be nice if user gets the image visibility case wrong

This commit is contained in:
Matthew Hooker 2016-12-14 16:08:36 -08:00
parent 9c863cb081
commit 754ed931e9
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
1 changed files with 5 additions and 4 deletions

View File

@ -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
}
}