Skip to content

Commit

Permalink
fix(instance): read server image during import (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinBrosse authored and jerome-quere committed Nov 22, 2019
1 parent 40a9743 commit c74bf15
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scaleway/resource_instance_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,9 @@ func resourceScalewayInstanceServerRead(d *schema.ResourceData, m interface{}) e
state, err := serverStateFlatten(response.Server.State)
if err != nil {
return err
} else {
d.Set("state", state)
}

d.Set("state", state)
d.Set("zone", string(zone))
d.Set("name", response.Server.Name)
d.Set("type", response.Server.CommercialType)
Expand All @@ -341,9 +340,11 @@ func resourceScalewayInstanceServerRead(d *schema.ResourceData, m interface{}) e
d.Set("enable_ipv6", response.Server.EnableIPv6)
d.Set("disable_dynamic_ip", !response.Server.DynamicIPRequired)

// TODO: If image is a label, check that response.Server.Image.ID match the label.
// It could be useful if the user edit the image with another tool.
if response.Server.Image != nil && isUUID(d.Get("image").(string)) {
// Image could be empty in an import context.
image := d.Get("image").(string)
if response.Server.Image != nil && (image == "" || isUUID(image)) {
// TODO: If image is a label, check that response.Server.Image.ID match the label.
// It could be useful if the user edit the image with another tool.
d.Set("image", response.Server.Image.ID)
}

Expand Down

0 comments on commit c74bf15

Please sign in to comment.