From 5b0894b5cdd146401f572c53dbb96370843c47a5 Mon Sep 17 00:00:00 2001 From: Joseph Anthony Pasquale Holsten Date: Mon, 1 Dec 2014 11:36:05 -0800 Subject: [PATCH] simplify digitalocean_droplet.image loading If a droplet's image slug is empty and its image id is empty, then the image attribute should be empty, so we may assign from either. So it is unnecessary to check if the image id is empty. * remove unnecessary check for emptiness of image id * reverse order of the conditions for assigning the image attribute, with the default case (using the slug) first, and the fallback case (using the id) second --- .../providers/digitalocean/resource_digitalocean_droplet.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/providers/digitalocean/resource_digitalocean_droplet.go b/builtin/providers/digitalocean/resource_digitalocean_droplet.go index 7dbc15bb2..43fa7bca6 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_droplet.go +++ b/builtin/providers/digitalocean/resource_digitalocean_droplet.go @@ -170,10 +170,10 @@ func resourceDigitalOceanDropletRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error retrieving droplet: %s", err) } - if droplet.ImageSlug() == "" && droplet.ImageId() != "" { - d.Set("image", droplet.ImageId()) - } else { + if droplet.ImageSlug() != "" { d.Set("image", droplet.ImageSlug()) + } else { + d.Set("image", droplet.ImageId()) } d.Set("name", droplet.Name)