Skip to content

Commit

Permalink
vms: update only tags when posible
Browse files Browse the repository at this point in the history
fix #86

Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo authored and outscale-toa committed Jul 8, 2022
1 parent bffc3a4 commit 4a313cf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions outscale/resource_outscale_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ func resourceOAPIVMUpdate(d *schema.ResourceData, meta interface{}) error {
id := d.Get("vm_id").(string)

nothingToDo := true
onlyTags := d.HasChange("tags")
o, n := d.GetChange("")
os := o.(map[string]interface{})
ns := n.(map[string]interface{})
Expand All @@ -687,12 +688,18 @@ func resourceOAPIVMUpdate(d *schema.ResourceData, meta interface{}) error {
if d.HasChange(k) && k != "get_admin_password" {
nothingToDo = false
}
if d.HasChange(k) && k != "tags" {
onlyTags = false
}
}

for k := range ns {
if d.HasChange(k) && k != "get_admin_password" {
nothingToDo = false
}
if d.HasChange(k) && k != "tags" {
onlyTags = false
}
}

if nothingToDo == true {
Expand Down Expand Up @@ -849,6 +856,10 @@ func resourceOAPIVMUpdate(d *schema.ResourceData, meta interface{}) error {

d.Partial(false)

if onlyTags {
goto out
}

if d.HasChange("state") && !d.IsNewResource() {
upState := d.Get("state").(string)
if upState != "stopped" && upState != "running" {
Expand All @@ -869,6 +880,7 @@ func resourceOAPIVMUpdate(d *schema.ResourceData, meta interface{}) error {
}
}

out:
return resourceOAPIVMRead(d, meta)
}

Expand Down

0 comments on commit 4a313cf

Please sign in to comment.