@@ -154,19 +154,19 @@ var _ = Describe("webhook unit test", func() {
154154 "rules" : map [string ]interface {}{
155155 "policies" : map [string ]interface {}{
156156 "acl-internal" : map [string ]interface {}{
157- "permissions" : []map [string ]interface {}{
157+ "permissions" : buildInterfaceSlice ( []map [string ]interface {}{
158158 {
159159 "any" : true ,
160160 },
161- },
162- "principals" : []map [string ]interface {}{
161+ }) ,
162+ "principals" : buildInterfaceSlice ( []map [string ]interface {}{
163163 {
164164 "source_ip" : map [string ]interface {}{
165165 "address_prefix" : "0.0.0.0" ,
166- "prefix_len" : 0 ,
166+ "prefix_len" : float64 ( 0 ) ,
167167 },
168168 },
169- },
169+ }) ,
170170 },
171171 },
172172 "action" : "DENY" ,
@@ -218,46 +218,45 @@ var _ = Describe("webhook unit test", func() {
218218 "rules" : map [string ]interface {}{
219219 "policies" : map [string ]interface {}{
220220 "acl-internal" : map [string ]interface {}{
221- "permissions" : []map [string ]interface {}{
221+ "permissions" : buildInterfaceSlice ( []map [string ]interface {}{
222222 {
223223 "any" : true ,
224224 },
225- },
226- "principals" : []map [string ]interface {} {
225+ }) ,
226+ "principals" : buildInterfaceSlice ( []map [string ]any {
227227 {
228228 "source_ip" : map [string ]interface {}{
229229 "address_prefix" : "0.0.0.0" ,
230- "prefix_len" : 0 ,
230+ "prefix_len" : float64 ( 0 ) ,
231231 },
232232 },
233233 {
234234 "remote_ip" : map [string ]interface {}{
235235 "address_prefix" : "100.250.0.0" ,
236- "prefix_len" : 16 ,
236+ "prefix_len" : float64 ( 16 ) ,
237237 },
238238 },
239239 {
240240 "remote_ip" : map [string ]interface {}{
241241 "address_prefix" : "10.96.0.0" ,
242- "prefix_len" : 11 ,
242+ "prefix_len" : float64 ( 11 ) ,
243243 },
244244 },
245245 {
246246 "remote_ip" : map [string ]interface {}{
247247 "address_prefix" : "10.250.0.0" ,
248- "prefix_len" : 16 ,
248+ "prefix_len" : float64 ( 16 ) ,
249249 },
250250 },
251251 {
252252 "remote_ip" : map [string ]interface {}{
253253 "address_prefix" : "100.96.0.0" ,
254- "prefix_len" : 11 ,
254+ "prefix_len" : float64 ( 11 ) ,
255255 },
256256 },
257- },
257+ }) ,
258258 },
259259 },
260- "action" : "ALLOW" ,
261260 },
262261 "@type" : "type.googleapis.com/envoy.extensions.filters.network.rbac.v3.RBAC" ,
263262 },
@@ -332,52 +331,51 @@ var _ = Describe("webhook unit test", func() {
332331 "rules" : map [string ]interface {}{
333332 "policies" : map [string ]interface {}{
334333 "acl-internal" : map [string ]interface {}{
335- "permissions" : []map [string ]interface {}{
334+ "permissions" : buildInterfaceSlice ( []map [string ]interface {}{
336335 {
337336 "any" : true ,
338337 },
339- },
340- "principals" : []map [string ]interface {} {
338+ }) ,
339+ "principals" : buildInterfaceSlice ( []map [string ]any {
341340 {
342341 "source_ip" : map [string ]interface {}{
343342 "address_prefix" : "0.0.0.0" ,
344- "prefix_len" : 0 ,
343+ "prefix_len" : float64 ( 0 ) ,
345344 },
346345 },
347346 {
348347 "remote_ip" : map [string ]interface {}{
349348 "address_prefix" : "100.250.0.0" ,
350- "prefix_len" : 16 ,
349+ "prefix_len" : float64 ( 16 ) ,
351350 },
352351 },
353352 {
354353 "remote_ip" : map [string ]interface {}{
355354 "address_prefix" : "10.96.0.0" ,
356- "prefix_len" : 11 ,
355+ "prefix_len" : float64 ( 11 ) ,
357356 },
358357 },
359358 {
360359 "remote_ip" : map [string ]interface {}{
361360 "address_prefix" : "10.250.0.0" ,
362- "prefix_len" : 16 ,
361+ "prefix_len" : float64 ( 16 ) ,
363362 },
364363 },
365364 {
366365 "remote_ip" : map [string ]interface {}{
367366 "address_prefix" : "100.96.0.0" ,
368- "prefix_len" : 11 ,
367+ "prefix_len" : float64 ( 11 ) ,
369368 },
370369 },
371370 {
372371 "remote_ip" : map [string ]interface {}{
373372 "address_prefix" : "10.9.8.7" ,
374- "prefix_len" : 32 ,
373+ "prefix_len" : float64 ( 32 ) ,
375374 },
376375 },
377- },
376+ }) ,
378377 },
379378 },
380- "action" : "ALLOW" ,
381379 },
382380 "@type" : "type.googleapis.com/envoy.extensions.filters.network.rbac.v3.RBAC" ,
383381 },
@@ -439,34 +437,34 @@ var _ = Describe("webhook unit test", func() {
439437 "rules" : map [string ]interface {}{
440438 "policies" : map [string ]interface {}{
441439 "acl-internal" : map [string ]interface {}{
442- "permissions" : []map [string ]interface {}{
440+ "permissions" : buildInterfaceSlice ( []map [string ]interface {}{
443441 {
444442 "any" : true ,
445443 },
446- },
447- "principals" : []map [string ]interface {} {
444+ }) ,
445+ "principals" : buildInterfaceSlice ( []map [string ]any {
448446 {
449447 "source_ip" : map [string ]interface {}{
450448 "address_prefix" : "0.0.0.0" ,
451- "prefix_len" : 0 ,
449+ "prefix_len" : float64 ( 0 ) ,
452450 },
453451 },
454452 {
453+
455454 "remote_ip" : map [string ]interface {}{
456455 "address_prefix" : "100.250.0.0" ,
457- "prefix_len" : 16 ,
456+ "prefix_len" : float64 ( 16 ) ,
458457 },
459458 },
460459 {
461460 "remote_ip" : map [string ]interface {}{
462461 "address_prefix" : "10.96.0.0" ,
463- "prefix_len" : 11 ,
462+ "prefix_len" : float64 ( 11 ) ,
464463 },
465464 },
466- },
465+ }) ,
467466 },
468467 },
469- "action" : "ALLOW" ,
470468 },
471469 "@type" : "type.googleapis.com/envoy.extensions.filters.network.rbac.v3.RBAC" ,
472470 },
@@ -573,3 +571,11 @@ func getEnvoyFilterFromFile(technicalID string) (filter *istionetworkingClientGo
573571
574572 return filter
575573}
574+
575+ // buildInterfaceSlice can be used to create a slice of interface which is not possible when using literals.
576+ func buildInterfaceSlice (maps []map [string ]any ) (ret []any ) {
577+ for _ , m := range maps {
578+ ret = append (ret , m )
579+ }
580+ return
581+ }
0 commit comments