github.phpd.cn/hashicorp/packer@v1.3.2/builder/triton/target_image_config.go (about) 1 package triton 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/packer/template/interpolate" 7 ) 8 9 // TargetImageConfig represents the configuration for the image to be created 10 // from the source machine. 11 type TargetImageConfig struct { 12 ImageName string `mapstructure:"image_name"` 13 ImageVersion string `mapstructure:"image_version"` 14 ImageDescription string `mapstructure:"image_description"` 15 ImageHomepage string `mapstructure:"image_homepage"` 16 ImageEULA string `mapstructure:"image_eula_url"` 17 ImageACL []string `mapstructure:"image_acls"` 18 ImageTags map[string]string `mapstructure:"image_tags"` 19 } 20 21 // Prepare performs basic validation on a TargetImageConfig struct. 22 func (c *TargetImageConfig) Prepare(ctx *interpolate.Context) []error { 23 var errs []error 24 25 if c.ImageName == "" { 26 errs = append(errs, fmt.Errorf("An image_name must be specified")) 27 } 28 29 if c.ImageVersion == "" { 30 errs = append(errs, fmt.Errorf("An image_version must be specified")) 31 } 32 33 if len(errs) > 0 { 34 return errs 35 } 36 37 return nil 38 }