@@ -34,32 +34,48 @@ import (
3434type InformersMap struct {
3535 // we abstract over the details of structured/unstructured/metadata with the specificInformerMaps
3636 // TODO(directxman12): genericize this over different projections now that we have 3 different maps
37+ // TODO(vincepri): A different structure of the specific informer map is possible, although it requires
38+ // a large refactoring that takes into account that there may be different kind of informers, in this case
39+ // 3 of those: structured, unstructured, and metadata.
3740
3841 structured * specificInformersMap
3942 unstructured * specificInformersMap
4043 metadata * specificInformersMap
44+ }
45+
46+ // InformersMapOptions configures an InformerMap.
47+ type InformersMapOptions struct {
48+ Scheme * runtime.Scheme
49+ Mapper meta.RESTMapper
50+ ResyncPeriod time.Duration
51+ Namespace string
52+ ByGVK InformersMapOptionsByGVK
53+ }
4154
42- // Scheme maps runtime.Objects to GroupVersionKinds
43- Scheme * runtime.Scheme
55+ // InformersMapOptionsByGVK configured additional by group version kind (or object)
56+ // in an InformerMap.
57+ type InformersMapOptionsByGVK struct {
58+ Selectors SelectorsByGVK
59+ Transformers TransformFuncByObject // TODO(vincepri): Why is this by object and not GVK?
60+ DisableDeepCopy DisableDeepCopyByGVK
4461}
4562
4663// NewInformersMap creates a new InformersMap that can create informers for
4764// both structured and unstructured objects.
48- func NewInformersMap (config * rest.Config ,
49- scheme * runtime.Scheme ,
50- mapper meta.RESTMapper ,
51- resync time.Duration ,
52- namespace string ,
53- selectors SelectorsByGVK ,
54- disableDeepCopy DisableDeepCopyByGVK ,
55- transformers TransformFuncByObject ,
56- ) * InformersMap {
65+ func NewInformersMap (config * rest.Config , options * InformersMapOptions ) * InformersMap {
5766 return & InformersMap {
58- structured : newStructuredInformersMap (config , scheme , mapper , resync , namespace , selectors , disableDeepCopy , transformers ),
59- unstructured : newUnstructuredInformersMap (config , scheme , mapper , resync , namespace , selectors , disableDeepCopy , transformers ),
60- metadata : newMetadataInformersMap (config , scheme , mapper , resync , namespace , selectors , disableDeepCopy , transformers ),
61-
62- Scheme : scheme ,
67+ structured : newSpecificInformersMap (config , & specificInformerMapOptions {
68+ InformersMapOptions : options ,
69+ ListWatcherFunc : structuredListWatch ,
70+ }),
71+ unstructured : newSpecificInformersMap (config , & specificInformerMapOptions {
72+ InformersMapOptions : options ,
73+ ListWatcherFunc : unstructuredListWatch ,
74+ }),
75+ metadata : newSpecificInformersMap (config , & specificInformerMapOptions {
76+ InformersMapOptions : options ,
77+ ListWatcherFunc : metadataListWatch ,
78+ }),
6379 }
6480}
6581
@@ -106,21 +122,3 @@ func (m *InformersMap) Get(ctx context.Context, gvk schema.GroupVersionKind, obj
106122 return m .structured .Get (ctx , gvk , obj )
107123 }
108124}
109-
110- // newStructuredInformersMap creates a new InformersMap for structured objects.
111- func newStructuredInformersMap (config * rest.Config , scheme * runtime.Scheme , mapper meta.RESTMapper , resync time.Duration ,
112- namespace string , selectors SelectorsByGVK , disableDeepCopy DisableDeepCopyByGVK , transformers TransformFuncByObject ) * specificInformersMap {
113- return newSpecificInformersMap (config , scheme , mapper , resync , namespace , selectors , disableDeepCopy , transformers , createStructuredListWatch )
114- }
115-
116- // newUnstructuredInformersMap creates a new InformersMap for unstructured objects.
117- func newUnstructuredInformersMap (config * rest.Config , scheme * runtime.Scheme , mapper meta.RESTMapper , resync time.Duration ,
118- namespace string , selectors SelectorsByGVK , disableDeepCopy DisableDeepCopyByGVK , transformers TransformFuncByObject ) * specificInformersMap {
119- return newSpecificInformersMap (config , scheme , mapper , resync , namespace , selectors , disableDeepCopy , transformers , createUnstructuredListWatch )
120- }
121-
122- // newMetadataInformersMap creates a new InformersMap for metadata-only objects.
123- func newMetadataInformersMap (config * rest.Config , scheme * runtime.Scheme , mapper meta.RESTMapper , resync time.Duration ,
124- namespace string , selectors SelectorsByGVK , disableDeepCopy DisableDeepCopyByGVK , transformers TransformFuncByObject ) * specificInformersMap {
125- return newSpecificInformersMap (config , scheme , mapper , resync , namespace , selectors , disableDeepCopy , transformers , createMetadataListWatch )
126- }
0 commit comments