-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.go
78 lines (69 loc) · 1.56 KB
/
types.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
package flagstate
import (
"github.com/docker/distribution/digest"
)
type Image struct {
Digest digest.Digest
MediaType string
OS string
Architecture string
Annotations map[string]string `json:",omitempty"`
Labels map[string]string `json:",omitempty"`
}
type TaggedImage struct {
Image
Tags []string
}
type ImageList struct {
Digest digest.Digest
MediaType string
Images []*Image
Annotations map[string]string `json:",omitempty"`
}
type TaggedImageList struct {
ImageList
Tags []string
}
type Repository struct {
Name string
Images []*TaggedImage
Lists []*TaggedImageList
}
func (im *Image) Title() string {
if v := im.Annotations["org.opencontainers.image.title"]; v != "" {
return v
} else if v := im.Labels["org.label-schema.name"]; v != "" {
return v
} else if v := im.Labels["io.k8s.display-name"]; v != "" {
return v
} else if v := im.Labels["name"]; v != "" {
return v
} else if v := im.Labels["Name"]; v != "" {
return v
} else {
return ""
}
}
func (im *Image) Description() string {
if v := im.Annotations["org.opencontainers.image.description"]; v != "" {
return v
} else if v := im.Labels["org.label-schema.description"]; v != "" {
return v
} else if v := im.Labels["io.k8s.description"]; v != "" {
return v
} else if v := im.Labels["description"]; v != "" {
return v
} else if v := im.Labels["Description"]; v != "" {
return v
} else {
return ""
}
}
func (im *TaggedImage) IsLatest() bool {
for _, tag := range im.Tags {
if tag == "latest" {
return true
}
}
return false
}