Support defined tags for oci builder

This commit is contained in:
Robert Neumayer 2019-09-27 14:49:37 +02:00
parent 2c9615a3e3
commit 70b2d300e6
4 changed files with 22 additions and 1 deletions

View File

@ -63,7 +63,8 @@ type Config struct {
SubnetID string `mapstructure:"subnet_ocid"`
// Tagging
Tags map[string]string `mapstructure:"tags"`
Tags map[string]string `mapstructure:"tags"`
DefinedTags map[string]map[string]interface{} `mapstructure:"defined_tags"`
ctx interpolate.Context
}
@ -207,6 +208,9 @@ func NewConfig(raws ...interface{}) (*Config, error) {
}
}
//if c.DefinedTags != nil {
// }
if c.ImageName == "" {
name, err := interpolate.Render("packer-{{timestamp}}", nil)
if err != nil {

View File

@ -32,6 +32,9 @@ func testConfig(accessConfFile *os.File) map[string]interface{} {
"metadata": map[string]string{
"key": "value",
},
"defined_tags": map[string]map[string]interface{}{
"namespace": {"key": "value"},
},
}
}

View File

@ -81,6 +81,7 @@ func (d *driverOCI) CreateImage(ctx context.Context, id string) (core.Image, err
InstanceId: &id,
DisplayName: &d.cfg.ImageName,
FreeformTags: d.cfg.Tags,
DefinedTags: d.cfg.DefinedTags,
}})
if err != nil {

View File

@ -161,6 +161,19 @@ builder.
"tag2": "value2"
```
- `defined_tags` (map of map of strings) - Add one or more defined tags for a given namespace to the resulting
custom image. See [the Oracle
docs](https://docs.cloud.oracle.com/iaas/Content/Identity/Concepts/taggingoverview.htm)
for more details. Example:
``` {.yaml}
"tags":
"namespace": {
"tag1": "value1",
"tag2": "value2"
}
```
## Basic Example
Here is a basic example. Note that account specific configuration has been