fix (builder/oracle-oci): add freeform and defined tags to create_vnic_details
This commit is contained in:
parent
254716a02a
commit
dd54651125
|
@ -24,13 +24,15 @@ import (
|
||||||
|
|
||||||
type CreateVnicDetailsRaw struct {
|
type CreateVnicDetailsRaw struct {
|
||||||
// fields that can be specified under "create_vnic_details"
|
// fields that can be specified under "create_vnic_details"
|
||||||
AssignPublicIp *bool `mapstructure:"assign_public_ip" required:"false"`
|
AssignPublicIp *bool `mapstructure:"assign_public_ip" required:"false"`
|
||||||
DisplayName *string `mapstructure:"display_name" required:"false"`
|
DefinedTags map[string]map[string]interface{} `mapstructure:"defined_tags" required:"false"`
|
||||||
HostnameLabel *string `mapstructure:"hostname_label" required:"false"`
|
DisplayName *string `mapstructure:"display_name" required:"false"`
|
||||||
NsgIds []string `mapstructure:"nsg_ids" required:"false"`
|
FreeformTags map[string]string `mapstructure:"tags" required:"false"`
|
||||||
PrivateIp *string `mapstructure:"private_ip" required:"false"`
|
HostnameLabel *string `mapstructure:"hostname_label" required:"false"`
|
||||||
SkipSourceDestCheck *bool `mapstructure:"skip_source_dest_check" required:"false"`
|
NsgIds []string `mapstructure:"nsg_ids" required:"false"`
|
||||||
SubnetId *string `mapstructure:"subnet_id" required:"false"`
|
PrivateIp *string `mapstructure:"private_ip" required:"false"`
|
||||||
|
SkipSourceDestCheck *bool `mapstructure:"skip_source_dest_check" required:"false"`
|
||||||
|
SubnetId *string `mapstructure:"subnet_id" required:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|
|
@ -188,13 +188,15 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
||||||
// FlatCreateVnicDetailsRaw is an auto-generated flat version of CreateVnicDetailsRaw.
|
// FlatCreateVnicDetailsRaw is an auto-generated flat version of CreateVnicDetailsRaw.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatCreateVnicDetailsRaw struct {
|
type FlatCreateVnicDetailsRaw struct {
|
||||||
AssignPublicIp *bool `mapstructure:"assign_public_ip" required:"false" cty:"assign_public_ip" hcl:"assign_public_ip"`
|
AssignPublicIp *bool `mapstructure:"assign_public_ip" required:"false" cty:"assign_public_ip" hcl:"assign_public_ip"`
|
||||||
DisplayName *string `mapstructure:"display_name" required:"false" cty:"display_name" hcl:"display_name"`
|
DefinedTags map[string]map[string]interface{} `mapstructure:"defined_tags" required:"false" cty:"defined_tags" hcl:"defined_tags"`
|
||||||
HostnameLabel *string `mapstructure:"hostname_label" required:"false" cty:"hostname_label" hcl:"hostname_label"`
|
DisplayName *string `mapstructure:"display_name" required:"false" cty:"display_name" hcl:"display_name"`
|
||||||
NsgIds []string `mapstructure:"nsg_ids" required:"false" cty:"nsg_ids" hcl:"nsg_ids"`
|
FreeformTags map[string]string `mapstructure:"tags" required:"false" cty:"tags" hcl:"tags"`
|
||||||
PrivateIp *string `mapstructure:"private_ip" required:"false" cty:"private_ip" hcl:"private_ip"`
|
HostnameLabel *string `mapstructure:"hostname_label" required:"false" cty:"hostname_label" hcl:"hostname_label"`
|
||||||
SkipSourceDestCheck *bool `mapstructure:"skip_source_dest_check" required:"false" cty:"skip_source_dest_check" hcl:"skip_source_dest_check"`
|
NsgIds []string `mapstructure:"nsg_ids" required:"false" cty:"nsg_ids" hcl:"nsg_ids"`
|
||||||
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id" hcl:"subnet_id"`
|
PrivateIp *string `mapstructure:"private_ip" required:"false" cty:"private_ip" hcl:"private_ip"`
|
||||||
|
SkipSourceDestCheck *bool `mapstructure:"skip_source_dest_check" required:"false" cty:"skip_source_dest_check" hcl:"skip_source_dest_check"`
|
||||||
|
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id" hcl:"subnet_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatCreateVnicDetailsRaw.
|
// FlatMapstructure returns a new FlatCreateVnicDetailsRaw.
|
||||||
|
@ -210,7 +212,9 @@ func (*CreateVnicDetailsRaw) FlatMapstructure() interface{ HCL2Spec() map[string
|
||||||
func (*FlatCreateVnicDetailsRaw) HCL2Spec() map[string]hcldec.Spec {
|
func (*FlatCreateVnicDetailsRaw) HCL2Spec() map[string]hcldec.Spec {
|
||||||
s := map[string]hcldec.Spec{
|
s := map[string]hcldec.Spec{
|
||||||
"assign_public_ip": &hcldec.AttrSpec{Name: "assign_public_ip", Type: cty.Bool, Required: false},
|
"assign_public_ip": &hcldec.AttrSpec{Name: "assign_public_ip", Type: cty.Bool, Required: false},
|
||||||
|
"defined_tags": &hcldec.AttrSpec{Name: "defined_tags", Type: cty.Map(cty.String), Required: false},
|
||||||
"display_name": &hcldec.AttrSpec{Name: "display_name", Type: cty.String, Required: false},
|
"display_name": &hcldec.AttrSpec{Name: "display_name", Type: cty.String, Required: false},
|
||||||
|
"tags": &hcldec.AttrSpec{Name: "tags", Type: cty.Map(cty.String), Required: false},
|
||||||
"hostname_label": &hcldec.AttrSpec{Name: "hostname_label", Type: cty.String, Required: false},
|
"hostname_label": &hcldec.AttrSpec{Name: "hostname_label", Type: cty.String, Required: false},
|
||||||
"nsg_ids": &hcldec.AttrSpec{Name: "nsg_ids", Type: cty.List(cty.String), Required: false},
|
"nsg_ids": &hcldec.AttrSpec{Name: "nsg_ids", Type: cty.List(cty.String), Required: false},
|
||||||
"private_ip": &hcldec.AttrSpec{Name: "private_ip", Type: cty.String, Required: false},
|
"private_ip": &hcldec.AttrSpec{Name: "private_ip", Type: cty.String, Required: false},
|
||||||
|
|
|
@ -76,6 +76,8 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin
|
||||||
PrivateIp: d.cfg.CreateVnicDetails.PrivateIp,
|
PrivateIp: d.cfg.CreateVnicDetails.PrivateIp,
|
||||||
SkipSourceDestCheck: d.cfg.CreateVnicDetails.SkipSourceDestCheck,
|
SkipSourceDestCheck: d.cfg.CreateVnicDetails.SkipSourceDestCheck,
|
||||||
SubnetId: d.cfg.CreateVnicDetails.SubnetId,
|
SubnetId: d.cfg.CreateVnicDetails.SubnetId,
|
||||||
|
DefinedTags: d.cfg.CreateVnicDetails.DefinedTags,
|
||||||
|
FreeformTags: d.cfg.CreateVnicDetails.FreeformTags,
|
||||||
}
|
}
|
||||||
|
|
||||||
instanceDetails.CreateVnicDetails = &CreateVnicDetails
|
instanceDetails.CreateVnicDetails = &CreateVnicDetails
|
||||||
|
|
|
@ -141,9 +141,10 @@ builder.
|
||||||
to the instance used for the image creation process.
|
to the instance used for the image creation process.
|
||||||
|
|
||||||
- `create_vnic_details` (map of strings) - Specify details for the virtual network interface card (VNIC)
|
- `create_vnic_details` (map of strings) - Specify details for the virtual network interface card (VNIC)
|
||||||
that get attached to the instance. Possible keys (all optional) are: `assign_public_ip` (bool),
|
that is attached to the instance. Possible keys (all optional) are: `assign_public_ip` (bool),
|
||||||
`display_name` (string), `hostname_lable` (string), `nsg_ids` (list), `private_ip` (string),
|
`display_name` (string), `hostname_lable` (string), `nsg_ids` (list), `private_ip` (string),
|
||||||
`skip_source_dest_check` (bool), and `subnet_id` (string). See
|
`skip_source_dest_check` (bool), `subnet_id` (string), `tags` (map of string), and `defined_tags`
|
||||||
|
(map of maps of strings). See
|
||||||
[the Oracle docs](https://docs.cloud.oracle.com/en-us/iaas/Content/Network/Tasks/managingVNICs.htm)
|
[the Oracle docs](https://docs.cloud.oracle.com/en-us/iaas/Content/Network/Tasks/managingVNICs.htm)
|
||||||
for more information about VNICs.
|
for more information about VNICs.
|
||||||
|
|
||||||
|
@ -252,7 +253,7 @@ Build 'oracle-oci' finished.
|
||||||
[opc@packerhost ~]$
|
[opc@packerhost ~]$
|
||||||
```
|
```
|
||||||
|
|
||||||
## Auto-assign Tags and Network Security Groups to Instance
|
## Assigning Tags and Network Security Groups to the Instance
|
||||||
Tags are useful for breaking down costs and usage. The keys `instance_tags`
|
Tags are useful for breaking down costs and usage. The keys `instance_tags`
|
||||||
and `instance_defined_tags` are assigned to the temporary instance,
|
and `instance_defined_tags` are assigned to the temporary instance,
|
||||||
whereas `tags` and `defined_tags` are assigned to the resulting image.
|
whereas `tags` and `defined_tags` are assigned to the resulting image.
|
||||||
|
@ -264,16 +265,16 @@ of the virtual network interface card (VNIC) attached to the instance, and
|
||||||
are listed in `nsg_ids` under `create_vnic_details`.
|
are listed in `nsg_ids` under `create_vnic_details`.
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"name": "base-image-{{isotime \"20000102030405\"}}",
|
"name": "base-image-{{isotime \"20060102030405\"}}",
|
||||||
"type": "oracle-oci",
|
"type": "oracle-oci",
|
||||||
"availability_domain": "aaaa:PHX-AD-1",
|
"availability_domain": "aaaa:PHX-AD-1",
|
||||||
"base_image_ocid": "ocid1.image.oc1.iad.aaa",
|
"base_image_ocid": "ocid1.image.oc1.iad.aaa",
|
||||||
"compartment_ocid": "ocid1.compartment.oc1..aaa",
|
"compartment_ocid": "ocid1.compartment.oc1..aaa",
|
||||||
"image_name": "my-image-{{isotime \"20000102030405\"}}",
|
"image_name": "my-image-{{isotime \"20060102030405\"}}",
|
||||||
"shape": "VM.Standard.E2.1",
|
"shape": "VM.Standard.E2.1",
|
||||||
"subnet_ocid": "ocid1.subnet.oc1.iad.aaa",
|
"subnet_ocid": "ocid1.subnet.oc1.iad.aaa",
|
||||||
"use_private_ip": "true",
|
"use_private_ip": "true",
|
||||||
"instance_name": "packer-build-{{isotime \"20000102030405\"}}",
|
"instance_name": "packer-build-{{isotime \"20060102030405\"}}",
|
||||||
"instance_tags": { "testing": "yes" },
|
"instance_tags": { "testing": "yes" },
|
||||||
"instance_defined_tags": {
|
"instance_defined_tags": {
|
||||||
"Operations": {
|
"Operations": {
|
||||||
|
@ -287,7 +288,7 @@ are listed in `nsg_ids` under `create_vnic_details`.
|
||||||
"nsg_ids": ["ocid1.networksecuritygroup.oc1.iad.aaa"]
|
"nsg_ids": ["ocid1.networksecuritygroup.oc1.iad.aaa"]
|
||||||
},
|
},
|
||||||
"tags": {
|
"tags": {
|
||||||
"CreationDate": "{{isotime \"20000102 15:04:05 MST\"}}"
|
"CreationDate": "{{isotime \"20060102 03:04:05 MST\"}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue