Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(instance): read server image during import #337

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions scaleway/resource_instance_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,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 @@ -350,9 +349,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