forked from CATechnologiesTest/kubeiql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kubeiql.go
977 lines (858 loc) · 26.4 KB
/
kubeiql.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
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
// Copyright (c) 2018 CA. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"context"
)
// The schema below defines the objects and relationships for Kubernetes.
// It is not yet complete.
var Schema = `
schema {
query: Query
mutation: Mutation
}
# The query type, represents all of the entry points into our object graph
type Query {
# look up pods
allPods(): [Pod]
allPodsInNamespace(namespace: String!): [Pod]
podByName(namespace: String!, name: String!): Pod
# look up deployments
allDeployments(): [Deployment]
allDeploymentsInNamespace(namespace: String!): [Deployment]
deploymentByName(namespace: String!, name: String!): Deployment
# look up replica sets
allReplicaSets(): [ReplicaSet]
allReplicaSetsInNamespace(namespace: String!): [ReplicaSet]
replicaSetByName(namespace: String!, name: String!): ReplicaSet
# look up daemon sets
allDaemonSets(): [DaemonSet]
allDaemonSetsInNamespace(namespace: String!): [DaemonSet]
daemonSetByName(namespace: String!, name: String!): DaemonSet
# look up stateful sets
allStatefulSets(): [StatefulSet]
allStatefulSetsInNamespace(namespace: String!): [StatefulSet]
statefulSetByName(namespace: String!, name: String!): StatefulSet
# look up services
allServices(): [Service]
allServicesInNamespace(namespace: String!): [Service]
serviceByName(namespace: String!, name: String!): Service
}
# The mutation type, represents all updates we can make to our data
type Mutation {
}
# Available logging levels
enum LogLevel {
debug
info
warning
error
fatal
panic
}
# A service
type Service implements Resource {
# The metadata for the service (name, labels, namespace, etc.)
metadata: Metadata!
# The description for the service
spec: ServiceSpec!
# The direct owner of the replicaSet
owner: Resource
# The root owner of the replicaSet
rootOwner: Resource
# Which controllers does this service select?
selected: [Resource!]!
# Runtime status
# status ServiceStatus! XXX
}
# Description of a service
type ServiceSpec {
# IP Address of the service
clusterIP: String
# External IPs
externalIPs: [String!]
# External reference for kubedns
externalName: String
# How a service should redirect to ports
externalTrafficPolicy: String
# Port used by health checks
healthCheckNodePort: Int
# IP for load balancer
loadBalancerIP: String
# Ranges from which to choose load balancer IPs
loadBalancerSourceRanges: [String!]
# Exposed ports
ports: [ServicePort!]
# Whether to publish dns addresses when peers are not yet ready for
# discovery
publishNotReadyAddresses: Boolean
# Labels to select controllers for association with the service
selector: [Label!]!
# Whether or not to use session affinity ("ClientIP" or "None")
sessionAffinity: String
# Config for session affinity
sessionAffinityConfig: SessionAffinityConfig
# Type of service
type: ServiceType!
}
# A port managed by a service
type ServicePort {
# port name, if any -- required if multiple ports
name: String
# port allocated to each node on which this service is exposed
nodePort: Int
# port exposed by the service
port: Int!
# IP Protocol - "TCP" or "UDP", default: "TCP"
protocol: String
# Number or name of port on the pods targeted by the service
targetPortString: String
targetPortInt: Int
}
# Service Types
enum ServiceType { ClientIP NodePort ExternalName LoadBalancer }
# Session affinity config
type SessionAffinityConfig {
# config for client IP
clientIP: ClientIPConfig!
}
# Client IP config
type ClientIPConfig {
# timeout between 0 and 86400 (one day)
timeoutSeconds: Int!
}
# A pod
type Pod implements Resource {
# The metadata for the pod (name, labels, namespace, etc.)
metadata: Metadata!
# behavior specification
spec: PodSpec!
# The direct owner of the pod
owner: Resource
# The root owner of the pod
rootOwner: Resource
# XXX PodStatus
}
# A replicaSet
type ReplicaSet implements Resource {
# The metadata for the replicaSet (name, labels, namespace, etc.)
metadata: Metadata!
# The direct owner of the replicaSet
owner: Resource
# The root owner of the replicaSet
rootOwner: Resource
# The pods controlled by this replicaSet
pods: [Pod!]!
}
# A statefulSet
type StatefulSet implements Resource {
# The metadata for the statefulSet (name, labels, namespace, etc.)
metadata: Metadata!
# The direct owner of the statefulSet
owner: Resource
# The root owner of the statefulSet
rootOwner: Resource
# The pods controlled by this statefulSet
pods: [Pod!]!
}
# A daemonSet
type DaemonSet implements Resource {
# The metadata for the daemonSet (name, labels, namespace, etc.)
metadata: Metadata!
# The direct owner of the daemonSet
owner: Resource
# The root owner of the daemonSet
rootOwner: Resource
# The pods controlled by this daemonSet
pods: [Pod!]!
}
# A deployment
type Deployment implements Resource {
# The metadata for the deployment (name, labels, namespace, etc.)
metadata: Metadata!
# Description of the deployment
spec: DeploymentSpec!
# The direct owner of the deployment
owner: Resource
# The root owner of the deployment
rootOwner: Resource
# The replicaSets that are children of this deployment
replicaSets: [ReplicaSet!]!
}
# A deployment specification
type DeploymentSpec {
# Minimum number of seconds for which a newly created pod should be
# ready without any of its container crashing, for it to be considered
# available (defaults to 0)
minReadySeconds: Int!
# Whether or not the deployment is paused
paused: Boolean!
# The maximum time in seconds for a deployment to make progress before
# it is considered to be failed.
progressDeadlineSeconds: Int!
# Number of desired pods (default: 1).
replicas: Int!
# The number of old ReplicaSets to retain to allow rollback (default: 10).
revisionHistoryLimit: Int!
# Label selector for pods.
selector: LabelSelector
# The deployment strategy to use to replace existing pods with new ones.
strategy: DeploymentStrategy!
# Template describing the pods that will be created.
template: PodTemplateSpec!
}
# metadata
type Metadata { # annotations??
# When was the decorated object created
creationTimestamp: String
# Prefix for generated names
generateName: String
# Sequence number for state transitions
generation: Int
# Top level labels
labels: [Label!]!
# Generated name
name: String
# Namespace containing the object
namespace: String
# All owners
ownerReferences: [Resource!]
# Version
resourceVersion: String
# How to find this object
selfLink: String
# UUID
uid: String
}
# PodTemplateSpec
type PodTemplateSpec {
# standard metadata
metadata: Metadata!
# Specification for generated pods
spec: PodSpec!
}
# PodSpec
type PodSpec {
# Optional duration in seconds the pod may be active on the node
# relative to StartTime before the system will actively try to mark it
# failed and kill associated containers. Value must be a positive integer.
activeDeadlineSeconds: Int
# Scheduling constraints for the pod, if specified
affinity: Affinity
# AutomountServiceAccountToken indicates whether a service account token
# should be automatically mounted.
automountServiceAccountToken: Boolean!
# List of containers belonging to the pod
containers: [Container!]!
# DNS parameters of a pod
dnsConfig: PodDNSConfig
# DNS policy for the pod -- defaults to "ClusterFirst"
dnsPolicy: DNSPolicy
# List of hosts and IPs to inject into pod host file
hostAliases: [HostAlias!]
# Whether or not to use the host ipc namespace -- default: false
hostIPC: Boolean!
# Whether or not to use host networking -- default: false
hostNetwork: Boolean!
# Whether or not to use the host pid namespace -- default: false
hostPID: Boolean!
# Hostname for the pod -- defaults to system-generated value
hostname: String
# List of references to secrets in the same namespace used to pull images
imagePullSecrets: [LocalObjectReference!]
# Initialization containers for the pod
initContainers: [Container!]
# Name of specific host on which to schedule the pod (if any)
nodeName: String
# Priority of the pod
priority: Int
# Class name of priority class for the pod
priorityClassName: String
# Conditions to evaluate for pod readiness
readinessGates: [PodReadinessGate!]
# Restart policy for all containers within the pod -- default: Always
restartPolicy: RestartPolicy!
# Specific scheduler to use for pod
schedulerName: String
# Pod-level security attributes and common container settings
securityContext: PodSecurityContext
# Name of service account to use when running this pod
serviceAccountName: String
# Whether or not to share a single process namespace between all containers
# default: false
shareProcessNamespace: Boolean!
# Desired pod subdomain, if any
subdomain: String
# Duration in seconds the pod needs to terminate gracefully -- default: 30s
terminationGracePeriodSeconds: Int!
# Tolerations for the pod
tolerations: [Toleration!]
# List of volumes that can be mounted by containers in the pod
volumes: [Volume!]
}
# Persistent storage
type Volume {
#
# INCOMPLETE
#
# config map used to populate the volume
configMap: ConfigMapVolumeSource
# volume name -- must be a DNS_LABEL and unique within the pod
name: String!
# a pre-existing file or directory on the host machine
hostPath: HostPathVolumeSource
# reference to a persistent volume claim
persistentVolumeClaim: PersistentVolumeClaimVolumeSource
# a secret that should populate the volume
secret: SecretVolumeSource
}
# Volume sources
type ConfigMapVolumeSource {
# mode bits to use on created files by default -- default value: 0644
defaultMode: Int
# specific config map items to expose -- if unset, expose all
items: [KeyToPath!]
# name of map
name: String!
# Is it okay if the config map does not exist? -- default: false
optional: Boolean!
}
type HostPathVolumeSource {
# path of the directory on the host
path: String!
# type for host path volume -- defaults to: ""
type: String
}
type PersistentVolumeClaimVolumeSource {
# name of a PersistentVolumeClaim in the same namespace as the pod
claimName: String!
# Is the claim read only? -- default: false
readOnly: Boolean!
}
type SecretVolumeSource {
# mode bits to use on created files by default -- default value: 0644
defaultMode: Int
# specific secret items to expose -- if unset, expose all
items: [KeyToPath!]
# Is it okay if the secret does not exist? -- default: false
optional: Boolean!
# name of secret
secretName: String!
}
# kernel parameters to set
type Sysctl {
# name of a parameter
name: String!
# parameter value
value: String!
}
# mapping of string key to path within a volume
type KeyToPath {
# the key to project
key: String!
# mode bits to use on the file [0 .. 0777]; if empty, uses volume default
mode: Int
# relative path of the file to map
path: String!
}
# Reference to a pod condition
type PodReadinessGate {
# a condition in the condition list for the pod
conditionType: String!
}
# Pod-level security attributes and common container settings
type PodSecurityContext {
# supplemental group that applies to all containers in a pod
fsGroup: Int
# GID for container process entrypoint
runAsGroup: Int
# Must the container run as non-root?
runAsNonRoot: Boolean!
# UID for container process entrypoint
runAsUser: Int
# SELinux context to apply to all containers
seLinuxOptions: SELinuxOptions
# list of groups applied to the first process run in each container in
# addition to the primary group
supplementalGroups: [Int!]
# list of namespaced sysctls user for the pod
sysctls: [Sysctl!]
}
# Conditions determining whether a node can host a particular pod
type Toleration {
# the taint effect to match
effect: TolerationEffect
# the taint key the toleration references; empty means match all
key: String
# relationship between key and value
operator: TolerationOperator
# the period of time the toleration tolerates the taint; unset means
# forever, zero or negative means immediately evict
tolerationSeconds: Int
# taint value matched by the toleration -- should be empty if operator
# is "Exists"
value: String
}
# Operators for tolerations
enum TolerationOperator {
Exists Equal
}
# Toleration effect possible values
enum TolerationEffect {
NoSchedule PreferNoSchedule NoExecute
}
# SELinux labels to apply to a container
type SELinuxOptions {
# level label
level: String
# role label
role: String
# type label
type: String
#user label
user: String
}
# LocalObjectReference
type LocalObjectReference {
# name of referenced object
name: String!
}
# DNS support
type PodDNSConfig {
# list of DNS name server IP addresses
nameservers: [String!]
# DNS resolver options
options: [PodDNSConfigOption!]
# DNS search domains for host-name lookup
searches: [String!]
}
# Options for DNS config
type PodDNSConfigOption {
name: String!
value: String!
}
# HostAlias
type HostAlias {
# Hostnames for the IP address
hostnames: [String!]!
# IP address of the host
ip: String!
}
# Container
type Container {
# XXX not yet
}
# Affinity
type Affinity {
# affinity with nodes
nodeAffinity: NodeAffinity
# affinity with other pods
podAffinity: PodAffinity
# anti-affinity with other pods
podAntiAffinity: PodAntiAffinity
}
# NodeAffinity
type NodeAffinity {
# nodes satisfying these conditions will be preferred
preferredDuringSchedulingIgnoredDuringExecution: [PreferredSchedulingTerm!]
# nodes satisfying these conditions will be required
requiredDuringSchedulingIgnoredDuringExecution: NodeSelector
}
# NodeSelector
type NodeSelector {
# list of terms used to match nodes for deployment (ORed together)
nodeSelectorTerms: [NodeSelectorTerm!]!
}
# NodeSelectorTerm
type NodeSelectorTerm {
# node requirements based on node labels
matchExpressions: [NodeSelectorRequirement!]
# node requirements based on node fields
matchFields: [NodeSelectorRequirement!]
}
# Requirement expression matched against node labels
type NodeSelectorRequirement {
# The node key that the selector applies to
key: String!
# The expression operator
operator: NodeOperator!
# The values to match against
values: [String!]
}
# PodAffinity
type PodAffinity {
# nodes satisfying these conditions will be preferred
preferredDuringSchedulingIgnoredDuringExecution: [WeightedPodAffinityTerm!]
# nodes satisfying these conditions will be required
requiredDuringSchedulingIgnoredDuringExecution: PodAffinityTerm
}
# PodAntiAffinity
type PodAntiAffinity {
# nodes satisfying these conditions will be preferred
preferredDuringSchedulingIgnoredDuringExecution: [WeightedPodAffinityTerm!]
# nodes satisfying these conditions will be required
requiredDuringSchedulingIgnoredDuringExecution: PodAffinityTerm
}
# WeightedPodAffinityTerm
type WeightedPodAffinityTerm {
# term associated with a weight
podAffinityTerm: PodAffinityTerm!
# weight for the term
weight: Int!
}
# PodAffinityTerm
type PodAffinityTerm {
# selector to match other pod labels
labelSelector: LabelSelector
# which namespaces to match against -- defaults to the pod namespace
namespaces: [String!]
# whether the pod should be co-located or not co-located with pods
# matching the selector
topologyKey: String!
}
# PreferredSchedulingTerm
type PreferredSchedulingTerm {
# node preference
preference: NodeSelectorTerm!
# weight associated with the term
weight: Int!
}
# Node operator values
enum NodeOperator {
In NotIn Exists DoesNotExist Gt Lt
}
# RestartPolicy values
enum RestartPolicy {
Always OnFailure Never
}
# DNSPolicy values
enum DNSPolicy {
ClusterFirstWithHostNet ClusterFirst Default None
}
# LabelSelector for matching pods
type LabelSelector {
# constraint expressions for labels
matchExpressions: [LabelSelectorRequirement!]
# key/value matches
matchLabels: [Label!]
}
# Constraint expression for labels
type LabelSelectorRequirement {
# The label key that the selector applies to
key: String!
# The expression operator
operator: LabelOperator!
# The values to match against
values: [String!]!
}
# Constraint operators for labels
enum LabelOperator {
In NotIn Exists DoesNotExist
}
# deployment strategy
type DeploymentStrategy {
# Rolling update config parameters
rollingUpdate: RollingUpdateDeployment
# Type of deployment
type: DeploymentStrategyType
}
# Types of deployment strategy
enum DeploymentStrategyType {
Recreate RollingUpdate
}
# The following section is a mess due to the questionable decision by
# the Kubernetes team to make certain fields contain either ints or
# strings (WHY?????)
# rolling update parameters
type RollingUpdateDeployment {
# The maximum number of pods that can be scheduled above the desired
# number of pods.
maxSurgeInt: Int
maxSurgeString: String
# The maximum number of pods that can be unavailable during the update.
maxUnavailableInt: Int
maxUnavailableString: String
}
# A label
type Label {
# label name
name: String!
# label value
value: String!
}
# Any Kubernetes resource
interface Resource {
# type of resource
kind: String!
# resource metadata
metadata: Metadata!
# resource direct owner
owner: Resource
# resource root owner
rootOwner: Resource
}
`
const PodKind = "Pod"
const ReplicaSetKind = "ReplicaSet"
const StatefulSetKind = "StatefulSet"
const DaemonSetKind = "DaemonSet"
const DeploymentKind = "Deployment"
const ServiceKind = "Service"
// The root of all queries and mutations. All defined queries and mutations
// start as methods on Resolver
type Resolver struct {
}
// Objects in json are unmarshalled into map[string]interface{}
type JsonObject = map[string]interface{}
type JsonArray = []interface{}
// Pod lookups
func (r *Resolver) AllPods(ctx context.Context) *[]*podResolver {
pset := getAllK8sObjsOfKind(
ctx,
PodKind,
func(jobj JsonObject) bool { return true })
results := make([]*podResolver, len(pset))
for idx, p := range pset {
results[idx] = p.(*podResolver)
}
return &results
}
func (r *Resolver) AllPodsInNamespace(
ctx context.Context,
args *struct {
Namespace string
}) *[]*podResolver {
pset := getAllK8sObjsOfKindInNamespace(
ctx,
PodKind,
args.Namespace,
func(jobj JsonObject) bool { return true })
results := make([]*podResolver, len(pset))
for idx, p := range pset {
results[idx] = p.(*podResolver)
}
return &results
}
func (r *Resolver) PodByName(
ctx context.Context,
args *struct {
Namespace string
Name string
}) *podResolver {
res := getK8sResource(ctx, PodKind, args.Namespace, args.Name)
if res == nil {
return nil
}
return res.(*podResolver)
}
// Deployment lookups
func (r *Resolver) AllDeployments(ctx context.Context) *[]*deploymentResolver {
dset := getAllK8sObjsOfKind(
ctx,
DeploymentKind,
func(jobj JsonObject) bool { return true })
results := make([]*deploymentResolver, len(dset))
for idx, d := range dset {
results[idx] = d.(*deploymentResolver)
}
return &results
}
func (r *Resolver) AllDeploymentsInNamespace(
ctx context.Context,
args *struct {
Namespace string
}) *[]*deploymentResolver {
dset := getAllK8sObjsOfKindInNamespace(
ctx,
DeploymentKind,
args.Namespace,
func(jobj JsonObject) bool { return true })
results := make([]*deploymentResolver, len(dset))
for idx, p := range dset {
results[idx] = p.(*deploymentResolver)
}
return &results
}
func (r *Resolver) DeploymentByName(
ctx context.Context,
args *struct {
Namespace string
Name string
}) *deploymentResolver {
res := getK8sResource(ctx, DeploymentKind, args.Namespace, args.Name)
if res == nil {
return nil
}
return res.(*deploymentResolver)
}
// ReplicaSet lookups
func (r *Resolver) AllReplicaSets(ctx context.Context) *[]*replicaSetResolver {
rset := getAllK8sObjsOfKind(
ctx,
ReplicaSetKind,
func(jobj JsonObject) bool { return true })
results := make([]*replicaSetResolver, len(rset))
for idx, r := range rset {
results[idx] = r.(*replicaSetResolver)
}
return &results
}
func (r *Resolver) AllReplicaSetsInNamespace(
ctx context.Context,
args *struct {
Namespace string
}) *[]*replicaSetResolver {
rset := getAllK8sObjsOfKindInNamespace(
ctx,
ReplicaSetKind,
args.Namespace,
func(jobj JsonObject) bool { return true })
results := make([]*replicaSetResolver, len(rset))
for idx, p := range rset {
results[idx] = p.(*replicaSetResolver)
}
return &results
}
func (r *Resolver) ReplicaSetByName(
ctx context.Context,
args *struct {
Namespace string
Name string
}) *replicaSetResolver {
res := getK8sResource(ctx, ReplicaSetKind, args.Namespace, args.Name)
if res == nil {
return nil
}
return res.(*replicaSetResolver)
}
// StatefulSet lookups
func (r *Resolver) AllStatefulSets(ctx context.Context) *[]*statefulSetResolver {
sset := getAllK8sObjsOfKind(
ctx,
StatefulSetKind,
func(jobj JsonObject) bool { return true })
results := make([]*statefulSetResolver, len(sset))
for idx, s := range sset {
results[idx] = s.(*statefulSetResolver)
}
return &results
}
func (r *Resolver) AllStatefulSetsInNamespace(
ctx context.Context,
args *struct {
Namespace string
}) *[]*statefulSetResolver {
sset := getAllK8sObjsOfKindInNamespace(
ctx,
StatefulSetKind,
args.Namespace,
func(jobj JsonObject) bool { return true })
results := make([]*statefulSetResolver, len(sset))
for idx, p := range sset {
results[idx] = p.(*statefulSetResolver)
}
return &results
}
func (r *Resolver) StatefulSetByName(
ctx context.Context,
args *struct {
Namespace string
Name string
}) *statefulSetResolver {
res := getK8sResource(ctx, StatefulSetKind, args.Namespace, args.Name)
if res == nil {
return nil
}
return res.(*statefulSetResolver)
}
// Service lookups
func (r *Resolver) AllServices(ctx context.Context) *[]*serviceResolver {
sset := getAllK8sObjsOfKind(
ctx,
ServiceKind,
func(jobj JsonObject) bool { return true })
results := make([]*serviceResolver, len(sset))
for idx, s := range sset {
results[idx] = s.(*serviceResolver)
}
return &results
}
func (r *Resolver) AllServicesInNamespace(
ctx context.Context,
args *struct {
Namespace string
}) *[]*serviceResolver {
sset := getAllK8sObjsOfKindInNamespace(
ctx,
ServiceKind,
args.Namespace,
func(jobj JsonObject) bool { return true })
results := make([]*serviceResolver, len(sset))
for idx, p := range sset {
results[idx] = p.(*serviceResolver)
}
return &results
}
func (r *Resolver) ServiceByName(
ctx context.Context,
args *struct {
Namespace string
Name string
}) *serviceResolver {
res := getK8sResource(ctx, ServiceKind, args.Namespace, args.Name)
if res == nil {
return nil
}
return res.(*serviceResolver)
}
// DaemonSet lookups
func (r *Resolver) AllDaemonSets(ctx context.Context) *[]*daemonSetResolver {
dset := getAllK8sObjsOfKind(
ctx,
DaemonSetKind,
func(jobj JsonObject) bool { return true })
results := make([]*daemonSetResolver, len(dset))
for idx, d := range dset {
results[idx] = d.(*daemonSetResolver)
}
return &results
}
func (r *Resolver) AllDaemonSetsInNamespace(
ctx context.Context,
args *struct {
Namespace string
}) *[]*daemonSetResolver {
dset := getAllK8sObjsOfKindInNamespace(
ctx,
DaemonSetKind,
args.Namespace,
func(jobj JsonObject) bool { return true })
results := make([]*daemonSetResolver, len(dset))
for idx, p := range dset {
results[idx] = p.(*daemonSetResolver)
}
return &results
}
func (r *Resolver) DaemonSetByName(
ctx context.Context,
args *struct {
Namespace string
Name string
}) *daemonSetResolver {
res := getK8sResource(ctx, DaemonSetKind, args.Namespace, args.Name)
if res == nil {
return nil
}
return res.(*daemonSetResolver)
}