be nice if user gets the image visibility case wrong
This commit is contained in:
parent
9c863cb081
commit
754ed931e9
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue