@@ -72,6 +72,9 @@ func NewRegistry() *Registry {
72
72
}
73
73
}
74
74
75
+ // MustNewFilteredDynamicSharedInformerFactory creates a new SharedInformerFactory
76
+ // and registers it under the given RegistryKey. It panics if there is already
77
+ // an entry with that key.
75
78
func (r * Registry ) MustNewFilteredDynamicSharedInformerFactory (key FactoryKey , client dynamic.Interface , defaultResync time.Duration , namespace string , tweakListOptions dynamicinformer.TweakListOptionsFunc ) dynamicinformer.DynamicSharedInformerFactory {
76
79
factory , err := r .NewFilteredDynamicSharedInformerFactory (key , client , defaultResync , namespace , tweakListOptions )
77
80
if err != nil {
@@ -80,6 +83,8 @@ func (r *Registry) MustNewFilteredDynamicSharedInformerFactory(key FactoryKey, c
80
83
return factory
81
84
}
82
85
86
+ // NewFilteredDynamicSharedInformerFactory creates a new SharedInformerFactory
87
+ // and registers it under the given RegistryKey
83
88
func (r * Registry ) NewFilteredDynamicSharedInformerFactory (key FactoryKey , client dynamic.Interface , defaultResync time.Duration , namespace string , tweakListOptions dynamicinformer.TweakListOptionsFunc ) (dynamicinformer.DynamicSharedInformerFactory , error ) {
84
89
r .Lock ()
85
90
defer r .Unlock ()
@@ -100,12 +105,23 @@ func IndexerFor[K runtime.Object](r *Registry, key RegistryKey) *Indexer[K] {
100
105
return NewIndexer [K ](r .InformerFor (key ).GetIndexer ())
101
106
}
102
107
108
+ // Add adds a factory to the registry under the given RegistryKey
103
109
func (r * Registry ) Add (key RegistryKey , factory dynamicinformer.DynamicSharedInformerFactory ) {
104
110
r .Lock ()
105
111
defer r .Unlock ()
106
112
r .factories [key ] = factory
107
113
}
108
114
115
+ // Remove removes a factory from the registry. Note that it does not stop any
116
+ // informers that were started via the factory; they should be stopped via
117
+ // context cancellation.
118
+ func (r * Registry ) Remove (key RegistryKey , factory dynamicinformer.DynamicSharedInformerFactory ) {
119
+ r .Lock ()
120
+ defer r .Unlock ()
121
+ delete (r .factories , key )
122
+ }
123
+
124
+ // InformerFactoryFor returns GVR-specific InformerFactory from the Registry.
109
125
func (r * Registry ) InformerFactoryFor (key RegistryKey ) informers.GenericInformer {
110
126
r .RLock ()
111
127
defer r .RUnlock ()
@@ -116,14 +132,17 @@ func (r *Registry) InformerFactoryFor(key RegistryKey) informers.GenericInformer
116
132
return factory .ForResource (key .GroupVersionResource )
117
133
}
118
134
135
+ // ListerFor returns the GVR-specific Lister from the Registry
119
136
func (r * Registry ) ListerFor (key RegistryKey ) cache.GenericLister {
120
137
return r .InformerFactoryFor (key ).Lister ()
121
138
}
122
139
140
+ // InformerFor returns the GVR-specific Informer from the Registry
123
141
func (r * Registry ) InformerFor (key RegistryKey ) cache.SharedIndexInformer {
124
142
return r .InformerFactoryFor (key ).Informer ()
125
143
}
126
144
145
+ // IndexerFor returns the GVR-specific Indexer from the Registry
127
146
func (r * Registry ) IndexerFor (key RegistryKey ) cache.Indexer {
128
147
return r .InformerFactoryFor (key ).Informer ().GetIndexer ()
129
148
}
0 commit comments