From 754ed931e9dec0bdf4b25d41e8802d80e0775824 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Wed, 14 Dec 2016 16:08:36 -0800 Subject: [PATCH] be nice if user gets the image visibility case wrong --- builder/openstack/image_config.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/builder/openstack/image_config.go b/builder/openstack/image_config.go index 50f802c55..3e4319547 100644 --- a/builder/openstack/image_config.go +++ b/builder/openstack/image_config.go @@ -2,6 +2,7 @@ package openstack import ( "fmt" + "strings" imageservice "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" "github.com/mitchellh/packer/template/interpolate" @@ -9,8 +10,7 @@ import ( // ImageConfig is for common configuration related to creating Images. type ImageConfig struct { - ImageName string `mapstructure:"image_name"` - + ImageName string `mapstructure:"image_name"` ImageMetadata map[string]string `mapstructure:"metadata"` ImageVisibility imageservice.ImageVisibility `mapstructure:"image_visibility"` ImageMembers []string `mapstructure:"image_members"` @@ -36,11 +36,12 @@ func (c *ImageConfig) Prepare(ctx *interpolate.Context) []error { // ImageVisibility values // https://wiki.openstack.org/wiki/Glance-v2-community-image-visibility-design if c.ImageVisibility != "" { - validVals := []string{"public", "private", "shared", "community"} + validVals := []imageservice.ImageVisibility{"public", "private", "shared", "community"} valid := false for _, val := range validVals { - if string(c.ImageVisibility) == val { + if strings.EqualFold(string(c.ImageVisibility), string(val)) { valid = true + c.ImageVisibility = val break } }