@@ -186,6 +186,67 @@ func TestParameters(t *testing.T) {
186186 g .Expect (result ).To (BeNil ())
187187 },
188188 },
189+ {
190+ name : "update authorized IP ranges with empty struct if spec does not have authorized IP ranges but existing cluster has authorized IP ranges" ,
191+ existing : getExistingClusterWithAuthorizedIPRanges (),
192+ spec : & ManagedClusterSpec {
193+ Name : "test-managedcluster" ,
194+ ResourceGroup : "test-rg" ,
195+ Location : "test-location" ,
196+ Tags : map [string ]string {
197+ "test-tag" : "test-value" ,
198+ },
199+ Version : "v1.22.0" ,
200+ LoadBalancerSKU : "Standard" ,
201+ },
202+ expect : func (g * WithT , result interface {}) {
203+ g .Expect (result ).To (BeAssignableToTypeOf (containerservice.ManagedCluster {}))
204+ g .Expect (result .(containerservice.ManagedCluster ).APIServerAccessProfile ).To (Not (BeNil ()))
205+ g .Expect (result .(containerservice.ManagedCluster ).APIServerAccessProfile .AuthorizedIPRanges ).To (Equal (& []string {}))
206+ },
207+ },
208+ {
209+ name : "update authorized IP ranges with authorized IPs spec has authorized IP ranges but existing cluster does not have authorized IP ranges" ,
210+ existing : getExistingCluster (),
211+ spec : & ManagedClusterSpec {
212+ Name : "test-managedcluster" ,
213+ ResourceGroup : "test-rg" ,
214+ Location : "test-location" ,
215+ Tags : map [string ]string {
216+ "test-tag" : "test-value" ,
217+ },
218+ Version : "v1.22.0" ,
219+ LoadBalancerSKU : "Standard" ,
220+ APIServerAccessProfile : & APIServerAccessProfile {
221+ AuthorizedIPRanges : []string {"192.168.0.1/32, 192.168.0.2/32, 192.168.0.3/32" },
222+ },
223+ },
224+ expect : func (g * WithT , result interface {}) {
225+ g .Expect (result ).To (BeAssignableToTypeOf (containerservice.ManagedCluster {}))
226+ g .Expect (result .(containerservice.ManagedCluster ).APIServerAccessProfile ).To (Not (BeNil ()))
227+ g .Expect (result .(containerservice.ManagedCluster ).APIServerAccessProfile .AuthorizedIPRanges ).To (Equal (& []string {"192.168.0.1/32, 192.168.0.2/32, 192.168.0.3/32" }))
228+ },
229+ },
230+ {
231+ name : "no update needed when authorized IP ranges when both clusters have the same authorized IP ranges" ,
232+ existing : getExistingClusterWithAuthorizedIPRanges (),
233+ spec : & ManagedClusterSpec {
234+ Name : "test-managedcluster" ,
235+ ResourceGroup : "test-rg" ,
236+ Location : "test-location" ,
237+ Tags : map [string ]string {
238+ "test-tag" : "test-value" ,
239+ },
240+ Version : "v1.22.0" ,
241+ LoadBalancerSKU : "Standard" ,
242+ APIServerAccessProfile : & APIServerAccessProfile {
243+ AuthorizedIPRanges : []string {"192.168.0.1/32, 192.168.0.2/32, 192.168.0.3/32" },
244+ },
245+ },
246+ expect : func (g * WithT , result interface {}) {
247+ g .Expect (result ).To (BeNil ())
248+ },
249+ },
189250 }
190251 for _ , tc := range testcases {
191252 tc := tc
@@ -336,3 +397,11 @@ func getSampleManagedCluster() containerservice.ManagedCluster {
336397 })),
337398 }
338399}
400+
401+ func getExistingClusterWithAuthorizedIPRanges () containerservice.ManagedCluster {
402+ mc := getExistingCluster ()
403+ mc .APIServerAccessProfile = & containerservice.ManagedClusterAPIServerAccessProfile {
404+ AuthorizedIPRanges : & []string {"192.168.0.1/32, 192.168.0.2/32, 192.168.0.3/32" },
405+ }
406+ return mc
407+ }
0 commit comments