File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
azure/services/managedclusters Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ func (s *ManagedClusterSpec) Parameters(existing interface{}) (params interface{
190190 Type : containerservice .ResourceIdentityTypeSystemAssigned ,
191191 },
192192 Location : & s .Location ,
193+ Tags : * to .StringMapPtr (s .Tags ),
193194 ManagedClusterProperties : & containerservice.ManagedClusterProperties {
194195 NodeResourceGroup : & s .NodeResourceGroup ,
195196 EnableRBAC : to .BoolPtr (true ),
@@ -217,10 +218,6 @@ func (s *ManagedClusterSpec) Parameters(existing interface{}) (params interface{
217218 },
218219 }
219220
220- if tags := * to .StringMapPtr (s .Tags ); len (tags ) != 0 {
221- managedCluster .Tags = tags
222- }
223-
224221 if s .PodCIDR != "" {
225222 managedCluster .NetworkProfile .PodCidr = & s .PodCIDR
226223 }
@@ -327,6 +324,12 @@ func (s *ManagedClusterSpec) Parameters(existing interface{}) (params interface{
327324 // AgentPool changes are managed through AMMP.
328325 managedCluster .AgentPoolProfiles = existingMC .AgentPoolProfiles
329326
327+ // Do not trigger an update because of nil/empty discrepancies between the two sets of tags.
328+ if len (existingMC .Tags ) == 0 && len (managedCluster .Tags ) == 0 {
329+ existingMC .Tags = nil
330+ managedCluster .Tags = nil
331+ }
332+
330333 diff := computeDiffOfNormalizedClusters (managedCluster , existingMC )
331334 if diff == "" {
332335 return nil , nil
Original file line number Diff line number Diff line change @@ -128,6 +128,19 @@ func TestParameters(t *testing.T) {
128128 g .Expect (result .(containerservice.ManagedCluster ).KubernetesVersion ).To (Equal (to .StringPtr ("v1.22.99" )))
129129 },
130130 },
131+ {
132+ name : "delete all tags" ,
133+ existing : getExistingCluster (),
134+ spec : & ManagedClusterSpec {
135+ Tags : nil ,
136+ },
137+ expect : func (g * WithT , result interface {}) {
138+ g .Expect (result ).To (BeAssignableToTypeOf (containerservice.ManagedCluster {}))
139+ tags := result .(containerservice.ManagedCluster ).Tags
140+ g .Expect (tags ).NotTo (BeNil ())
141+ g .Expect (tags ).To (BeEmpty ())
142+ },
143+ },
131144 }
132145 for _ , tc := range testcases {
133146 tc := tc
You can’t perform that action at this time.
0 commit comments