/
types.go
575 lines (434 loc) · 13.5 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
package nodes
import (
"fmt"
"reflect"
kappsv1 "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
osgraph "github.com/openshift/origin/pkg/oc/lib/graph/genericgraph"
)
var (
ServiceNodeKind = reflect.TypeOf(corev1.Service{}).Name()
PodNodeKind = reflect.TypeOf(corev1.Pod{}).Name()
PodSpecNodeKind = reflect.TypeOf(corev1.PodSpec{}).Name()
PodTemplateSpecNodeKind = reflect.TypeOf(corev1.PodTemplateSpec{}).Name()
ReplicationControllerNodeKind = reflect.TypeOf(corev1.ReplicationController{}).Name()
ReplicationControllerSpecNodeKind = reflect.TypeOf(corev1.ReplicationControllerSpec{}).Name()
ServiceAccountNodeKind = reflect.TypeOf(corev1.ServiceAccount{}).Name()
SecretNodeKind = reflect.TypeOf(corev1.Secret{}).Name()
PersistentVolumeClaimNodeKind = reflect.TypeOf(corev1.PersistentVolumeClaim{}).Name()
JobNodeKind = reflect.TypeOf(batchv1.Job{}).Name()
JobSpecNodeKind = reflect.TypeOf(batchv1.JobSpec{}).Name()
HorizontalPodAutoscalerNodeKind = reflect.TypeOf(autoscalingv1.HorizontalPodAutoscaler{}).Name()
StatefulSetNodeKind = reflect.TypeOf(kappsv1.StatefulSet{}).Name()
StatefulSetSpecNodeKind = reflect.TypeOf(kappsv1.StatefulSetSpec{}).Name()
DeploymentNodeKind = reflect.TypeOf(kappsv1.Deployment{}).Name()
DeploymentSpecNodeKind = reflect.TypeOf(kappsv1.DeploymentSpec{}).Name()
ReplicaSetNodeKind = reflect.TypeOf(kappsv1.ReplicaSet{}).Name()
ReplicaSetSpecNodeKind = reflect.TypeOf(kappsv1.ReplicaSetSpec{}).Name()
DaemonSetNodeKind = reflect.TypeOf(kappsv1.DaemonSet{}).Name()
)
func ServiceNodeName(o *corev1.Service) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(ServiceNodeKind, o)
}
type ServiceNode struct {
osgraph.Node
*corev1.Service
IsFound bool
}
func (n ServiceNode) Object() interface{} {
return n.Service
}
func (n ServiceNode) String() string {
return string(ServiceNodeName(n.Service))
}
func (*ServiceNode) Kind() string {
return ServiceNodeKind
}
func (n ServiceNode) Found() bool {
return n.IsFound
}
func PodNodeName(o *corev1.Pod) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(PodNodeKind, o)
}
type PodNode struct {
osgraph.Node
*corev1.Pod
}
func (n PodNode) Object() interface{} {
return n.Pod
}
func (n PodNode) String() string {
return string(PodNodeName(n.Pod))
}
func (n PodNode) UniqueName() osgraph.UniqueName {
return PodNodeName(n.Pod)
}
func (*PodNode) Kind() string {
return PodNodeKind
}
func PodSpecNodeName(o *corev1.PodSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", PodSpecNodeKind, ownerName))
}
type PodSpecNode struct {
osgraph.Node
*corev1.PodSpec
Namespace string
OwnerName osgraph.UniqueName
}
func (n PodSpecNode) Object() interface{} {
return n.PodSpec
}
func (n PodSpecNode) String() string {
return string(n.UniqueName())
}
func (n PodSpecNode) UniqueName() osgraph.UniqueName {
return PodSpecNodeName(n.PodSpec, n.OwnerName)
}
func (*PodSpecNode) Kind() string {
return PodSpecNodeKind
}
func ReplicaSetNodeName(o *kappsv1.ReplicaSet) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(ReplicaSetNodeKind, o)
}
type ReplicaSetNode struct {
osgraph.Node
ReplicaSet *kappsv1.ReplicaSet
IsFound bool
}
func (n ReplicaSetNode) Found() bool {
return n.IsFound
}
func (n ReplicaSetNode) Object() interface{} {
return n.ReplicaSet
}
func (n ReplicaSetNode) String() string {
return string(ReplicaSetNodeName(n.ReplicaSet))
}
func (n ReplicaSetNode) UniqueName() osgraph.UniqueName {
return ReplicaSetNodeName(n.ReplicaSet)
}
func (*ReplicaSetNode) Kind() string {
return ReplicaSetNodeKind
}
func ReplicaSetSpecNodeName(o *kappsv1.ReplicaSetSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", ReplicaSetSpecNodeKind, ownerName))
}
type ReplicaSetSpecNode struct {
osgraph.Node
ReplicaSetSpec *kappsv1.ReplicaSetSpec
Namespace string
OwnerName osgraph.UniqueName
}
func (n ReplicaSetSpecNode) Object() interface{} {
return n.ReplicaSetSpec
}
func (n ReplicaSetSpecNode) String() string {
return string(n.UniqueName())
}
func (n ReplicaSetSpecNode) UniqueName() osgraph.UniqueName {
return ReplicaSetSpecNodeName(n.ReplicaSetSpec, n.OwnerName)
}
func (*ReplicaSetSpecNode) Kind() string {
return ReplicaSetSpecNodeKind
}
func ReplicationControllerNodeName(o *corev1.ReplicationController) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(ReplicationControllerNodeKind, o)
}
type ReplicationControllerNode struct {
osgraph.Node
ReplicationController *corev1.ReplicationController
IsFound bool
}
func (n ReplicationControllerNode) Found() bool {
return n.IsFound
}
func (n ReplicationControllerNode) Object() interface{} {
return n.ReplicationController
}
func (n ReplicationControllerNode) String() string {
return string(ReplicationControllerNodeName(n.ReplicationController))
}
func (n ReplicationControllerNode) UniqueName() osgraph.UniqueName {
return ReplicationControllerNodeName(n.ReplicationController)
}
func (*ReplicationControllerNode) Kind() string {
return ReplicationControllerNodeKind
}
func ReplicationControllerSpecNodeName(o *corev1.ReplicationControllerSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", ReplicationControllerSpecNodeKind, ownerName))
}
type ReplicationControllerSpecNode struct {
osgraph.Node
ReplicationControllerSpec *corev1.ReplicationControllerSpec
Namespace string
OwnerName osgraph.UniqueName
}
func (n ReplicationControllerSpecNode) Object() interface{} {
return n.ReplicationControllerSpec
}
func (n ReplicationControllerSpecNode) String() string {
return string(n.UniqueName())
}
func (n ReplicationControllerSpecNode) UniqueName() osgraph.UniqueName {
return ReplicationControllerSpecNodeName(n.ReplicationControllerSpec, n.OwnerName)
}
func (*ReplicationControllerSpecNode) Kind() string {
return ReplicationControllerSpecNodeKind
}
func PodTemplateSpecNodeName(o *corev1.PodTemplateSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", PodTemplateSpecNodeKind, ownerName))
}
type PodTemplateSpecNode struct {
osgraph.Node
*corev1.PodTemplateSpec
Namespace string
OwnerName osgraph.UniqueName
}
func (n PodTemplateSpecNode) Object() interface{} {
return n.PodTemplateSpec
}
func (n PodTemplateSpecNode) String() string {
return string(n.UniqueName())
}
func (n PodTemplateSpecNode) UniqueName() osgraph.UniqueName {
return PodTemplateSpecNodeName(n.PodTemplateSpec, n.OwnerName)
}
func (*PodTemplateSpecNode) Kind() string {
return PodTemplateSpecNodeKind
}
func ServiceAccountNodeName(o *corev1.ServiceAccount) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(ServiceAccountNodeKind, o)
}
type ServiceAccountNode struct {
osgraph.Node
*corev1.ServiceAccount
IsFound bool
}
func (n ServiceAccountNode) Found() bool {
return n.IsFound
}
func (n ServiceAccountNode) Object() interface{} {
return n.ServiceAccount
}
func (n ServiceAccountNode) String() string {
return string(ServiceAccountNodeName(n.ServiceAccount))
}
func (*ServiceAccountNode) Kind() string {
return ServiceAccountNodeKind
}
func SecretNodeName(o *corev1.Secret) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(SecretNodeKind, o)
}
type SecretNode struct {
osgraph.Node
*corev1.Secret
IsFound bool
}
func (n SecretNode) Found() bool {
return n.IsFound
}
func (n SecretNode) Object() interface{} {
return n.Secret
}
func (n SecretNode) String() string {
return string(SecretNodeName(n.Secret))
}
func (*SecretNode) Kind() string {
return SecretNodeKind
}
func PersistentVolumeClaimNodeName(o *corev1.PersistentVolumeClaim) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(PersistentVolumeClaimNodeKind, o)
}
type PersistentVolumeClaimNode struct {
osgraph.Node
PersistentVolumeClaim *corev1.PersistentVolumeClaim
IsFound bool
}
func (n PersistentVolumeClaimNode) Found() bool {
return n.IsFound
}
func (n PersistentVolumeClaimNode) Object() interface{} {
return n.PersistentVolumeClaim
}
func (n PersistentVolumeClaimNode) String() string {
return string(n.UniqueName())
}
func (*PersistentVolumeClaimNode) Kind() string {
return PersistentVolumeClaimNodeKind
}
func (n PersistentVolumeClaimNode) UniqueName() osgraph.UniqueName {
return PersistentVolumeClaimNodeName(n.PersistentVolumeClaim)
}
func JobNodeName(o *batchv1.Job) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(JobNodeKind, o)
}
type JobNode struct {
osgraph.Node
Job *batchv1.Job
IsFound bool
}
func (n JobNode) Found() bool {
return n.IsFound
}
func (n JobNode) Object() interface{} {
return n.Job
}
func (n JobNode) String() string {
return string(JobNodeName(n.Job))
}
func (n JobNode) UniqueName() osgraph.UniqueName {
return JobNodeName(n.Job)
}
func (*JobNode) Kind() string {
return JobNodeKind
}
func JobSpecNodeName(o *batchv1.JobSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", JobSpecNodeKind, ownerName))
}
type JobSpecNode struct {
osgraph.Node
JobSpec *batchv1.JobSpec
Namespace string
OwnerName osgraph.UniqueName
}
func (n JobSpecNode) Object() interface{} {
return n.JobSpec
}
func (n JobSpecNode) String() string {
return string(n.UniqueName())
}
func (n JobSpecNode) UniqueName() osgraph.UniqueName {
return JobSpecNodeName(n.JobSpec, n.OwnerName)
}
func (*JobSpecNode) Kind() string {
return JobSpecNodeKind
}
func HorizontalPodAutoscalerNodeName(o *autoscalingv1.HorizontalPodAutoscaler) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(HorizontalPodAutoscalerNodeKind, o)
}
type HorizontalPodAutoscalerNode struct {
osgraph.Node
HorizontalPodAutoscaler *autoscalingv1.HorizontalPodAutoscaler
}
func (n HorizontalPodAutoscalerNode) Object() interface{} {
return n.HorizontalPodAutoscaler
}
func (n HorizontalPodAutoscalerNode) String() string {
return string(n.UniqueName())
}
func (*HorizontalPodAutoscalerNode) Kind() string {
return HorizontalPodAutoscalerNodeKind
}
func (n HorizontalPodAutoscalerNode) UniqueName() osgraph.UniqueName {
return HorizontalPodAutoscalerNodeName(n.HorizontalPodAutoscaler)
}
func DeploymentNodeName(o *kappsv1.Deployment) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(DeploymentNodeKind, o)
}
type DeploymentNode struct {
osgraph.Node
Deployment *kappsv1.Deployment
IsFound bool
}
func (n DeploymentNode) Found() bool {
return n.IsFound
}
func (n DeploymentNode) Object() interface{} {
return n.Deployment
}
func (n DeploymentNode) String() string {
return string(n.UniqueName())
}
func (n DeploymentNode) UniqueName() osgraph.UniqueName {
return DeploymentNodeName(n.Deployment)
}
func (*DeploymentNode) Kind() string {
return DeploymentNodeKind
}
func DeploymentSpecNodeName(o *kappsv1.DeploymentSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", DeploymentSpecNodeKind, ownerName))
}
type DeploymentSpecNode struct {
osgraph.Node
DeploymentSpec *kappsv1.DeploymentSpec
Namespace string
OwnerName osgraph.UniqueName
}
func (n DeploymentSpecNode) Object() interface{} {
return n.DeploymentSpec
}
func (n DeploymentSpecNode) String() string {
return string(n.UniqueName())
}
func (n DeploymentSpecNode) UniqueName() osgraph.UniqueName {
return DeploymentSpecNodeName(n.DeploymentSpec, n.OwnerName)
}
func (*DeploymentSpecNode) Kind() string {
return DeploymentSpecNodeKind
}
func StatefulSetNodeName(o *kappsv1.StatefulSet) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(StatefulSetNodeKind, o)
}
type StatefulSetNode struct {
osgraph.Node
StatefulSet *kappsv1.StatefulSet
IsFound bool
}
func (n StatefulSetNode) Found() bool {
return n.IsFound
}
func (n StatefulSetNode) Object() interface{} {
return n.StatefulSet
}
func (n StatefulSetNode) String() string {
return string(n.UniqueName())
}
func (n StatefulSetNode) UniqueName() osgraph.UniqueName {
return StatefulSetNodeName(n.StatefulSet)
}
func (*StatefulSetNode) Kind() string {
return StatefulSetNodeKind
}
func StatefulSetSpecNodeName(o *kappsv1.StatefulSetSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", StatefulSetSpecNodeKind, ownerName))
}
type StatefulSetSpecNode struct {
osgraph.Node
StatefulSetSpec *kappsv1.StatefulSetSpec
Namespace string
OwnerName osgraph.UniqueName
}
func (n StatefulSetSpecNode) Object() interface{} {
return n.StatefulSetSpec
}
func (n StatefulSetSpecNode) String() string {
return string(n.UniqueName())
}
func (n StatefulSetSpecNode) UniqueName() osgraph.UniqueName {
return StatefulSetSpecNodeName(n.StatefulSetSpec, n.OwnerName)
}
func (*StatefulSetSpecNode) Kind() string {
return StatefulSetSpecNodeKind
}
func DaemonSetNodeName(o *kappsv1.DaemonSet) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(DaemonSetNodeKind, o)
}
type DaemonSetNode struct {
osgraph.Node
DaemonSet *kappsv1.DaemonSet
IsFound bool
}
func (n DaemonSetNode) Found() bool {
return n.IsFound
}
func (n DaemonSetNode) Object() interface{} {
return n.DaemonSet
}
func (n DaemonSetNode) String() string {
return string(DaemonSetNodeName(n.DaemonSet))
}
func (*DaemonSetNode) Kind() string {
return DaemonSetNodeKind
}