tests: add some fields to config_test

This commit is contained in:
js-g 2020-09-08 23:30:37 -04:00
parent dd54651125
commit 9d5dedc3db
4 changed files with 28 additions and 19 deletions

View File

@ -1,4 +1,4 @@
//go:generate mapstructure-to-hcl2 -type Config,CreateVnicDetailsRaw //go:generate mapstructure-to-hcl2 -type Config,CreateVNICDetails
package oci package oci
@ -22,7 +22,7 @@ import (
ociauth "github.com/oracle/oci-go-sdk/common/auth" ociauth "github.com/oracle/oci-go-sdk/common/auth"
) )
type CreateVnicDetailsRaw struct { type CreateVNICDetails 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"`
DefinedTags map[string]map[string]interface{} `mapstructure:"defined_tags" required:"false"` DefinedTags map[string]map[string]interface{} `mapstructure:"defined_tags" required:"false"`
@ -90,8 +90,8 @@ type Config struct {
UserDataFile string `mapstructure:"user_data_file"` UserDataFile string `mapstructure:"user_data_file"`
// Networking // Networking
SubnetID string `mapstructure:"subnet_ocid"` SubnetID string `mapstructure:"subnet_ocid"`
CreateVnicDetails CreateVnicDetailsRaw `mapstructure:"create_vnic_details"` CreateVnicDetails CreateVNICDetails `mapstructure:"create_vnic_details"`
// Tagging // Tagging
Tags map[string]string `mapstructure:"tags"` Tags map[string]string `mapstructure:"tags"`

View File

@ -1,4 +1,4 @@
// Code generated by "mapstructure-to-hcl2 -type Config,CreateVnicDetailsRaw"; DO NOT EDIT. // Code generated by "mapstructure-to-hcl2 -type Config,CreateVNICDetails"; DO NOT EDIT.
package oci package oci
import ( import (
@ -85,7 +85,7 @@ type FlatConfig struct {
UserData *string `mapstructure:"user_data" cty:"user_data" hcl:"user_data"` UserData *string `mapstructure:"user_data" cty:"user_data" hcl:"user_data"`
UserDataFile *string `mapstructure:"user_data_file" cty:"user_data_file" hcl:"user_data_file"` UserDataFile *string `mapstructure:"user_data_file" cty:"user_data_file" hcl:"user_data_file"`
SubnetID *string `mapstructure:"subnet_ocid" cty:"subnet_ocid" hcl:"subnet_ocid"` SubnetID *string `mapstructure:"subnet_ocid" cty:"subnet_ocid" hcl:"subnet_ocid"`
CreateVnicDetails *FlatCreateVnicDetailsRaw `mapstructure:"create_vnic_details" cty:"create_vnic_details" hcl:"create_vnic_details"` CreateVnicDetails *FlatCreateVNICDetails `mapstructure:"create_vnic_details" cty:"create_vnic_details" hcl:"create_vnic_details"`
Tags map[string]string `mapstructure:"tags" cty:"tags" hcl:"tags"` Tags map[string]string `mapstructure:"tags" cty:"tags" hcl:"tags"`
DefinedTags map[string]map[string]interface{} `mapstructure:"defined_tags" cty:"defined_tags" hcl:"defined_tags"` DefinedTags map[string]map[string]interface{} `mapstructure:"defined_tags" cty:"defined_tags" hcl:"defined_tags"`
} }
@ -178,16 +178,16 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"user_data": &hcldec.AttrSpec{Name: "user_data", Type: cty.String, Required: false}, "user_data": &hcldec.AttrSpec{Name: "user_data", Type: cty.String, Required: false},
"user_data_file": &hcldec.AttrSpec{Name: "user_data_file", Type: cty.String, Required: false}, "user_data_file": &hcldec.AttrSpec{Name: "user_data_file", Type: cty.String, Required: false},
"subnet_ocid": &hcldec.AttrSpec{Name: "subnet_ocid", Type: cty.String, Required: false}, "subnet_ocid": &hcldec.AttrSpec{Name: "subnet_ocid", Type: cty.String, Required: false},
"create_vnic_details": &hcldec.BlockSpec{TypeName: "create_vnic_details", Nested: hcldec.ObjectSpec((*FlatCreateVnicDetailsRaw)(nil).HCL2Spec())}, "create_vnic_details": &hcldec.BlockSpec{TypeName: "create_vnic_details", Nested: hcldec.ObjectSpec((*FlatCreateVNICDetails)(nil).HCL2Spec())},
"tags": &hcldec.AttrSpec{Name: "tags", Type: cty.Map(cty.String), Required: false}, "tags": &hcldec.AttrSpec{Name: "tags", Type: cty.Map(cty.String), Required: false},
"defined_tags": &hcldec.AttrSpec{Name: "defined_tags", Type: cty.Map(cty.String), Required: false}, "defined_tags": &hcldec.AttrSpec{Name: "defined_tags", Type: cty.Map(cty.String), Required: false},
} }
return s return s
} }
// FlatCreateVnicDetailsRaw is an auto-generated flat version of CreateVnicDetailsRaw. // FlatCreateVNICDetails is an auto-generated flat version of CreateVNICDetails.
// 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 FlatCreateVNICDetails 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"`
DefinedTags map[string]map[string]interface{} `mapstructure:"defined_tags" required:"false" cty:"defined_tags" hcl:"defined_tags"` DefinedTags map[string]map[string]interface{} `mapstructure:"defined_tags" required:"false" cty:"defined_tags" hcl:"defined_tags"`
DisplayName *string `mapstructure:"display_name" required:"false" cty:"display_name" hcl:"display_name"` DisplayName *string `mapstructure:"display_name" required:"false" cty:"display_name" hcl:"display_name"`
@ -199,17 +199,17 @@ type FlatCreateVnicDetailsRaw struct {
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id" hcl:"subnet_id"` SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id" hcl:"subnet_id"`
} }
// FlatMapstructure returns a new FlatCreateVnicDetailsRaw. // FlatMapstructure returns a new FlatCreateVNICDetails.
// FlatCreateVnicDetailsRaw is an auto-generated flat version of CreateVnicDetailsRaw. // FlatCreateVNICDetails is an auto-generated flat version of CreateVNICDetails.
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. // Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
func (*CreateVnicDetailsRaw) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { func (*CreateVNICDetails) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
return new(FlatCreateVnicDetailsRaw) return new(FlatCreateVNICDetails)
} }
// HCL2Spec returns the hcl spec of a CreateVnicDetailsRaw. // HCL2Spec returns the hcl spec of a CreateVNICDetails.
// This spec is used by HCL to read the fields of CreateVnicDetailsRaw. // This spec is used by HCL to read the fields of CreateVNICDetails.
// The decoded values from this spec will then be applied to a FlatCreateVnicDetailsRaw. // The decoded values from this spec will then be applied to a FlatCreateVNICDetails.
func (*FlatCreateVnicDetailsRaw) HCL2Spec() map[string]hcldec.Spec { func (*FlatCreateVNICDetails) 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}, "defined_tags": &hcldec.AttrSpec{Name: "defined_tags", Type: cty.Map(cty.String), Required: false},

View File

@ -21,7 +21,6 @@ func testConfig(accessConfFile *os.File) map[string]interface{} {
// Image // Image
"base_image_ocid": "ocd1...", "base_image_ocid": "ocd1...",
"shape": "VM.Standard1.1",
"image_name": "HelloWorld", "image_name": "HelloWorld",
// Networking // Networking
@ -36,6 +35,16 @@ func testConfig(accessConfFile *os.File) map[string]interface{} {
"defined_tags": map[string]map[string]interface{}{ "defined_tags": map[string]map[string]interface{}{
"namespace": {"key": "value"}, "namespace": {"key": "value"},
}, },
// Instance Details
"instance_name": "hello-world",
"instance_tags": map[string]string{
"key": "value",
},
"create_vnic_details": map[string]interface{}{
"nsg_ids": []string{"ocd1..."},
},
"shape": "VM.Standard1.1",
} }
} }

View File

@ -281,7 +281,7 @@ are listed in `nsg_ids` under `create_vnic_details`.
"Team": "CostCenter", "Team": "CostCenter",
"Environment": "prod" "Environment": "prod"
} }
} },
"create_vnic_details": { "create_vnic_details": {
"assign_public_ip": "false", "assign_public_ip": "false",
"display_name": "testing-123", "display_name": "testing-123",