@@ -47,17 +47,18 @@ type InformerCollectionOption func(*InformerCollection)
47
47
// NewInformerCollection creates a new InformerCollection
48
48
func NewInformerCollection (meshName string , stop <- chan struct {}, opts ... InformerCollectionOption ) (* InformerCollection , error ) {
49
49
ic := & InformerCollection {
50
- meshName : meshName ,
51
- informers : map [InformerKey ]* informer {},
50
+ meshName : meshName ,
51
+ informers : map [InformerKey ]* informer {},
52
+ selectedInformers : map [InformerKey ]struct {}{},
52
53
}
53
54
55
+ // Execute all of the given options (e.g. set clients, set custom stores, etc.)
54
56
for _ , opt := range opts {
55
57
if opt != nil {
56
58
opt (ic )
57
59
}
58
60
}
59
61
60
- // Initialize informers
61
62
informerInitHandlerMap := map [InformerKey ]informerInit {
62
63
// Kubernetes
63
64
InformerKeyNamespace : ic .initNamespaceMonitor ,
@@ -84,7 +85,7 @@ func NewInformerCollection(meshName string, stop <-chan struct{}, opts ...Inform
84
85
}
85
86
86
87
if len (ic .selectedInformers ) == 0 {
87
- // Initialize all informers
88
+ // Select all informers
88
89
ic .selectedInformers = map [InformerKey ]struct {}{
89
90
InformerKeyNamespace : {},
90
91
InformerKeyService : {},
@@ -191,7 +192,7 @@ func (ic *InformerCollection) run(stop <-chan struct{}) error {
191
192
continue
192
193
}
193
194
194
- go informer .Run (make ( chan struct {}) )
195
+ go informer .Run (stop )
195
196
names = append (names , string (name ))
196
197
log .Info ().Msgf ("Waiting for %s informer cache sync..." , name )
197
198
hasSynced = append (hasSynced , informer .HasSynced )
0 commit comments