-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
types.go
186 lines (141 loc) · 4.19 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package nodes
import (
"fmt"
"reflect"
osgraph "github.com/openshift/origin/pkg/api/graph"
imageapi "github.com/openshift/origin/pkg/image/api"
)
var (
ImageStreamNodeKind = reflect.TypeOf(imageapi.ImageStream{}).Name()
ImageNodeKind = reflect.TypeOf(imageapi.Image{}).Name()
ImageStreamTagNodeKind = reflect.TypeOf(imageapi.ImageStreamTag{}).Name()
ImageStreamImageNodeKind = reflect.TypeOf(imageapi.ImageStreamImage{}).Name()
// non-api types
DockerRepositoryNodeKind = reflect.TypeOf(imageapi.DockerImageReference{}).Name()
ImageLayerNodeKind = "ImageLayer"
)
func ImageStreamNodeName(o *imageapi.ImageStream) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(ImageStreamNodeKind, o)
}
type ImageStreamNode struct {
osgraph.Node
*imageapi.ImageStream
IsFound bool
}
func (n ImageStreamNode) Found() bool {
return n.IsFound
}
func (n ImageStreamNode) Object() interface{} {
return n.ImageStream
}
func (n ImageStreamNode) String() string {
return string(ImageStreamNodeName(n.ImageStream))
}
func (n ImageStreamNode) ResourceString() string {
return "is/" + n.Name
}
func (*ImageStreamNode) Kind() string {
return ImageStreamNodeKind
}
func ImageStreamTagNodeName(o *imageapi.ImageStreamTag) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(ImageStreamTagNodeKind, o)
}
type ImageStreamTagNode struct {
osgraph.Node
*imageapi.ImageStreamTag
IsFound bool
}
func (n ImageStreamTagNode) Found() bool {
return n.IsFound
}
func (n ImageStreamTagNode) ImageSpec() string {
name, tag, _ := imageapi.SplitImageStreamTag(n.ImageStreamTag.Name)
return imageapi.DockerImageReference{Namespace: n.Namespace, Name: name, Tag: tag}.String()
}
func (n ImageStreamTagNode) ImageTag() string {
_, tag, _ := imageapi.SplitImageStreamTag(n.ImageStreamTag.Name)
return tag
}
func (n ImageStreamTagNode) Object() interface{} {
return n.ImageStreamTag
}
func (n ImageStreamTagNode) String() string {
return string(ImageStreamTagNodeName(n.ImageStreamTag))
}
func (n ImageStreamTagNode) ResourceString() string {
return "imagestreamtag/" + n.Name
}
func (*ImageStreamTagNode) Kind() string {
return ImageStreamTagNodeKind
}
func ImageStreamImageNodeName(o *imageapi.ImageStreamImage) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(ImageStreamImageNodeKind, o)
}
type ImageStreamImageNode struct {
osgraph.Node
*imageapi.ImageStreamImage
IsFound bool
}
func (n ImageStreamImageNode) Object() interface{} {
return n.ImageStreamImage
}
func (n ImageStreamImageNode) String() string {
return string(ImageStreamImageNodeName(n.ImageStreamImage))
}
func (*ImageStreamImageNode) Kind() string {
return ImageStreamImageNodeKind
}
func DockerImageRepositoryNodeName(o imageapi.DockerImageReference) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%s", DockerRepositoryNodeKind, o.String()))
}
type DockerImageRepositoryNode struct {
osgraph.Node
Ref imageapi.DockerImageReference
}
func (n DockerImageRepositoryNode) ImageSpec() string {
return n.Ref.String()
}
func (n DockerImageRepositoryNode) ImageTag() string {
return n.Ref.DockerClientDefaults().Tag
}
func (n DockerImageRepositoryNode) String() string {
return string(DockerImageRepositoryNodeName(n.Ref))
}
func (*DockerImageRepositoryNode) Kind() string {
return DockerRepositoryNodeKind
}
func ImageNodeName(o *imageapi.Image) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(ImageNodeKind, o)
}
type ImageNode struct {
osgraph.Node
Image *imageapi.Image
}
func (n ImageNode) Object() interface{} {
return n.Image
}
func (n ImageNode) String() string {
return string(ImageNodeName(n.Image))
}
func (n ImageNode) ResourceString() string {
return "image/" + n.Image.Name
}
func (*ImageNode) Kind() string {
return ImageNodeKind
}
func ImageLayerNodeName(layer string) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%s", ImageLayerNodeKind, layer))
}
type ImageLayerNode struct {
osgraph.Node
Layer string
}
func (n ImageLayerNode) Object() interface{} {
return n.Layer
}
func (n ImageLayerNode) String() string {
return string(ImageLayerNodeName(n.Layer))
}
func (*ImageLayerNode) Kind() string {
return ImageLayerNodeKind
}