Check if spot price is empty, when spot_tags is set

This commit is contained in:
Mark Meyer 2017-10-13 08:22:15 +02:00
parent 3dbf1cb371
commit 2fec76ea87
5 changed files with 11 additions and 8 deletions

View File

@ -77,10 +77,6 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
c.RunTags = make(map[string]string) c.RunTags = make(map[string]string)
} }
if c.SpotTags == nil {
c.SpotTags = make(map[string]string)
}
// Validation // Validation
errs := c.Comm.Prepare(ctx) errs := c.Comm.Prepare(ctx)
@ -123,6 +119,13 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
} }
} }
if c.SpotTags != nil {
if c.SpotPrice == "" || c.SpotPrice == "0" {
errs = append(errs, fmt.Errorf(
"spot_tags should not be set when not requesting a spot instance"))
}
}
if c.UserData != "" && c.UserDataFile != "" { if c.UserData != "" && c.UserDataFile != "" {
errs = append(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified.")) errs = append(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified."))
} else if c.UserDataFile != "" { } else if c.UserDataFile != "" {

View File

@ -344,7 +344,7 @@ builder.
`Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)` `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)`
- `spot_tags` (object of key/value strings) - Requires `spot_price` to - `spot_tags` (object of key/value strings) - Requires `spot_price` to
be set. This tells Packer to aplly tags to the spot request that is be set. This tells Packer to apply tags to the spot request that is
issued. issued.
- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA) - `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA)

View File

@ -337,7 +337,7 @@ builder.
`Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)` `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)`
- `spot_tags` (object of key/value strings) - Requires `spot_price` to - `spot_tags` (object of key/value strings) - Requires `spot_price` to
be set. This tells Packer to aplly tags to the spot request that is be set. This tells Packer to apply tags to the spot request that is
issued. issued.
- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA) - `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA)

View File

@ -265,7 +265,7 @@ builder.
`Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)` or `Windows (Amazon VPC)` `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)` or `Windows (Amazon VPC)`
- `spot_tags` (object of key/value strings) - Requires `spot_price` to - `spot_tags` (object of key/value strings) - Requires `spot_price` to
be set. This tells Packer to aplly tags to the spot request that is be set. This tells Packer to apply tags to the spot request that is
issued. issued.
- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA) - `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA)

View File

@ -340,7 +340,7 @@ builder.
`Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)` `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)`
- `spot_tags` (object of key/value strings) - Requires `spot_price` to - `spot_tags` (object of key/value strings) - Requires `spot_price` to
be set. This tells Packer to aplly tags to the spot request that is be set. This tells Packer to apply tags to the spot request that is
issued. issued.
- `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA) - `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA)