add a fixer and update docs for spot_price_auto_product
This commit is contained in:
parent
c722afe707
commit
c979cad579
|
@ -43,6 +43,7 @@ func init() {
|
|||
"hyperv-cpu-and-ram": new(FizerHypervCPUandRAM),
|
||||
"vmware-compaction": new(FixerVMwareCompaction),
|
||||
"clean-image-name": new(FixerCleanImageName),
|
||||
"spot-price-auto-product": new(FixerAmazonSpotPriceProductDeprecation),
|
||||
}
|
||||
|
||||
FixerOrder = []string{
|
||||
|
@ -67,5 +68,6 @@ func init() {
|
|||
"vmware-compaction",
|
||||
"hyperv-cpu-and-ram",
|
||||
"clean-image-name",
|
||||
"spot-price-auto-product",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package fix
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
// FixerAmazonSpotPriceProductDeprecation removes the deprecated "vhd_temp_path" setting
|
||||
// from Amazon builder templates
|
||||
type FixerAmazonSpotPriceProductDeprecation struct{}
|
||||
|
||||
func (FixerAmazonSpotPriceProductDeprecation) Fix(input map[string]interface{}) (map[string]interface{}, error) {
|
||||
// The type we'll decode into; we only care about builders
|
||||
type template struct {
|
||||
Builders []map[string]interface{}
|
||||
}
|
||||
|
||||
// Decode the input into our structure, if we can
|
||||
var tpl template
|
||||
if err := mapstructure.Decode(input, &tpl); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, builder := range tpl.Builders {
|
||||
builderTypeRaw, ok := builder["type"]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
builderType, ok := builderTypeRaw.(string)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
buildersToFix := []string{"amazon-ebs", "amazon-ebssurrogate",
|
||||
"amazon-ebsvolume", "amazon-instance"}
|
||||
|
||||
matched := false
|
||||
for _, b := range buildersToFix {
|
||||
if builderType == b {
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !matched {
|
||||
continue
|
||||
}
|
||||
|
||||
_, ok = builder["spot_price_auto_product"]
|
||||
if ok {
|
||||
delete(builder, "spot_price_auto_product")
|
||||
}
|
||||
}
|
||||
|
||||
input["builders"] = tpl.Builders
|
||||
return input, nil
|
||||
}
|
||||
|
||||
func (FixerAmazonSpotPriceProductDeprecation) Synopsis() string {
|
||||
return `Removes the deprecated "spot_price_auto_product" setting from Amazon builder templates`
|
||||
}
|
|
@ -16,9 +16,15 @@
|
|||
this to `auto` for Packer to automatically discover the best spot price or
|
||||
to "0" to use an on demand instance (default).
|
||||
|
||||
- `spot_price_auto_product` (string) - Required if `spot_price` is set to
|
||||
`auto`. This tells Packer what sort of AMI you're launching to find the
|
||||
best spot price. This must be one of: `Linux/UNIX`, `SUSE Linux`,
|
||||
- `spot_price_auto_product` (string) - Deprecated. Prior to v1.4.3, was
|
||||
required if `spot_price` is set to `auto`.
|
||||
|
||||
If you are using Packer v1.4.3 or later, simply remove this from your
|
||||
template; it is no longer necessary based on recent changes to how Amazon
|
||||
calculates spot prices.
|
||||
|
||||
Prior to version 1.4.3, This told Packer what sort of AMI you're launching
|
||||
to find the best spot price. This must be one of: `Linux/UNIX`, `SUSE Linux`,
|
||||
`Windows`, `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`,
|
||||
`Windows (Amazon VPC)`
|
||||
|
||||
|
|
Loading…
Reference in New Issue