forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirtinformers.go
1286 lines (1069 loc) · 51.8 KB
/
virtinformers.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
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of the KubeVirt project
*
* 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.
*
* Copyright 2017, 2018 Red Hat, Inc.
*
*/
package controller
import (
"errors"
"fmt"
"math/rand"
"sync"
"time"
"kubevirt.io/api/snapshot"
"kubevirt.io/api/clone"
clonev1alpha1 "kubevirt.io/api/clone/v1alpha1"
promv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
vsv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
routev1 "github.com/openshift/api/route/v1"
secv1 "github.com/openshift/api/security/v1"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
k8sv1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
policyv1 "k8s.io/api/policy/v1"
rbacv1 "k8s.io/api/rbac/v1"
storagev1 "k8s.io/api/storage/v1"
extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
extclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/informers"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
apiregv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
aggregatorclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
"kubevirt.io/api/core"
kubev1 "kubevirt.io/api/core/v1"
exportv1 "kubevirt.io/api/export/v1alpha1"
instancetypeapi "kubevirt.io/api/instancetype"
instancetypev1alpha2 "kubevirt.io/api/instancetype/v1alpha2"
"kubevirt.io/api/migrations"
migrationsv1 "kubevirt.io/api/migrations/v1alpha1"
poolv1 "kubevirt.io/api/pool/v1alpha1"
snapshotv1 "kubevirt.io/api/snapshot/v1alpha1"
"kubevirt.io/client-go/kubecli"
"kubevirt.io/client-go/log"
cdiv1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
"kubevirt.io/kubevirt/pkg/testutils"
)
const (
/*
TODO: replace the assignment to expression that accepts only kubev1.ManagedByLabelOperatorValue after few releases (after 0.47)
The new assignment is to avoid error on update
(operator can't recognize components with the old managed-by label's value)
*/
OperatorLabel = kubev1.ManagedByLabel + " in (" + kubev1.ManagedByLabelOperatorValue + "," + kubev1.ManagedByLabelOperatorOldValue + " )"
NotOperatorLabel = kubev1.ManagedByLabel + " notin (" + kubev1.ManagedByLabelOperatorValue + "," + kubev1.ManagedByLabelOperatorOldValue + " )"
)
var unexpectedObjectError = errors.New("unexpected object")
type newSharedInformer func() cache.SharedIndexInformer
type KubeInformerFactory interface {
// Starts any informers that have not been started yet
// This function is thread safe and idempotent
Start(stopCh <-chan struct{})
// Waits for all informers to sync
WaitForCacheSync(stopCh <-chan struct{})
// Watches for vmi objects
VMI() cache.SharedIndexInformer
// Watches for vmi objects assigned to a specific host
VMISourceHost(hostName string) cache.SharedIndexInformer
// Watches for vmi objects assigned to a specific host
// as a migration target
VMITargetHost(hostName string) cache.SharedIndexInformer
// Watches for VirtualMachineInstanceReplicaSet objects
VMIReplicaSet() cache.SharedIndexInformer
// Watches for VirtualMachinePool objects
VMPool() cache.SharedIndexInformer
// Watches for VirtualMachineInstancePreset objects
VirtualMachinePreset() cache.SharedIndexInformer
// Watches for pods related only to kubevirt
KubeVirtPod() cache.SharedIndexInformer
// Watches for nodes
KubeVirtNode() cache.SharedIndexInformer
// VirtualMachine handles the VMIs that are stopped or not running
VirtualMachine() cache.SharedIndexInformer
// Watches VirtualMachineInstanceMigration objects
VirtualMachineInstanceMigration() cache.SharedIndexInformer
// Watches VirtualMachineExport objects
VirtualMachineExport() cache.SharedIndexInformer
// Watches VirtualMachineSnapshot objects
VirtualMachineSnapshot() cache.SharedIndexInformer
// Watches VirtualMachineSnapshot objects
VirtualMachineSnapshotContent() cache.SharedIndexInformer
// Watches VirtualMachineRestore objects
VirtualMachineRestore() cache.SharedIndexInformer
// Watches MigrationPolicy objects
MigrationPolicy() cache.SharedIndexInformer
// Watches VirtualMachineClone objects
VirtualMachineClone() cache.SharedIndexInformer
// Watches VirtualMachineInstancetype objects
VirtualMachineInstancetype() cache.SharedIndexInformer
// Watches VirtualMachineClusterInstancetype objects
VirtualMachineClusterInstancetype() cache.SharedIndexInformer
// Watches VirtualMachinePreference objects
VirtualMachinePreference() cache.SharedIndexInformer
// Watches VirtualMachineClusterPreference objects
VirtualMachineClusterPreference() cache.SharedIndexInformer
// Watches for k8s extensions api configmap
ApiAuthConfigMap() cache.SharedIndexInformer
// Watches for the kubevirt CA config map
KubeVirtCAConfigMap() cache.SharedIndexInformer
// Watches for the kubevirt export CA config map
KubeVirtExportCAConfigMap() cache.SharedIndexInformer
// Watches for the export route config map
ExportRouteConfigMap() cache.SharedIndexInformer
// Watches for the kubevirt export service
ExportService() cache.SharedIndexInformer
// ConfigMaps which are managed by the operator
OperatorConfigMap() cache.SharedIndexInformer
// Watches for PersistentVolumeClaim objects
PersistentVolumeClaim() cache.SharedIndexInformer
// Watches for ControllerRevision objects
ControllerRevision() cache.SharedIndexInformer
// Watches for CDI DataVolume objects
DataVolume() cache.SharedIndexInformer
// Fake CDI DataVolume informer used when feature gate is disabled
DummyDataVolume() cache.SharedIndexInformer
// Watches for CDI DataSource objects
DataSource() cache.SharedIndexInformer
// Fake CDI DataSource informer used when feature gate is disabled
DummyDataSource() cache.SharedIndexInformer
// Watches for CDI objects
CDI() cache.SharedIndexInformer
// Fake CDI informer used when feature gate is disabled
DummyCDI() cache.SharedIndexInformer
// Watches for CDIConfig objects
CDIConfig() cache.SharedIndexInformer
// Fake CDIConfig informer used when feature gate is disabled
DummyCDIConfig() cache.SharedIndexInformer
// CRD
CRD() cache.SharedIndexInformer
// Watches for KubeVirt objects
KubeVirt() cache.SharedIndexInformer
// Service Accounts
OperatorServiceAccount() cache.SharedIndexInformer
// ClusterRole
OperatorClusterRole() cache.SharedIndexInformer
// ClusterRoleBinding
OperatorClusterRoleBinding() cache.SharedIndexInformer
// Roles
OperatorRole() cache.SharedIndexInformer
// RoleBinding
OperatorRoleBinding() cache.SharedIndexInformer
// CRD
OperatorCRD() cache.SharedIndexInformer
// Service
OperatorService() cache.SharedIndexInformer
// DaemonSet
OperatorDaemonSet() cache.SharedIndexInformer
// Deployment
OperatorDeployment() cache.SharedIndexInformer
// SecurityContextConstraints
OperatorSCC() cache.SharedIndexInformer
// Fake SecurityContextConstraints informer used when not on openshift
DummyOperatorSCC() cache.SharedIndexInformer
// Routes
OperatorRoute() cache.SharedIndexInformer
// Fake Routes informer used when not on openshift
DummyOperatorRoute() cache.SharedIndexInformer
// Ingress
Ingress() cache.SharedIndexInformer
// ConfigMaps for operator install strategies
OperatorInstallStrategyConfigMaps() cache.SharedIndexInformer
// Jobs for dumping operator install strategies
OperatorInstallStrategyJob() cache.SharedIndexInformer
// KubeVirt infrastructure pods
OperatorPod() cache.SharedIndexInformer
// Webhooks created/managed by virt operator
OperatorValidationWebhook() cache.SharedIndexInformer
// Webhooks created/managed by virt operator
OperatorMutatingWebhook() cache.SharedIndexInformer
// APIServices created/managed by virt operator
OperatorAPIService() cache.SharedIndexInformer
// PodDisruptionBudgets created/managed by virt operator
OperatorPodDisruptionBudget() cache.SharedIndexInformer
// ServiceMonitors created/managed by virt operator
OperatorServiceMonitor() cache.SharedIndexInformer
// Managed secrets which hold data like certificates
Secrets() cache.SharedIndexInformer
// Unmanaged secrets for things like Ingress TLS
UnmanagedSecrets() cache.SharedIndexInformer
// Fake ServiceMonitor informer used when Prometheus is not installed
DummyOperatorServiceMonitor() cache.SharedIndexInformer
// The namespace where kubevirt is deployed in
Namespace() cache.SharedIndexInformer
// PrometheusRules created/managed by virt operator
OperatorPrometheusRule() cache.SharedIndexInformer
// Fake PrometheusRule informer used when Prometheus not installed
DummyOperatorPrometheusRule() cache.SharedIndexInformer
// PVC StorageClasses
StorageClass() cache.SharedIndexInformer
// Pod returns an informer for ALL Pods in the system
Pod() cache.SharedIndexInformer
K8SInformerFactory() informers.SharedInformerFactory
}
type kubeInformerFactory struct {
restClient *rest.RESTClient
clientSet kubecli.KubevirtClient
aggregatorClient aggregatorclient.Interface
lock sync.Mutex
defaultResync time.Duration
informers map[string]cache.SharedIndexInformer
startedInformers map[string]bool
kubevirtNamespace string
k8sInformers informers.SharedInformerFactory
}
func NewKubeInformerFactory(restClient *rest.RESTClient, clientSet kubecli.KubevirtClient, aggregatorClient aggregatorclient.Interface, kubevirtNamespace string) KubeInformerFactory {
return &kubeInformerFactory{
restClient: restClient,
clientSet: clientSet,
aggregatorClient: aggregatorClient,
// Resulting resync period will be between 12 and 24 hours, like the default for k8s
defaultResync: resyncPeriod(12 * time.Hour),
informers: make(map[string]cache.SharedIndexInformer),
startedInformers: make(map[string]bool),
kubevirtNamespace: kubevirtNamespace,
k8sInformers: informers.NewSharedInformerFactoryWithOptions(clientSet, 0),
}
}
// Start can be called from multiple controllers in different go routines safely.
// Only informers that have not started are triggered by this function.
// Multiple calls to this function are idempotent.
func (f *kubeInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
for name, informer := range f.informers {
if f.startedInformers[name] {
// skip informers that have already started.
log.Log.Infof("SKIPPING informer %s", name)
continue
}
log.Log.Infof("STARTING informer %s", name)
go informer.Run(stopCh)
f.startedInformers[name] = true
}
f.k8sInformers.Start(stopCh)
}
func (f *kubeInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) {
syncs := []cache.InformerSynced{}
f.lock.Lock()
for name, informer := range f.informers {
log.Log.Infof("Waiting for cache sync of informer %s", name)
syncs = append(syncs, informer.HasSynced)
}
f.lock.Unlock()
cache.WaitForCacheSync(stopCh, syncs...)
}
// internal function used to retrieve an already created informer
// or create a new informer if one does not already exist.
// Thread safe
func (f *kubeInformerFactory) getInformer(key string, newFunc newSharedInformer) cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informer, exists := f.informers[key]
if exists {
return informer
}
informer = newFunc()
f.informers[key] = informer
return informer
}
func (f *kubeInformerFactory) Namespace() cache.SharedIndexInformer {
return f.getInformer("namespaceInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.CoreV1().RESTClient(), "namespaces", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(
lw,
&k8sv1.Namespace{},
f.defaultResync,
cache.Indexers{
"namespace_name": func(obj interface{}) ([]string, error) {
return []string{obj.(*k8sv1.Namespace).GetName()}, nil
},
},
)
})
}
func GetVMIInformerIndexers() cache.Indexers {
return cache.Indexers{
cache.NamespaceIndex: cache.MetaNamespaceIndexFunc,
"node": func(obj interface{}) (strings []string, e error) {
return []string{obj.(*kubev1.VirtualMachineInstance).Status.NodeName}, nil
},
"dv": func(obj interface{}) ([]string, error) {
vmi, ok := obj.(*kubev1.VirtualMachineInstance)
if !ok {
return nil, unexpectedObjectError
}
var dvs []string
for _, vol := range vmi.Spec.Volumes {
if vol.DataVolume != nil {
dvs = append(dvs, fmt.Sprintf("%s/%s", vmi.Namespace, vol.DataVolume.Name))
}
}
return dvs, nil
},
"pvc": func(obj interface{}) ([]string, error) {
vmi, ok := obj.(*kubev1.VirtualMachineInstance)
if !ok {
return nil, unexpectedObjectError
}
var pvcs []string
for _, vol := range vmi.Spec.Volumes {
if vol.PersistentVolumeClaim != nil {
pvcs = append(pvcs, fmt.Sprintf("%s/%s", vmi.Namespace, vol.PersistentVolumeClaim.ClaimName))
}
}
return pvcs, nil
},
}
}
func (f *kubeInformerFactory) VMI() cache.SharedIndexInformer {
return f.getInformer("vmiInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.restClient, "virtualmachineinstances", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &kubev1.VirtualMachineInstance{}, f.defaultResync, GetVMIInformerIndexers())
})
}
func (f *kubeInformerFactory) VMISourceHost(hostName string) cache.SharedIndexInformer {
labelSelector, err := labels.Parse(fmt.Sprintf(kubev1.NodeNameLabel+" in (%s)", hostName))
if err != nil {
panic(err)
}
return f.getInformer("vmiInformer-sources", func() cache.SharedIndexInformer {
lw := NewListWatchFromClient(f.restClient, "virtualmachineinstances", k8sv1.NamespaceAll, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &kubev1.VirtualMachineInstance{}, f.defaultResync, cache.Indexers{
cache.NamespaceIndex: cache.MetaNamespaceIndexFunc,
"node": func(obj interface{}) (strings []string, e error) {
return []string{obj.(*kubev1.VirtualMachineInstance).Status.NodeName}, nil
},
})
})
}
func (f *kubeInformerFactory) VMITargetHost(hostName string) cache.SharedIndexInformer {
labelSelector, err := labels.Parse(fmt.Sprintf(kubev1.MigrationTargetNodeNameLabel+" in (%s)", hostName))
if err != nil {
panic(err)
}
return f.getInformer("vmiInformer-targets", func() cache.SharedIndexInformer {
lw := NewListWatchFromClient(f.restClient, "virtualmachineinstances", k8sv1.NamespaceAll, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &kubev1.VirtualMachineInstance{}, f.defaultResync, cache.Indexers{
cache.NamespaceIndex: cache.MetaNamespaceIndexFunc,
"node": func(obj interface{}) (strings []string, e error) {
return []string{obj.(*kubev1.VirtualMachineInstance).Status.NodeName}, nil
},
})
})
}
func (f *kubeInformerFactory) VMIReplicaSet() cache.SharedIndexInformer {
return f.getInformer("vmirsInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.restClient, "virtualmachineinstancereplicasets", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &kubev1.VirtualMachineInstanceReplicaSet{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) VMPool() cache.SharedIndexInformer {
return f.getInformer("vmpool", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().PoolV1alpha1().RESTClient(), "virtualmachinepools", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &poolv1.VirtualMachinePool{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) VirtualMachinePreset() cache.SharedIndexInformer {
return f.getInformer("vmiPresetInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.restClient, "virtualmachineinstancepresets", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &kubev1.VirtualMachineInstancePreset{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) VirtualMachineInstanceMigration() cache.SharedIndexInformer {
return f.getInformer("vmimInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.restClient, "virtualmachineinstancemigrations", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &kubev1.VirtualMachineInstanceMigration{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) KubeVirtPod() cache.SharedIndexInformer {
return f.getInformer("kubeVirtPodInformer", func() cache.SharedIndexInformer {
// Watch all pods with the kubevirt app label
labelSelector, err := labels.Parse(kubev1.AppLabel)
if err != nil {
panic(err)
}
lw := NewListWatchFromClient(f.clientSet.CoreV1().RESTClient(), "pods", k8sv1.NamespaceAll, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &k8sv1.Pod{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) KubeVirtNode() cache.SharedIndexInformer {
return f.getInformer("kubeVirtNodeInformer", func() cache.SharedIndexInformer {
lw := NewListWatchFromClient(f.clientSet.CoreV1().RESTClient(), "nodes", k8sv1.NamespaceAll, fields.Everything(), labels.Everything())
return cache.NewSharedIndexInformer(lw, &k8sv1.Node{}, f.defaultResync, cache.Indexers{})
})
}
func GetVirtualMachineInformerIndexers() cache.Indexers {
return cache.Indexers{
cache.NamespaceIndex: cache.MetaNamespaceIndexFunc,
"dv": func(obj interface{}) ([]string, error) {
vm, ok := obj.(*kubev1.VirtualMachine)
if !ok {
return nil, unexpectedObjectError
}
var dvs []string
for _, vol := range vm.Spec.Template.Spec.Volumes {
if vol.DataVolume != nil {
dvs = append(dvs, fmt.Sprintf("%s/%s", vm.Namespace, vol.DataVolume.Name))
}
}
return dvs, nil
},
"pvc": func(obj interface{}) ([]string, error) {
vm, ok := obj.(*kubev1.VirtualMachine)
if !ok {
return nil, unexpectedObjectError
}
var pvcs []string
for _, vol := range vm.Spec.Template.Spec.Volumes {
if vol.PersistentVolumeClaim != nil {
pvcs = append(pvcs, fmt.Sprintf("%s/%s", vm.Namespace, vol.PersistentVolumeClaim.ClaimName))
}
}
return pvcs, nil
},
}
}
func (f *kubeInformerFactory) VirtualMachine() cache.SharedIndexInformer {
return f.getInformer("vmInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.restClient, "virtualmachines", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &kubev1.VirtualMachine{}, f.defaultResync, GetVirtualMachineInformerIndexers())
})
}
func GetVirtualMachineExportInformerIndexers() cache.Indexers {
return cache.Indexers{
"pvc": func(obj interface{}) ([]string, error) {
export, ok := obj.(*exportv1.VirtualMachineExport)
if !ok {
return nil, unexpectedObjectError
}
if (export.Spec.Source.APIGroup == nil ||
*export.Spec.Source.APIGroup == "" || *export.Spec.Source.APIGroup == "v1") &&
export.Spec.Source.Kind == "PersistentVolumeClaim" {
return []string{fmt.Sprintf("%s/%s", export.Namespace, export.Spec.Source.Name)}, nil
}
return nil, nil
},
"vmsnapshot": func(obj interface{}) ([]string, error) {
export, ok := obj.(*exportv1.VirtualMachineExport)
if !ok {
return nil, unexpectedObjectError
}
if export.Spec.Source.APIGroup != nil &&
*export.Spec.Source.APIGroup == snapshotv1.SchemeGroupVersion.Group &&
export.Spec.Source.Kind == "VirtualMachineSnapshot" {
return []string{fmt.Sprintf("%s/%s", export.Namespace, export.Spec.Source.Name)}, nil
}
return nil, nil
},
"vm": func(obj interface{}) ([]string, error) {
export, ok := obj.(*exportv1.VirtualMachineExport)
if !ok {
return nil, unexpectedObjectError
}
if export.Spec.Source.APIGroup != nil &&
*export.Spec.Source.APIGroup == core.GroupName &&
export.Spec.Source.Kind == "VirtualMachine" {
return []string{fmt.Sprintf("%s/%s", export.Namespace, export.Spec.Source.Name)}, nil
}
return nil, nil
},
}
}
func (f *kubeInformerFactory) VirtualMachineExport() cache.SharedIndexInformer {
return f.getInformer("vmExportInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().ExportV1alpha1().RESTClient(), "virtualmachineexports", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &exportv1.VirtualMachineExport{}, f.defaultResync, GetVirtualMachineExportInformerIndexers())
})
}
func GetVirtualMachineSnapshotInformerIndexers() cache.Indexers {
return cache.Indexers{
"vm": func(obj interface{}) ([]string, error) {
vms, ok := obj.(*snapshotv1.VirtualMachineSnapshot)
if !ok {
return nil, unexpectedObjectError
}
if vms.Spec.Source.APIGroup != nil &&
*vms.Spec.Source.APIGroup == core.GroupName &&
vms.Spec.Source.Kind == "VirtualMachine" {
return []string{fmt.Sprintf("%s/%s", vms.Namespace, vms.Spec.Source.Name)}, nil
}
return nil, nil
},
}
}
func (f *kubeInformerFactory) VirtualMachineSnapshot() cache.SharedIndexInformer {
return f.getInformer("vmSnapshotInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().SnapshotV1alpha1().RESTClient(), "virtualmachinesnapshots", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &snapshotv1.VirtualMachineSnapshot{}, f.defaultResync, GetVirtualMachineSnapshotInformerIndexers())
})
}
func GetVirtualMachineSnapshotContentInformerIndexers() cache.Indexers {
return cache.Indexers{
"volumeSnapshot": func(obj interface{}) ([]string, error) {
vmsc, ok := obj.(*snapshotv1.VirtualMachineSnapshotContent)
if !ok {
return nil, unexpectedObjectError
}
var volumeSnapshots []string
for _, v := range vmsc.Spec.VolumeBackups {
if v.VolumeSnapshotName != nil {
k := fmt.Sprintf("%s/%s", vmsc.Namespace, *v.VolumeSnapshotName)
volumeSnapshots = append(volumeSnapshots, k)
}
}
return volumeSnapshots, nil
},
}
}
func (f *kubeInformerFactory) VirtualMachineSnapshotContent() cache.SharedIndexInformer {
return f.getInformer("vmSnapshotContentInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().SnapshotV1alpha1().RESTClient(), "virtualmachinesnapshotcontents", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &snapshotv1.VirtualMachineSnapshotContent{}, f.defaultResync, GetVirtualMachineSnapshotContentInformerIndexers())
})
}
func GetVirtualMachineRestoreInformerIndexers() cache.Indexers {
return cache.Indexers{
cache.NamespaceIndex: cache.MetaNamespaceIndexFunc,
"vm": func(obj interface{}) ([]string, error) {
vmr, ok := obj.(*snapshotv1.VirtualMachineRestore)
if !ok {
return nil, unexpectedObjectError
}
if vmr.Spec.Target.APIGroup != nil &&
*vmr.Spec.Target.APIGroup == core.GroupName &&
vmr.Spec.Target.Kind == "VirtualMachine" {
return []string{fmt.Sprintf("%s/%s", vmr.Namespace, vmr.Spec.Target.Name)}, nil
}
return nil, nil
},
}
}
func (f *kubeInformerFactory) VirtualMachineRestore() cache.SharedIndexInformer {
return f.getInformer("vmRestoreInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().SnapshotV1alpha1().RESTClient(), "virtualmachinerestores", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &snapshotv1.VirtualMachineRestore{}, f.defaultResync, GetVirtualMachineRestoreInformerIndexers())
})
}
func (f *kubeInformerFactory) MigrationPolicy() cache.SharedIndexInformer {
return f.getInformer("migrationPolicyInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().MigrationsV1alpha1().RESTClient(), migrations.ResourceMigrationPolicies, k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &migrationsv1.MigrationPolicy{}, f.defaultResync, cache.Indexers{})
})
}
func GetVirtualMachineCloneInformerIndexers() cache.Indexers {
return cache.Indexers{
"snapshotSource": func(obj interface{}) ([]string, error) {
vmClone, ok := obj.(*clonev1alpha1.VirtualMachineClone)
if !ok {
return nil, unexpectedObjectError
}
source := vmClone.Spec.Source
if source != nil && *source.APIGroup == snapshot.GroupName && source.Kind == "VirtualMachineSnapshot" {
snapshotSourceKey := fmt.Sprintf("%s/%s", vmClone.Namespace, source.Name)
return []string{snapshotSourceKey}, nil
}
return nil, nil
},
}
}
func (f *kubeInformerFactory) VirtualMachineClone() cache.SharedIndexInformer {
return f.getInformer("virtualMachineCloneInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().CloneV1alpha1().RESTClient(), clone.ResourceVMClonePlural, k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &clonev1alpha1.VirtualMachineClone{}, f.defaultResync, GetVirtualMachineCloneInformerIndexers())
})
}
func (f *kubeInformerFactory) VirtualMachineInstancetype() cache.SharedIndexInformer {
return f.getInformer("vmInstancetypeInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().InstancetypeV1alpha2().RESTClient(), instancetypeapi.PluralResourceName, k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &instancetypev1alpha2.VirtualMachineInstancetype{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) VirtualMachineClusterInstancetype() cache.SharedIndexInformer {
return f.getInformer("vmClusterInstancetypeInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().InstancetypeV1alpha2().RESTClient(), instancetypeapi.ClusterPluralResourceName, k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &instancetypev1alpha2.VirtualMachineClusterInstancetype{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) VirtualMachinePreference() cache.SharedIndexInformer {
return f.getInformer("vmPreferenceInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().InstancetypeV1alpha2().RESTClient(), instancetypeapi.PluralPreferenceResourceName, k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &instancetypev1alpha2.VirtualMachinePreference{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) VirtualMachineClusterPreference() cache.SharedIndexInformer {
return f.getInformer("vmClusterPreferenceInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.GeneratedKubeVirtClient().InstancetypeV1alpha2().RESTClient(), instancetypeapi.ClusterPluralPreferenceResourceName, k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &instancetypev1alpha2.VirtualMachineClusterPreference{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) DataVolume() cache.SharedIndexInformer {
return f.getInformer("dataVolumeInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.CdiClient().CdiV1beta1().RESTClient(), "datavolumes", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &cdiv1.DataVolume{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) DummyDataVolume() cache.SharedIndexInformer {
return f.getInformer("fakeDataVolumeInformer", func() cache.SharedIndexInformer {
informer, _ := testutils.NewFakeInformerFor(&cdiv1.DataVolume{})
return informer
})
}
func (f *kubeInformerFactory) DataSource() cache.SharedIndexInformer {
return f.getInformer("dataSourceInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.clientSet.CdiClient().CdiV1beta1().RESTClient(), "datasources", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &cdiv1.DataSource{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) DummyDataSource() cache.SharedIndexInformer {
return f.getInformer("fakeDataSourceInformer", func() cache.SharedIndexInformer {
informer, _ := testutils.NewFakeInformerFor(&cdiv1.DataSource{})
return informer
})
}
func (f *kubeInformerFactory) CDI() cache.SharedIndexInformer {
return f.getInformer("cdiInformer", func() cache.SharedIndexInformer {
restClient := f.clientSet.CdiClient().CdiV1beta1().RESTClient()
lw := cache.NewListWatchFromClient(restClient, "cdis", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &cdiv1.CDI{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) DummyCDI() cache.SharedIndexInformer {
return f.getInformer("fakeCdiInformer", func() cache.SharedIndexInformer {
informer, _ := testutils.NewFakeInformerFor(&cdiv1.CDI{})
return informer
})
}
func (f *kubeInformerFactory) CDIConfig() cache.SharedIndexInformer {
return f.getInformer("cdiConfigInformer", func() cache.SharedIndexInformer {
restClient := f.clientSet.CdiClient().CdiV1beta1().RESTClient()
lw := cache.NewListWatchFromClient(restClient, "cdiconfigs", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &cdiv1.CDIConfig{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) DummyCDIConfig() cache.SharedIndexInformer {
return f.getInformer("fakeCdiConfigInformer", func() cache.SharedIndexInformer {
informer, _ := testutils.NewFakeInformerFor(&cdiv1.CDIConfig{})
return informer
})
}
func (f *kubeInformerFactory) ApiAuthConfigMap() cache.SharedIndexInformer {
return f.getInformer("extensionsConfigMapInformer", func() cache.SharedIndexInformer {
restClient := f.clientSet.CoreV1().RESTClient()
fieldSelector := fields.OneTermEqualSelector("metadata.name", "extension-apiserver-authentication")
lw := cache.NewListWatchFromClient(restClient, "configmaps", metav1.NamespaceSystem, fieldSelector)
return cache.NewSharedIndexInformer(lw, &k8sv1.ConfigMap{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) KubeVirtCAConfigMap() cache.SharedIndexInformer {
return f.getInformer("extensionsKubeVirtCAConfigMapInformer", func() cache.SharedIndexInformer {
restClient := f.clientSet.CoreV1().RESTClient()
fieldSelector := fields.OneTermEqualSelector("metadata.name", "kubevirt-ca")
lw := cache.NewListWatchFromClient(restClient, "configmaps", f.kubevirtNamespace, fieldSelector)
return cache.NewSharedIndexInformer(lw, &k8sv1.ConfigMap{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) KubeVirtExportCAConfigMap() cache.SharedIndexInformer {
return f.getInformer("extensionsKubeVirtExportCAConfigMapInformer", func() cache.SharedIndexInformer {
restClient := f.clientSet.CoreV1().RESTClient()
fieldSelector := fields.OneTermEqualSelector("metadata.name", "kubevirt-export-ca")
lw := cache.NewListWatchFromClient(restClient, "configmaps", f.kubevirtNamespace, fieldSelector)
return cache.NewSharedIndexInformer(lw, &k8sv1.ConfigMap{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) ExportRouteConfigMap() cache.SharedIndexInformer {
return f.getInformer("extensionsExportRouteConfigMapInformer", func() cache.SharedIndexInformer {
restClient := f.clientSet.CoreV1().RESTClient()
fieldSelector := fields.OneTermEqualSelector("metadata.name", "kube-root-ca.crt")
lw := cache.NewListWatchFromClient(restClient, "configmaps", f.kubevirtNamespace, fieldSelector)
return cache.NewSharedIndexInformer(lw, &k8sv1.ConfigMap{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) ExportService() cache.SharedIndexInformer {
return f.getInformer("exportService", func() cache.SharedIndexInformer {
// Watch all service with the kubevirt app label
labelSelector, err := labels.Parse(fmt.Sprintf("%s=%s", kubev1.AppLabel, exportv1.App))
if err != nil {
panic(err)
}
lw := NewListWatchFromClient(f.clientSet.CoreV1().RESTClient(), "services", k8sv1.NamespaceAll, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &k8sv1.Service{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) PersistentVolumeClaim() cache.SharedIndexInformer {
return f.getInformer("persistentVolumeClaimInformer", func() cache.SharedIndexInformer {
restClient := f.clientSet.CoreV1().RESTClient()
lw := cache.NewListWatchFromClient(restClient, "persistentvolumeclaims", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &k8sv1.PersistentVolumeClaim{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func GetControllerRevisionInformerIndexers() cache.Indexers {
return cache.Indexers{
"vm": func(obj interface{}) ([]string, error) {
cr, ok := obj.(*appsv1.ControllerRevision)
if !ok {
return nil, unexpectedObjectError
}
for _, ref := range cr.OwnerReferences {
if ref.Kind == "VirtualMachine" {
return []string{string(ref.UID)}, nil
}
}
return nil, nil
},
"vmpool": func(obj interface{}) ([]string, error) {
cr, ok := obj.(*appsv1.ControllerRevision)
if !ok {
return nil, unexpectedObjectError
}
for _, ref := range cr.OwnerReferences {
if ref.Kind == "VirtualMachinePool" {
return []string{string(ref.UID)}, nil
}
}
return nil, nil
},
}
}
func (f *kubeInformerFactory) ControllerRevision() cache.SharedIndexInformer {
return f.getInformer("controllerRevisionInformer", func() cache.SharedIndexInformer {
restClient := f.clientSet.AppsV1().RESTClient()
lw := cache.NewListWatchFromClient(restClient, "controllerrevisions", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &appsv1.ControllerRevision{}, f.defaultResync, GetControllerRevisionInformerIndexers())
})
}
func (f *kubeInformerFactory) KubeVirt() cache.SharedIndexInformer {
return f.getInformer("kubeVirtInformer", func() cache.SharedIndexInformer {
lw := cache.NewListWatchFromClient(f.restClient, "kubevirts", k8sv1.NamespaceAll, fields.Everything())
return cache.NewSharedIndexInformer(lw, &kubev1.KubeVirt{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
// resyncPeriod computes the time interval a shared informer waits before resyncing with the api server
func resyncPeriod(minResyncPeriod time.Duration) time.Duration {
// #nosec no need for better randomness
factor := rand.Float64() + 1
return time.Duration(float64(minResyncPeriod.Nanoseconds()) * factor)
}
func (f *kubeInformerFactory) OperatorServiceAccount() cache.SharedIndexInformer {
return f.getInformer("OperatorServiceAccountInformer", func() cache.SharedIndexInformer {
labelSelector, err := labels.Parse(OperatorLabel)
if err != nil {
panic(err)
}
lw := NewListWatchFromClient(f.clientSet.CoreV1().RESTClient(), "serviceaccounts", k8sv1.NamespaceAll, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &k8sv1.ServiceAccount{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) OperatorConfigMap() cache.SharedIndexInformer {
// filter out install strategies
return f.getInformer("OperatorConfigMapInformer", func() cache.SharedIndexInformer {
labelSelector, err := labels.Parse(fmt.Sprintf("!%s, %s", kubev1.InstallStrategyLabel, OperatorLabel))
if err != nil {
panic(err)
}
restClient := f.clientSet.CoreV1().RESTClient()
lw := NewListWatchFromClient(restClient, "configmaps", f.kubevirtNamespace, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &k8sv1.ConfigMap{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) OperatorClusterRole() cache.SharedIndexInformer {
return f.getInformer("OperatorClusterRoleInformer", func() cache.SharedIndexInformer {
labelSelector, err := labels.Parse(OperatorLabel)
if err != nil {
panic(err)
}
lw := NewListWatchFromClient(f.clientSet.RbacV1().RESTClient(), "clusterroles", k8sv1.NamespaceAll, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &rbacv1.ClusterRole{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) OperatorClusterRoleBinding() cache.SharedIndexInformer {
return f.getInformer("OperatorClusterRoleBindingInformer", func() cache.SharedIndexInformer {
labelSelector, err := labels.Parse(OperatorLabel)
if err != nil {
panic(err)
}
lw := NewListWatchFromClient(f.clientSet.RbacV1().RESTClient(), "clusterrolebindings", k8sv1.NamespaceAll, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &rbacv1.ClusterRoleBinding{}, f.defaultResync, cache.Indexers{})
})
}
func (f *kubeInformerFactory) OperatorRole() cache.SharedIndexInformer {
return f.getInformer("OperatorRoleInformer", func() cache.SharedIndexInformer {
labelSelector, err := labels.Parse(OperatorLabel)
if err != nil {
panic(err)
}
lw := NewListWatchFromClient(f.clientSet.RbacV1().RESTClient(), "roles", k8sv1.NamespaceAll, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &rbacv1.Role{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) OperatorRoleBinding() cache.SharedIndexInformer {
return f.getInformer("OperatorRoleBindingInformer", func() cache.SharedIndexInformer {
labelSelector, err := labels.Parse(OperatorLabel)
if err != nil {
panic(err)
}
lw := NewListWatchFromClient(f.clientSet.RbacV1().RESTClient(), "rolebindings", k8sv1.NamespaceAll, fields.Everything(), labelSelector)
return cache.NewSharedIndexInformer(lw, &rbacv1.RoleBinding{}, f.defaultResync, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
})
}
func (f *kubeInformerFactory) OperatorCRD() cache.SharedIndexInformer {
return f.getInformer("OperatorCRDInformer", func() cache.SharedIndexInformer {
labelSelector, err := labels.Parse(OperatorLabel)
if err != nil {
panic(err)