Skip to content

Commit

Permalink
Update details if changed for an instance (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishesh92 authored Mar 6, 2024
1 parent 976e564 commit 5be794b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cloudstack/resource_cloudstack_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,14 +677,26 @@ func resourceCloudStackInstanceUpdate(d *schema.ResourceData, meta interface{})
}
}

// Check is the tags have changed and if so, update the tags
// Check if the tags have changed and if so, update the tags
if d.HasChange("tags") {
if err := updateTags(cs, d, "UserVm"); err != nil {
return fmt.Errorf("Error updating tags on instance %s: %s", name, err)
}
d.SetPartial("tags")
}

// Check if the details have changed and if so, update the details
if d.HasChange("details") {
p := cs.VirtualMachine.NewUpdateVirtualMachineParams(d.Id())
vmDetails := make(map[string]string)
if details := d.Get("details"); details != nil {
for k, v := range details.(map[string]interface{}) {
vmDetails[k] = v.(string)
}
}
p.SetDetails(vmDetails)
}

d.Partial(false)

return resourceCloudStackInstanceRead(d, meta)
Expand Down

0 comments on commit 5be794b

Please sign in to comment.