forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdef.go
94 lines (75 loc) · 1.73 KB
/
def.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package reference
import (
digest "github.com/opencontainers/go-digest"
)
// Reference represents image name which may include hub/namespace/name:tag
// like registry.hub.docker.com/library/ubuntu:latest.
type Reference interface {
String() string
}
// Named is an object which has full name.
type Named interface {
Reference
Name() string
}
// Tagged is an Named object contains tag.
type Tagged interface {
Named
Tag() string
}
// CanonicalDigested is an object which doesn't contains the tag information.
type CanonicalDigested interface {
Named
Digest() digest.Digest
}
// Digested is an object which is digest.
type Digested interface {
Reference
Digest() digest.Digest
}
// namedReference represents the image short ID or Name.
type namedReference struct {
name string
}
func (n namedReference) Name() string {
return n.name
}
func (n namedReference) String() string {
return n.name
}
// taggedReference represents the image Name:tag.
type taggedReference struct {
Named
tag string
}
func (t taggedReference) Tag() string {
return t.tag
}
func (t taggedReference) String() string {
return t.Name() + ":" + t.tag
}
// canonicalDigestedReference represents the image canonical digest information.
type canonicalDigestedReference struct {
Named
digest digest.Digest
}
func (cd canonicalDigestedReference) String() string {
return cd.Name() + "@" + cd.digest.String()
}
func (cd canonicalDigestedReference) Digest() digest.Digest {
return cd.digest
}
type reference struct {
Named
tag string
digest digest.Digest
}
func (r reference) Tag() string {
return r.tag
}
func (r reference) Digest() digest.Digest {
return r.digest
}
func (r reference) String() string {
return r.Name() + ":" + r.tag + "@" + r.digest.String()
}