@@ -76,21 +76,21 @@ func NewNetworkPolicyManager(config npmconfig.Config,
7676
7777 // create v2 NPM specific components.
7878 if npMgr .config .Toggles .EnableV2NPM {
79- npMgr .NpmNamespaceCacheV2 = & controllersv2.NpmNamespaceCache {NsMap : make (map [string ]* common.Namespace )}
80- npMgr .PodControllerV2 = controllersv2 .NewPodController (npMgr .PodInformer , dp , npMgr .NpmNamespaceCacheV2 )
81- npMgr .NamespaceControllerV2 = controllersv2 .NewNamespaceController (npMgr .NsInformer , dp , npMgr .NpmNamespaceCacheV2 )
79+ npMgr .K8SControllersV2 . NpmNamespaceCacheV2 = & controllersv2.NpmNamespaceCache {NsMap : make (map [string ]* common.Namespace )}
80+ npMgr .K8SControllersV2 . PodControllerV2 = controllersv2 .NewPodController (npMgr .Informers . PodInformer , dp , npMgr . K8SControllersV2 .NpmNamespaceCacheV2 )
81+ npMgr .K8SControllersV2 . NamespaceControllerV2 = controllersv2 .NewNamespaceController (npMgr .Informers . NsInformer , dp , npMgr . K8SControllersV2 .NpmNamespaceCacheV2 )
8282 // Question(jungukcho): Is config.Toggles.PlaceAzureChainFirst needed for v2?
83- npMgr .NetPolControllerV2 = controllersv2 .NewNetworkPolicyController (npMgr .NpInformer , dp )
83+ npMgr .K8SControllersV2 . NetPolControllerV2 = controllersv2 .NewNetworkPolicyController (npMgr . Informers .NpInformer , dp )
8484 return npMgr
8585 }
8686
8787 // create v1 NPM specific components.
8888 npMgr .ipsMgr = ipsm .NewIpsetManager (exec )
8989
90- npMgr .NpmNamespaceCacheV1 = & controllersv1.NpmNamespaceCache {NsMap : make (map [string ]* common.Namespace )}
91- npMgr .PodControllerV1 = controllersv1 .NewPodController (npMgr .PodInformer , npMgr .ipsMgr , npMgr .NpmNamespaceCacheV1 )
92- npMgr .NamespaceControllerV1 = controllersv1 .NewNameSpaceController (npMgr .NsInformer , npMgr .ipsMgr , npMgr .NpmNamespaceCacheV1 )
93- npMgr .NetPolControllerV1 = controllersv1 .NewNetworkPolicyController (npMgr .NpInformer , npMgr .ipsMgr , config .Toggles .PlaceAzureChainFirst )
90+ npMgr .K8SControllersV1 . NpmNamespaceCacheV1 = & controllersv1.NpmNamespaceCache {NsMap : make (map [string ]* common.Namespace )}
91+ npMgr .K8SControllersV1 . PodControllerV1 = controllersv1 .NewPodController (npMgr .Informers . PodInformer , npMgr .ipsMgr , npMgr . K8SControllersV1 .NpmNamespaceCacheV1 )
92+ npMgr .K8SControllersV1 . NamespaceControllerV1 = controllersv1 .NewNameSpaceController (npMgr .Informers . NsInformer , npMgr .ipsMgr , npMgr . K8SControllersV1 .NpmNamespaceCacheV1 )
93+ npMgr .K8SControllersV1 . NetPolControllerV1 = controllersv1 .NewNetworkPolicyController (npMgr . Informers .NpInformer , npMgr .ipsMgr , config .Toggles .PlaceAzureChainFirst )
9494 return npMgr
9595}
9696
@@ -104,13 +104,13 @@ func (npMgr *NetworkPolicyManager) MarshalJSON() ([]byte, error) {
104104 m := map [models.CacheKey ]json.RawMessage {}
105105
106106 if npMgr .config .Toggles .EnableV2NPM {
107- npmNamespaceCacheRaw , err := json .Marshal (npMgr .NpmNamespaceCacheV2 )
107+ npmNamespaceCacheRaw , err := json .Marshal (npMgr .K8SControllersV2 . NpmNamespaceCacheV2 )
108108 if err != nil {
109109 return nil , errors .Wrapf (err , "failed to marshal v2 ns cache" )
110110 }
111111 m [models .NsMap ] = npmNamespaceCacheRaw
112112
113- podControllerRaw , err := json .Marshal (npMgr .PodControllerV2 )
113+ podControllerRaw , err := json .Marshal (npMgr .K8SControllersV2 . PodControllerV2 )
114114 if err != nil {
115115 return nil , errors .Wrapf (err , "failed to marshal v2 pod controller" )
116116 }
@@ -123,13 +123,13 @@ func (npMgr *NetworkPolicyManager) MarshalJSON() ([]byte, error) {
123123 m [models .SetMap ] = setMapRaw
124124
125125 } else {
126- npmNamespaceCacheRaw , err := json .Marshal (npMgr .NpmNamespaceCacheV1 )
126+ npmNamespaceCacheRaw , err := json .Marshal (npMgr .K8SControllersV1 . NpmNamespaceCacheV1 )
127127 if err != nil {
128128 return nil , errors .Wrapf (err , "failed to marshal v1 ns cache" )
129129 }
130130 m [models .NsMap ] = npmNamespaceCacheRaw
131131
132- podControllerRaw , err := json .Marshal (npMgr .PodControllerV1 )
132+ podControllerRaw , err := json .Marshal (npMgr .K8SControllersV1 . PodControllerV1 )
133133 if err != nil {
134134 return nil , errors .Wrapf (err , "failed to marshal v1 pod controller" )
135135 }
@@ -149,7 +149,7 @@ func (npMgr *NetworkPolicyManager) MarshalJSON() ([]byte, error) {
149149
150150 }
151151
152- nodenameRaw , err := json .Marshal (npMgr .NodeName )
152+ nodenameRaw , err := json .Marshal (npMgr .AzureConfig . NodeName )
153153 if err != nil {
154154 return nil , errors .Wrapf (err , "failed to marshal node name" )
155155 }
@@ -165,47 +165,47 @@ func (npMgr *NetworkPolicyManager) MarshalJSON() ([]byte, error) {
165165
166166// GetAppVersion returns network policy manager app version
167167func (npMgr * NetworkPolicyManager ) GetAppVersion () string {
168- return npMgr .Version
168+ return npMgr .AzureConfig . Version
169169}
170170
171171// Start starts shared informers and waits for the shared informer cache to sync.
172172func (npMgr * NetworkPolicyManager ) Start (config npmconfig.Config , stopCh <- chan struct {}) error {
173173 if ! config .Toggles .EnableV2NPM {
174174 // Do initialization of data plane before starting syncup of each controller to avoid heavy call to api-server
175- if err := npMgr .NetPolControllerV1 .BootupDataplane (); err != nil {
175+ if err := npMgr .K8SControllersV1 . NetPolControllerV1 .BootupDataplane (); err != nil {
176176 return fmt .Errorf ("Failed to initialized data plane with err %w" , err )
177177 }
178178 }
179179
180180 // Starts all informers manufactured by npMgr's informerFactory.
181- npMgr .InformerFactory .Start (stopCh )
181+ npMgr .Informers . InformerFactory .Start (stopCh )
182182
183183 // Wait for the initial sync of local cache.
184- if ! cache .WaitForCacheSync (stopCh , npMgr .PodInformer .Informer ().HasSynced ) {
184+ if ! cache .WaitForCacheSync (stopCh , npMgr .Informers . PodInformer .Informer ().HasSynced ) {
185185 return fmt .Errorf ("Pod informer error: %w" , models .ErrInformerSyncFailure )
186186 }
187187
188- if ! cache .WaitForCacheSync (stopCh , npMgr .NsInformer .Informer ().HasSynced ) {
188+ if ! cache .WaitForCacheSync (stopCh , npMgr .Informers . NsInformer .Informer ().HasSynced ) {
189189 return fmt .Errorf ("Namespace informer error: %w" , models .ErrInformerSyncFailure )
190190 }
191191
192- if ! cache .WaitForCacheSync (stopCh , npMgr .NpInformer .Informer ().HasSynced ) {
192+ if ! cache .WaitForCacheSync (stopCh , npMgr .Informers . NpInformer .Informer ().HasSynced ) {
193193 return fmt .Errorf ("NetworkPolicy informer error: %w" , models .ErrInformerSyncFailure )
194194 }
195195
196196 // start v2 NPM controllers after synced
197197 if config .Toggles .EnableV2NPM {
198- go npMgr .PodControllerV2 .Run (stopCh )
199- go npMgr .NamespaceControllerV2 .Run (stopCh )
200- go npMgr .NetPolControllerV2 .Run (stopCh )
198+ go npMgr .K8SControllersV2 . PodControllerV2 .Run (stopCh )
199+ go npMgr .K8SControllersV2 . NamespaceControllerV2 .Run (stopCh )
200+ go npMgr .K8SControllersV2 . NetPolControllerV2 .Run (stopCh )
201201 return nil
202202 }
203203
204204 // start v1 NPM controllers after synced
205- go npMgr .PodControllerV1 .Run (stopCh )
206- go npMgr .NamespaceControllerV1 .Run (stopCh )
207- go npMgr .NetPolControllerV1 .Run (stopCh )
208- go npMgr .NetPolControllerV1 .RunPeriodicTasks (stopCh )
205+ go npMgr .K8SControllersV1 . PodControllerV1 .Run (stopCh )
206+ go npMgr .K8SControllersV1 . NamespaceControllerV1 .Run (stopCh )
207+ go npMgr .K8SControllersV1 . NetPolControllerV1 .Run (stopCh )
208+ go npMgr .K8SControllersV1 . NetPolControllerV1 .RunPeriodicTasks (stopCh )
209209
210210 return nil
211211}
0 commit comments