@@ -143,10 +143,6 @@ func setResourceData(d *schema.ResourceData, eksCluster *eksmodel.VmwareTanzuMan
143143
144144 // see the explanation of this in the func doc of nodepoolPosMap
145145 npPosMap := nodepoolPosMap (tfNodepools )
146-
147- // get nodepool mapping of names with their details
148- npDataMap := nodepoolDetailsMap (tfNodepools )
149-
150146 nodepools := make ([]* eksmodel.VmwareTanzuManageV1alpha1EksclusterNodepoolDefinition , len (tfNodepools ))
151147
152148 for _ , np := range remoteNodepools {
@@ -157,11 +153,10 @@ func setResourceData(d *schema.ResourceData, eksCluster *eksmodel.VmwareTanzuMan
157153 },
158154 Spec : np .Spec ,
159155 }
156+ npDef .Spec .Tags = filterOutClusterTags (np .Spec .Tags , eksCluster .Spec .Config .Tags )
160157
161158 if pos , ok := npPosMap [np .FullName .Name ]; ok {
162159 nodepools [pos ] = npDef
163- // Add tf file nodepool tags as part of nodepool tags so that it will not show difference
164- nodepools [pos ].Spec .Tags = npDataMap [np .FullName .Name ].Spec .Tags
165160 } else {
166161 nodepools = append (nodepools , npDef )
167162 }
@@ -197,12 +192,17 @@ func nodepoolPosMap(nps []*eksmodel.VmwareTanzuManageV1alpha1EksclusterNodepoolD
197192 return ret
198193}
199194
200- // Returns mapping of nodepool names to their corresponding details in the array.
201- func nodepoolDetailsMap (nps []* eksmodel.VmwareTanzuManageV1alpha1EksclusterNodepoolDefinition ) map [string ]* eksmodel.VmwareTanzuManageV1alpha1EksclusterNodepoolDefinition {
202- ret := map [string ]* eksmodel.VmwareTanzuManageV1alpha1EksclusterNodepoolDefinition {}
203- for _ , np := range nps {
204- ret [np .Info .Name ] = np
195+ // filterOutClusterTags is used to remove cluster tags from nodepool while checking diff.
196+ func filterOutClusterTags (npTags , clusterTags map [string ]string ) map [string ]string {
197+ npWithoutClusterTags := make (map [string ]string )
198+
199+ for k , v := range npTags {
200+ if val , ok := clusterTags [k ]; ! ok {
201+ npWithoutClusterTags [k ] = v
202+ } else if v != val {
203+ npWithoutClusterTags [k ] = v
204+ }
205205 }
206206
207- return ret
207+ return npWithoutClusterTags
208208}
0 commit comments