@@ -34,32 +34,48 @@ import (
34
34
type InformersMap struct {
35
35
// we abstract over the details of structured/unstructured/metadata with the specificInformerMaps
36
36
// 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.
37
40
38
41
structured * specificInformersMap
39
42
unstructured * specificInformersMap
40
43
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
+ }
41
54
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
44
61
}
45
62
46
63
// NewInformersMap creates a new InformersMap that can create informers for
47
64
// 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 {
57
66
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
+ }),
63
79
}
64
80
}
65
81
@@ -106,21 +122,3 @@ func (m *InformersMap) Get(ctx context.Context, gvk schema.GroupVersionKind, obj
106
122
return m .structured .Get (ctx , gvk , obj )
107
123
}
108
124
}
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