@@ -262,4 +262,35 @@ func TestParameters(t *testing.T) {
262262 g .Expect (actual .Spec .DnsPrefix ).To (Equal (ptr .To ("managed by CAPZ" )))
263263 g .Expect (actual .Spec .EnablePodSecurityPolicy ).To (Equal (ptr .To (true )))
264264 })
265+ t .Run ("updating existing managed cluster to a non nil DNS Service IP" , func (t * testing.T ) {
266+ g := NewGomegaWithT (t )
267+
268+ spec := & ManagedClusterSpec {
269+ DNSPrefix : ptr .To ("managed by CAPZ" ),
270+ Tags : map [string ]string {"additional" : "tags" },
271+ ServiceCIDR : "123.200.198.0/10" ,
272+ DNSServiceIP : ptr .To ("123.200.198.99" ),
273+ }
274+ existing := & asocontainerservicev1.ManagedCluster {
275+ Spec : asocontainerservicev1.ManagedCluster_Spec {
276+ DnsPrefix : ptr .To ("set by the user" ),
277+ EnablePodSecurityPolicy : ptr .To (true ), // set by the user
278+
279+ },
280+ Status : asocontainerservicev1.ManagedCluster_STATUS {
281+ AgentPoolProfiles : []asocontainerservicev1.ManagedClusterAgentPoolProfile_STATUS {},
282+ Tags : map [string ]string {},
283+ },
284+ }
285+
286+ actual , err := spec .Parameters (context .Background (), existing )
287+
288+ g .Expect (err ).NotTo (HaveOccurred ())
289+ g .Expect (actual .Spec .AgentPoolProfiles ).To (BeNil ())
290+ g .Expect (actual .Spec .Tags ).To (BeNil ())
291+ g .Expect (actual .Spec .DnsPrefix ).To (Equal (ptr .To ("managed by CAPZ" )))
292+ g .Expect (actual .Spec .EnablePodSecurityPolicy ).To (Equal (ptr .To (true )))
293+ g .Expect (actual .Spec .NetworkProfile .DnsServiceIP ).To (Equal (ptr .To ("123.200.198.99" )))
294+ g .Expect (actual .Spec .NetworkProfile .ServiceCidr ).To (Equal (ptr .To ("123.200.198.0/10" )))
295+ })
265296}
0 commit comments