@@ -121,8 +121,8 @@ func resourceBmInstance() *schema.Resource {
121
121
},
122
122
},
123
123
"interface" : & schema.Schema {
124
- Type : schema .TypeSet ,
125
- Set : interfaceUniqueID ,
124
+ Type : schema .TypeList ,
125
+ // Set: interfaceUniqueID,
126
126
Required : true ,
127
127
Elem : & schema.Resource {
128
128
Schema : map [string ]* schema.Schema {
@@ -276,7 +276,7 @@ func resourceBmInstanceCreate(ctx context.Context, d *schema.ResourceData, m int
276
276
return diag .FromErr (err )
277
277
}
278
278
279
- ifs := d .Get ("interface" ).(* schema. Set ). List ( )
279
+ ifs := d .Get ("interface" ).([] interface {} )
280
280
//sort interfaces by 'is_parent' at first and by 'order' key to attach it in right order
281
281
sort .Sort (instanceInterfaces (ifs ))
282
282
newInterface := make ([]bminstances.InterfaceOpts , len (ifs ))
@@ -404,7 +404,7 @@ func resourceBmInstanceRead(ctx context.Context, d *schema.ResourceData, m inter
404
404
return diag .FromErr (err )
405
405
}
406
406
407
- interfaces , err := extractInstanceInterfaceIntoMap (d .Get ("interface" ).(* schema. Set ). List ( ))
407
+ interfaces , err := extractInstanceInterfaceIntoMap (d .Get ("interface" ).([] interface {} ))
408
408
if err != nil {
409
409
return diag .FromErr (err )
410
410
}
@@ -491,7 +491,7 @@ func resourceBmInstanceRead(ctx context.Context, d *schema.ResourceData, m inter
491
491
}
492
492
}
493
493
}
494
- if err := d .Set ("interface" , schema . NewSet ( interfaceUniqueID , cleanInterfaces ) ); err != nil {
494
+ if err := d .Set ("interface" , cleanInterfaces ); err != nil {
495
495
return diag .FromErr (err )
496
496
}
497
497
@@ -633,16 +633,16 @@ func resourceBmInstanceUpdate(ctx context.Context, d *schema.ResourceData, m int
633
633
if d .HasChange ("interface" ) {
634
634
ifsOldRaw , ifsNewRaw := d .GetChange ("interface" )
635
635
636
- ifsOld := ifsOldRaw .(* schema. Set )
637
- ifsNew := ifsNewRaw .(* schema. Set )
636
+ ifsOld := ifsOldRaw .([] interface {} )
637
+ ifsNew := ifsNewRaw .([] interface {} )
638
638
639
- for _ , i := range ifsOld .List () {
640
- if ifsNew .Contains (i ) {
639
+ for _ , i := range ifsOld {
640
+ iface := i .(map [string ]interface {})
641
+ if isInterfaceContains (iface , ifsNew ) {
641
642
log .Println ("[DEBUG] Skipped, dont need detach" )
642
643
continue
643
644
}
644
645
645
- iface := i .(map [string ]interface {})
646
646
if iface ["is_parent" ].(bool ) {
647
647
return diag .Errorf ("could not detach trunk interface" )
648
648
}
@@ -675,14 +675,13 @@ func resourceBmInstanceUpdate(ctx context.Context, d *schema.ResourceData, m int
675
675
return diag .FromErr (err )
676
676
}
677
677
678
- sortedNewIfs := ifsNew . List ( )
679
- sort . Sort ( instanceInterfaces ( sortedNewIfs ))
680
- for _ , i := range sortedNewIfs {
681
- if ifsOld . Contains ( i ) {
678
+ sort . Sort ( instanceInterfaces ( ifsNew ) )
679
+ for _ , i := range ifsNew {
680
+ iface := i .( map [ string ] interface {})
681
+ if isInterfaceContains ( iface , ifsOld ) {
682
682
log .Println ("[DEBUG] Skipped, dont need attach" )
683
683
continue
684
684
}
685
- iface := i .(map [string ]interface {})
686
685
if isInterfaceAttached (currentIfs , iface ) {
687
686
continue
688
687
}
0 commit comments