Skip to content

Commit

Permalink
respect vpc order definition order
Browse files Browse the repository at this point in the history
  • Loading branch information
quantimnot committed Feb 3, 2025
1 parent 605d1ef commit e520d44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions vultr/resource_vultr_bare_metal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func resourceVultrBareMetalServer() *schema.Resource {
ForceNew: true,
},
"vpc2_ids": {
Type: schema.TypeSet,
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand Down Expand Up @@ -264,7 +264,7 @@ func resourceVultrBareMetalServerCreate(ctx context.Context, d *schema.ResourceD
}

if vpcIDs, vpcOK := d.GetOk("vpc2_ids"); vpcOK {
for _, v := range vpcIDs.(*schema.Set).List() {
for _, v := range vpcIDs.([]interface{}) {
req.AttachVPC2 = append(req.AttachVPC2, v.(string))
}
}
Expand Down Expand Up @@ -411,12 +411,12 @@ func resourceVultrBareMetalServerUpdate(ctx context.Context, d *schema.ResourceD
oldVPC, newVPC := d.GetChange("vpc2_ids")

var oldIDs []string
for _, v := range oldVPC.(*schema.Set).List() {
for _, v := range oldVPC.([]interface{}) {
oldIDs = append(oldIDs, v.(string))
}

var newIDs []string
for _, v := range newVPC.(*schema.Set).List() {
for _, v := range newVPC.([]interface{}) {
newIDs = append(newIDs, v.(string))
}

Expand Down Expand Up @@ -449,7 +449,7 @@ func resourceVultrBareMetalServerDelete(ctx context.Context, d *schema.ResourceD

if vpcIDs, vpcOK := d.GetOk("vpc2_ids"); vpcOK {
detach := &govultr.BareMetalUpdate{}
for _, v := range vpcIDs.(*schema.Set).List() {
for _, v := range vpcIDs.([]interface{}) {
detach.DetachVPC2 = append(detach.DetachVPC2, v.(string))
}

Expand Down
20 changes: 10 additions & 10 deletions vultr/resource_vultr_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ func resourceVultrInstance() *schema.Resource {
Will not do anything unless enable_ipv6 is also true.`,
},
"vpc_ids": {
Type: schema.TypeSet,
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"vpc2_ids": {
Type: schema.TypeSet,
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand Down Expand Up @@ -369,13 +369,13 @@ func resourceVultrInstanceCreate(ctx context.Context, d *schema.ResourceData, me
}

if vpcIDs, vpcOK := d.GetOk("vpc_ids"); vpcOK {
for _, v := range vpcIDs.(*schema.Set).List() {
for _, v := range vpcIDs.([]interface{}) {
req.AttachVPC = append(req.AttachVPC, v.(string))
}
}

if vpcIDs, vpcOK := d.GetOk("vpc2_ids"); vpcOK {
for _, v := range vpcIDs.(*schema.Set).List() {
for _, v := range vpcIDs.([]interface{}) {
req.AttachVPC2 = append(req.AttachVPC2, v.(string))
}
}
Expand Down Expand Up @@ -620,12 +620,12 @@ func resourceVultrInstanceUpdate(ctx context.Context, d *schema.ResourceData, me
oldVPC, newVPC := d.GetChange("vpc_ids")

var oldIDs []string
for _, v := range oldVPC.(*schema.Set).List() {
for _, v := range oldVPC.([]interface{}) {
oldIDs = append(oldIDs, v.(string))
}

var newIDs []string
for _, v := range newVPC.(*schema.Set).List() {
for _, v := range newVPC.([]interface{}) {
newIDs = append(newIDs, v.(string))
}

Expand All @@ -638,12 +638,12 @@ func resourceVultrInstanceUpdate(ctx context.Context, d *schema.ResourceData, me
oldVPC, newVPC := d.GetChange("vpc2_ids")

var oldIDs []string
for _, v := range oldVPC.(*schema.Set).List() {
for _, v := range oldVPC.([]interface{}) {
oldIDs = append(oldIDs, v.(string))
}

var newIDs []string
for _, v := range newVPC.(*schema.Set).List() {
for _, v := range newVPC.([]interface{}) {
newIDs = append(newIDs, v.(string))
}

Expand Down Expand Up @@ -713,7 +713,7 @@ func resourceVultrInstanceDelete(ctx context.Context, d *schema.ResourceData, me

if vpcIDs, vpcOK := d.GetOk("vpc_ids"); vpcOK {
detach := &govultr.InstanceUpdateReq{}
for _, v := range vpcIDs.(*schema.Set).List() {
for _, v := range vpcIDs.([]interface{}) {
detach.DetachVPC = append(detach.DetachVPC, v.(string))
}

Expand All @@ -724,7 +724,7 @@ func resourceVultrInstanceDelete(ctx context.Context, d *schema.ResourceData, me

if vpcIDs, vpcOK := d.GetOk("vpc2_ids"); vpcOK {
detach := &govultr.InstanceUpdateReq{}
for _, v := range vpcIDs.(*schema.Set).List() {
for _, v := range vpcIDs.([]interface{}) {
detach.DetachVPC2 = append(detach.DetachVPC2, v.(string))
}

Expand Down

0 comments on commit e520d44

Please # to comment.