This commit is contained in:
Adrien Delorme 2020-03-16 12:19:34 +01:00
parent dbb4981d66
commit dab689ce2e
8 changed files with 21 additions and 11 deletions

View File

@ -192,7 +192,7 @@ type AlicloudImageConfig struct {
AlicloudImageSkipRegionValidation bool `mapstructure:"skip_region_validation" required:"false"` AlicloudImageSkipRegionValidation bool `mapstructure:"skip_region_validation" required:"false"`
// Tags applied to the destination image and relevant snapshots. // Tags applied to the destination image and relevant snapshots.
AlicloudImageTags map[string]string `mapstructure:"tags" required:"false"` AlicloudImageTags map[string]string `mapstructure:"tags" required:"false"`
// Same as [`tags`](#tags) but defined as a singular block containing a key // Same as [`tags`](#tags) but defined as a singular repeatable block containing a key
// and a value field. In HCL2 mode the // and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.

View File

@ -51,7 +51,7 @@ type AMIConfig struct {
// [template engine](/docs/templates/engine.html), see [Build template // [template engine](/docs/templates/engine.html), see [Build template
// data](#build-template-data) for more information. // data](#build-template-data) for more information.
AMITags TagMap `mapstructure:"tags" required:"false"` AMITags TagMap `mapstructure:"tags" required:"false"`
// Same as [`tags`](#tags) but defined as a singular block containing a key // Same as [`tags`](#tags) but defined as a singular repeatable block containing a key
// and a value field. In HCL2 mode the // and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.

View File

@ -187,11 +187,11 @@ type RunConfig struct {
// EBS volumes. This is a [template engine](/docs/templates/engine.html), // EBS volumes. This is a [template engine](/docs/templates/engine.html),
// see [Build template data](#build-template-data) for more information. // see [Build template data](#build-template-data) for more information.
RunTags map[string]string `mapstructure:"run_tags" required:"false"` RunTags map[string]string `mapstructure:"run_tags" required:"false"`
// Same as [`run_tags`](#run_tags) but defined as a singular block // Same as [`run_tags`](#run_tags) but defined as a singular repeatable block
// containing a key and a value field. In HCL2 mode the // containing a key and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.
RunTag []hcl2template.KeyValues `mapstructure:"run_tag" required:"false"` RunTag hcl2template.KeyValues `mapstructure:"run_tag" required:"false"`
// The ID (not the name) of the security // The ID (not the name) of the security
// group to assign to the instance. By default this is not set and Packer will // group to assign to the instance. By default this is not set and Packer will
// automatically create a new temporary security group to allow SSH access. // automatically create a new temporary security group to allow SSH access.
@ -284,7 +284,7 @@ type RunConfig struct {
// Requires spot_price to be set. This tells Packer to apply tags to the // Requires spot_price to be set. This tells Packer to apply tags to the
// spot request that is issued. // spot request that is issued.
SpotTags map[string]string `mapstructure:"spot_tags" required:"false"` SpotTags map[string]string `mapstructure:"spot_tags" required:"false"`
// Same as [`spot_tags`](#spot_tags) but defined as a singular block // Same as [`spot_tags`](#spot_tags) but defined as a singular repeatable block
// containing a key and a value field. In HCL2 mode the // containing a key and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.
@ -422,6 +422,16 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
// Validation // Validation
errs := c.Comm.Prepare(ctx) errs := c.Comm.Prepare(ctx)
for _, s := range []struct {
tagMap TagMap
kvs hcl2template.KeyValues
}{
{c.RunTags, c.RunTag},
{c.SpotTags, c.SpotTag},
} {
errs = append(errs, s.kvs.CopyOn(s.tagMap)...)
}
for _, preparer := range []interface{ Prepare() []error }{ for _, preparer := range []interface{ Prepare() []error }{
&c.SourceAmiFilter, &c.SourceAmiFilter,
&c.SecurityGroupFilter, &c.SecurityGroupFilter,

View File

@ -15,7 +15,7 @@ type BlockDevice struct {
// completes. This is a [template engine](/docs/templates/engine.html), see // completes. This is a [template engine](/docs/templates/engine.html), see
// [Build template data](#build-template-data) for more information. // [Build template data](#build-template-data) for more information.
Tags awscommon.TagMap `mapstructure:"tags" required:"false"` Tags awscommon.TagMap `mapstructure:"tags" required:"false"`
// Same as [`tags`](#tags) but defined as a singular block // Same as [`tags`](#tags) but defined as a singular repeatable block
// containing a key and a value field. In HCL2 mode the // containing a key and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.

View File

@ -241,7 +241,7 @@ type Config struct {
// 256 characters. Tags are applied to every resource deployed by a Packer // 256 characters. Tags are applied to every resource deployed by a Packer
// build, i.e. Resource Group, VM, NIC, VNET, Public IP, KeyVault, etc. // build, i.e. Resource Group, VM, NIC, VNET, Public IP, KeyVault, etc.
AzureTags map[string]*string `mapstructure:"azure_tags" required:"false"` AzureTags map[string]*string `mapstructure:"azure_tags" required:"false"`
// Same as [`azure_tags`](#azure_tags) but defined as a singular block // Same as [`azure_tags`](#azure_tags) but defined as a singular repeatable block
// containing a key and a value field. In HCL2 mode the // containing a key and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.

View File

@ -63,7 +63,7 @@ type Config struct {
ImageDescription string `mapstructure:"image_description" required:"false"` ImageDescription string `mapstructure:"image_description" required:"false"`
// Key/value pair tags to add to the created image. // Key/value pair tags to add to the created image.
ImageTags map[string]string `mapstructure:"image_tags" required:"false"` ImageTags map[string]string `mapstructure:"image_tags" required:"false"`
// Same as [`image_tags`](#image_tags) but defined as a singular block // Same as [`image_tags`](#image_tags) but defined as a singular repeatable block
// containing a key and a value field. In HCL2 mode the // containing a key and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.
@ -77,7 +77,7 @@ type Config struct {
// Key/value pair tags to // Key/value pair tags to
// add to the created server. // add to the created server.
VmTags map[string]string `mapstructure:"vm_tags" required:"false"` VmTags map[string]string `mapstructure:"vm_tags" required:"false"`
// Same as [`vm_tags`](#vm_tags) but defined as a singular block containing // Same as [`vm_tags`](#vm_tags) but defined as a singular repeatable block containing
// a key and a value field. In HCL2 mode the // a key and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.

View File

@ -84,7 +84,7 @@ type TencentCloudRunConfig struct {
// Tags to apply to the instance that is *launched* to create the image. // Tags to apply to the instance that is *launched* to create the image.
// These tags are *not* applied to the resulting image. // These tags are *not* applied to the resulting image.
RunTags map[string]string `mapstructure:"run_tags" required:"false"` RunTags map[string]string `mapstructure:"run_tags" required:"false"`
// Same as [`run_tags`](#run_tags) but defined as a singular block // Same as [`run_tags`](#run_tags) but defined as a singular repeatable block
// containing a key and a value field. In HCL2 mode the // containing a key and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.

View File

@ -37,7 +37,7 @@ type TargetImageConfig struct {
ImageACL []string `mapstructure:"image_acls" required:"false"` ImageACL []string `mapstructure:"image_acls" required:"false"`
// Tag applied to the image. // Tag applied to the image.
ImageTags map[string]string `mapstructure:"image_tags" required:"false"` ImageTags map[string]string `mapstructure:"image_tags" required:"false"`
// Same as [`image_tags`](#image_tags) but defined as a singular block // Same as [`image_tags`](#image_tags) but defined as a singular repeatable block
// containing a key and a value field. In HCL2 mode the // containing a key and a value field. In HCL2 mode the
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks) // [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
// will allow you to create those programatically. // will allow you to create those programatically.