@@ -631,24 +631,26 @@ func resourceAciL3OutsideCreate(ctx context.Context, d *schema.ResourceData, m i
631631
632632 if defaultRouteLeakPolicy , ok := d .GetOk ("default_route_leak_policy" ); ok {
633633
634- newObj := defaultRouteLeakPolicy .(* schema.Set ).List ()[0 ].(map [string ]interface {})
634+ if len (defaultRouteLeakPolicy .(* schema.Set ).List ()) == 1 {
635+ newObj := defaultRouteLeakPolicy .(* schema.Set ).List ()[0 ].(map [string ]interface {})
635636
636- l3extDefaultRouteLeakPAttr := models.DefaultRouteLeakPolicyAttributes {}
637- l3extDefaultRouteLeakPAttr .Annotation = newObj ["annotation" ].(string )
638- l3extDefaultRouteLeakPAttr .Always = newObj ["always" ].(string )
639- l3extDefaultRouteLeakPAttr .Criteria = newObj ["criteria" ].(string )
637+ l3extDefaultRouteLeakPAttr := models.DefaultRouteLeakPolicyAttributes {}
638+ l3extDefaultRouteLeakPAttr .Annotation = newObj ["annotation" ].(string )
639+ l3extDefaultRouteLeakPAttr .Always = newObj ["always" ].(string )
640+ l3extDefaultRouteLeakPAttr .Criteria = newObj ["criteria" ].(string )
640641
641- scopeList := make ([]string , 0 , 1 )
642- for _ , val := range newObj ["scope" ].(* schema.Set ).List () {
643- scopeList = append (scopeList , val .(string ))
644- }
645- l3extDefaultRouteLeakPAttr .Scope = strings .Join (scopeList , "," )
642+ scopeList := make ([]string , 0 , 1 )
643+ for _ , val := range newObj ["scope" ].(* schema.Set ).List () {
644+ scopeList = append (scopeList , val .(string ))
645+ }
646+ l3extDefaultRouteLeakPAttr .Scope = strings .Join (scopeList , "," )
646647
647- l3extDefaultRouteLeakP := models .NewDefaultRouteLeakPolicy (fmt .Sprintf (models .RnL3extDefaultRouteLeakP ), l3extOut .DistinguishedName , l3extDefaultRouteLeakPAttr )
648+ l3extDefaultRouteLeakP := models .NewDefaultRouteLeakPolicy (fmt .Sprintf (models .RnL3extDefaultRouteLeakP ), l3extOut .DistinguishedName , l3extDefaultRouteLeakPAttr )
648649
649- err := aciClient .Save (l3extDefaultRouteLeakP )
650- if err != nil {
651- return diag .FromErr (err )
650+ err := aciClient .Save (l3extDefaultRouteLeakP )
651+ if err != nil {
652+ return diag .FromErr (err )
653+ }
652654 }
653655 }
654656
@@ -841,26 +843,28 @@ func resourceAciL3OutsideUpdate(ctx context.Context, d *schema.ResourceData, m i
841843
842844 if d .HasChange ("default_route_leak_policy" ) || d .HasChange ("annotation" ) {
843845 _ , newRel := d .GetChange ("default_route_leak_policy" )
844- newObj := newRel .(* schema.Set ).List ()[0 ].(map [string ]interface {})
846+ if len (newRel .(* schema.Set ).List ()) == 1 {
847+ newObj := newRel .(* schema.Set ).List ()[0 ].(map [string ]interface {})
845848
846- l3extDefaultRouteLeakPAttr := models.DefaultRouteLeakPolicyAttributes {}
847- l3extDefaultRouteLeakPAttr .Annotation = newObj ["annotation" ].(string )
848- l3extDefaultRouteLeakPAttr .Always = newObj ["always" ].(string )
849- l3extDefaultRouteLeakPAttr .Criteria = newObj ["criteria" ].(string )
849+ l3extDefaultRouteLeakPAttr := models.DefaultRouteLeakPolicyAttributes {}
850+ l3extDefaultRouteLeakPAttr .Annotation = newObj ["annotation" ].(string )
851+ l3extDefaultRouteLeakPAttr .Always = newObj ["always" ].(string )
852+ l3extDefaultRouteLeakPAttr .Criteria = newObj ["criteria" ].(string )
850853
851- scopeList := make ([]string , 0 , 1 )
852- for _ , val := range newObj ["scope" ].(* schema.Set ).List () {
853- scopeList = append (scopeList , val .(string ))
854- }
855- l3extDefaultRouteLeakPAttr .Scope = strings .Join (scopeList , "," )
854+ scopeList := make ([]string , 0 , 1 )
855+ for _ , val := range newObj ["scope" ].(* schema.Set ).List () {
856+ scopeList = append (scopeList , val .(string ))
857+ }
858+ l3extDefaultRouteLeakPAttr .Scope = strings .Join (scopeList , "," )
856859
857- l3extDefaultRouteLeakP := models .NewDefaultRouteLeakPolicy (fmt .Sprintf (models .RnL3extDefaultRouteLeakP ), l3extOut .DistinguishedName , l3extDefaultRouteLeakPAttr )
860+ l3extDefaultRouteLeakP := models .NewDefaultRouteLeakPolicy (fmt .Sprintf (models .RnL3extDefaultRouteLeakP ), l3extOut .DistinguishedName , l3extDefaultRouteLeakPAttr )
858861
859- l3extDefaultRouteLeakP .Status = "modified"
862+ l3extDefaultRouteLeakP .Status = "modified"
860863
861- err = aciClient .Save (l3extDefaultRouteLeakP )
862- if err != nil {
863- return diag .FromErr (err )
864+ err = aciClient .Save (l3extDefaultRouteLeakP )
865+ if err != nil {
866+ return diag .FromErr (err )
867+ }
864868 }
865869 }
866870
0 commit comments