mapstructure-to-hcl2: make basic named types pointers ( optional )

This commit is contained in:
Adrien Delorme 2020-01-07 12:46:27 +01:00
parent d8c3385814
commit 13ea97a1df
3 changed files with 165 additions and 153 deletions

View File

@ -10,109 +10,109 @@ import (
// FlatConfig is an auto-generated flat version of Config. // FlatConfig is an auto-generated flat version of Config.
// 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 FlatConfig struct { type FlatConfig struct {
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"` PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"` PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"` PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"` PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"` PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"` PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"` PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
Username *string `mapstructure:"username" required:"true" cty:"username"` Username *string `mapstructure:"username" required:"true" cty:"username"`
UserID *string `mapstructure:"user_id" cty:"user_id"` UserID *string `mapstructure:"user_id" cty:"user_id"`
Password *string `mapstructure:"password" required:"true" cty:"password"` Password *string `mapstructure:"password" required:"true" cty:"password"`
IdentityEndpoint *string `mapstructure:"identity_endpoint" required:"true" cty:"identity_endpoint"` IdentityEndpoint *string `mapstructure:"identity_endpoint" required:"true" cty:"identity_endpoint"`
TenantID *string `mapstructure:"tenant_id" required:"false" cty:"tenant_id"` TenantID *string `mapstructure:"tenant_id" required:"false" cty:"tenant_id"`
TenantName *string `mapstructure:"tenant_name" cty:"tenant_name"` TenantName *string `mapstructure:"tenant_name" cty:"tenant_name"`
DomainID *string `mapstructure:"domain_id" cty:"domain_id"` DomainID *string `mapstructure:"domain_id" cty:"domain_id"`
DomainName *string `mapstructure:"domain_name" required:"false" cty:"domain_name"` DomainName *string `mapstructure:"domain_name" required:"false" cty:"domain_name"`
Insecure *bool `mapstructure:"insecure" required:"false" cty:"insecure"` Insecure *bool `mapstructure:"insecure" required:"false" cty:"insecure"`
Region *string `mapstructure:"region" required:"false" cty:"region"` Region *string `mapstructure:"region" required:"false" cty:"region"`
EndpointType *string `mapstructure:"endpoint_type" required:"false" cty:"endpoint_type"` EndpointType *string `mapstructure:"endpoint_type" required:"false" cty:"endpoint_type"`
CACertFile *string `mapstructure:"cacert" required:"false" cty:"cacert"` CACertFile *string `mapstructure:"cacert" required:"false" cty:"cacert"`
ClientCertFile *string `mapstructure:"cert" required:"false" cty:"cert"` ClientCertFile *string `mapstructure:"cert" required:"false" cty:"cert"`
ClientKeyFile *string `mapstructure:"key" required:"false" cty:"key"` ClientKeyFile *string `mapstructure:"key" required:"false" cty:"key"`
Token *string `mapstructure:"token" required:"false" cty:"token"` Token *string `mapstructure:"token" required:"false" cty:"token"`
ApplicationCredentialName *string `mapstructure:"application_credential_name" required:"false" cty:"application_credential_name"` ApplicationCredentialName *string `mapstructure:"application_credential_name" required:"false" cty:"application_credential_name"`
ApplicationCredentialID *string `mapstructure:"application_credential_id" required:"false" cty:"application_credential_id"` ApplicationCredentialID *string `mapstructure:"application_credential_id" required:"false" cty:"application_credential_id"`
ApplicationCredentialSecret *string `mapstructure:"application_credential_secret" required:"false" cty:"application_credential_secret"` ApplicationCredentialSecret *string `mapstructure:"application_credential_secret" required:"false" cty:"application_credential_secret"`
Cloud *string `mapstructure:"cloud" required:"false" cty:"cloud"` Cloud *string `mapstructure:"cloud" required:"false" cty:"cloud"`
ImageName *string `mapstructure:"image_name" required:"true" cty:"image_name"` ImageName *string `mapstructure:"image_name" required:"true" cty:"image_name"`
ImageMetadata map[string]string `mapstructure:"metadata" required:"false" cty:"metadata"` ImageMetadata map[string]string `mapstructure:"metadata" required:"false" cty:"metadata"`
ImageVisibility images.ImageVisibility `mapstructure:"image_visibility" required:"false" cty:"image_visibility"` ImageVisibility *images.ImageVisibility `mapstructure:"image_visibility" required:"false" cty:"image_visibility"`
ImageMembers []string `mapstructure:"image_members" required:"false" cty:"image_members"` ImageMembers []string `mapstructure:"image_members" required:"false" cty:"image_members"`
ImageDiskFormat *string `mapstructure:"image_disk_format" required:"false" cty:"image_disk_format"` ImageDiskFormat *string `mapstructure:"image_disk_format" required:"false" cty:"image_disk_format"`
ImageTags []string `mapstructure:"image_tags" required:"false" cty:"image_tags"` ImageTags []string `mapstructure:"image_tags" required:"false" cty:"image_tags"`
ImageMinDisk *int `mapstructure:"image_min_disk" required:"false" cty:"image_min_disk"` ImageMinDisk *int `mapstructure:"image_min_disk" required:"false" cty:"image_min_disk"`
Type *string `mapstructure:"communicator" cty:"communicator"` Type *string `mapstructure:"communicator" cty:"communicator"`
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"` PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"` SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"` SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"` SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"` SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"` SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"` SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"` SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"` SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"` SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"` SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"` SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"` SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"` SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"` SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"` SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"` SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"` SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"` SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"` SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"` SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"` SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"` SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"` SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"` SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"` SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"` SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"` SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"` SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"` SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"` SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"` WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"` WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"` WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"` WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"` WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"` WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"` WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"` WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
SSHInterface *string `mapstructure:"ssh_interface" required:"false" cty:"ssh_interface"` SSHInterface *string `mapstructure:"ssh_interface" required:"false" cty:"ssh_interface"`
SSHIPVersion *string `mapstructure:"ssh_ip_version" required:"false" cty:"ssh_ip_version"` SSHIPVersion *string `mapstructure:"ssh_ip_version" required:"false" cty:"ssh_ip_version"`
SourceImage *string `mapstructure:"source_image" required:"true" cty:"source_image"` SourceImage *string `mapstructure:"source_image" required:"true" cty:"source_image"`
SourceImageName *string `mapstructure:"source_image_name" required:"true" cty:"source_image_name"` SourceImageName *string `mapstructure:"source_image_name" required:"true" cty:"source_image_name"`
SourceImageFilters *FlatImageFilter `mapstructure:"source_image_filter" required:"true" cty:"source_image_filter"` SourceImageFilters *FlatImageFilter `mapstructure:"source_image_filter" required:"true" cty:"source_image_filter"`
Flavor *string `mapstructure:"flavor" required:"true" cty:"flavor"` Flavor *string `mapstructure:"flavor" required:"true" cty:"flavor"`
AvailabilityZone *string `mapstructure:"availability_zone" required:"false" cty:"availability_zone"` AvailabilityZone *string `mapstructure:"availability_zone" required:"false" cty:"availability_zone"`
RackconnectWait *bool `mapstructure:"rackconnect_wait" required:"false" cty:"rackconnect_wait"` RackconnectWait *bool `mapstructure:"rackconnect_wait" required:"false" cty:"rackconnect_wait"`
FloatingIPNetwork *string `mapstructure:"floating_ip_network" required:"false" cty:"floating_ip_network"` FloatingIPNetwork *string `mapstructure:"floating_ip_network" required:"false" cty:"floating_ip_network"`
InstanceFloatingIPNet *string `mapstructure:"instance_floating_ip_net" required:"false" cty:"instance_floating_ip_net"` InstanceFloatingIPNet *string `mapstructure:"instance_floating_ip_net" required:"false" cty:"instance_floating_ip_net"`
FloatingIP *string `mapstructure:"floating_ip" required:"false" cty:"floating_ip"` FloatingIP *string `mapstructure:"floating_ip" required:"false" cty:"floating_ip"`
ReuseIPs *bool `mapstructure:"reuse_ips" required:"false" cty:"reuse_ips"` ReuseIPs *bool `mapstructure:"reuse_ips" required:"false" cty:"reuse_ips"`
SecurityGroups []string `mapstructure:"security_groups" required:"false" cty:"security_groups"` SecurityGroups []string `mapstructure:"security_groups" required:"false" cty:"security_groups"`
Networks []string `mapstructure:"networks" required:"false" cty:"networks"` Networks []string `mapstructure:"networks" required:"false" cty:"networks"`
Ports []string `mapstructure:"ports" required:"false" cty:"ports"` Ports []string `mapstructure:"ports" required:"false" cty:"ports"`
NetworkDiscoveryCIDRs []string `mapstructure:"network_discovery_cidrs" required:"false" cty:"network_discovery_cidrs"` NetworkDiscoveryCIDRs []string `mapstructure:"network_discovery_cidrs" required:"false" cty:"network_discovery_cidrs"`
UserData *string `mapstructure:"user_data" required:"false" cty:"user_data"` UserData *string `mapstructure:"user_data" required:"false" cty:"user_data"`
UserDataFile *string `mapstructure:"user_data_file" required:"false" cty:"user_data_file"` UserDataFile *string `mapstructure:"user_data_file" required:"false" cty:"user_data_file"`
InstanceName *string `mapstructure:"instance_name" required:"false" cty:"instance_name"` InstanceName *string `mapstructure:"instance_name" required:"false" cty:"instance_name"`
InstanceMetadata map[string]string `mapstructure:"instance_metadata" required:"false" cty:"instance_metadata"` InstanceMetadata map[string]string `mapstructure:"instance_metadata" required:"false" cty:"instance_metadata"`
ForceDelete *bool `mapstructure:"force_delete" required:"false" cty:"force_delete"` ForceDelete *bool `mapstructure:"force_delete" required:"false" cty:"force_delete"`
ConfigDrive *bool `mapstructure:"config_drive" required:"false" cty:"config_drive"` ConfigDrive *bool `mapstructure:"config_drive" required:"false" cty:"config_drive"`
FloatingIPPool *string `mapstructure:"floating_ip_pool" required:"false" cty:"floating_ip_pool"` FloatingIPPool *string `mapstructure:"floating_ip_pool" required:"false" cty:"floating_ip_pool"`
UseBlockStorageVolume *bool `mapstructure:"use_blockstorage_volume" required:"false" cty:"use_blockstorage_volume"` UseBlockStorageVolume *bool `mapstructure:"use_blockstorage_volume" required:"false" cty:"use_blockstorage_volume"`
VolumeName *string `mapstructure:"volume_name" required:"false" cty:"volume_name"` VolumeName *string `mapstructure:"volume_name" required:"false" cty:"volume_name"`
VolumeType *string `mapstructure:"volume_type" required:"false" cty:"volume_type"` VolumeType *string `mapstructure:"volume_type" required:"false" cty:"volume_type"`
VolumeSize *int `mapstructure:"volume_size" required:"false" cty:"volume_size"` VolumeSize *int `mapstructure:"volume_size" required:"false" cty:"volume_size"`
VolumeAvailabilityZone *string `mapstructure:"volume_availability_zone" required:"false" cty:"volume_availability_zone"` VolumeAvailabilityZone *string `mapstructure:"volume_availability_zone" required:"false" cty:"volume_availability_zone"`
OpenstackProvider *string `mapstructure:"openstack_provider" cty:"openstack_provider"` OpenstackProvider *string `mapstructure:"openstack_provider" cty:"openstack_provider"`
UseFloatingIp *bool `mapstructure:"use_floating_ip" required:"false" cty:"use_floating_ip"` UseFloatingIp *bool `mapstructure:"use_floating_ip" required:"false" cty:"use_floating_ip"`
} }
// FlatMapstructure returns a new FlatConfig. // FlatMapstructure returns a new FlatConfig.

View File

@ -450,22 +450,26 @@ func getMapstructureSquashedStruct(topPkg *types.Package, utStruct *types.Struct
field = types.NewField(field.Pos(), field.Pkg(), field.Name(), types.NewPointer(types.Typ[types.Bool]), field.Embedded()) field = types.NewField(field.Pos(), field.Pkg(), field.Name(), types.NewPointer(types.Typ[types.Bool]), field.Embedded())
case "github.com/hashicorp/packer/provisioner/powershell.ExecutionPolicy": // TODO(azr): unhack this situation case "github.com/hashicorp/packer/provisioner/powershell.ExecutionPolicy": // TODO(azr): unhack this situation
field = types.NewField(field.Pos(), field.Pkg(), field.Name(), types.NewPointer(types.Typ[types.String]), field.Embedded()) field = types.NewField(field.Pos(), field.Pkg(), field.Name(), types.NewPointer(types.Typ[types.String]), field.Embedded())
} default:
if str, isStruct := f.Underlying().(*types.Struct); isStruct { if str, isStruct := f.Underlying().(*types.Struct); isStruct {
obj := flattenNamed(f, str) obj := flattenNamed(f, str)
field = types.NewField(field.Pos(), field.Pkg(), field.Name(), obj, field.Embedded()) field = types.NewField(field.Pos(), field.Pkg(), field.Name(), obj, field.Embedded())
field = makePointer(field) field = makePointer(field)
} }
if slice, isSlice := f.Underlying().(*types.Slice); isSlice { if slice, isSlice := f.Underlying().(*types.Slice); isSlice {
if f, fNamed := slice.Elem().(*types.Named); fNamed { if f, fNamed := slice.Elem().(*types.Named); fNamed {
if str, isStruct := f.Underlying().(*types.Struct); isStruct { if str, isStruct := f.Underlying().(*types.Struct); isStruct {
// this is a slice of named structs; we want to change // this is a slice of named structs; we want to change
// the struct ref to a 'FlatStruct'. // the struct ref to a 'FlatStruct'.
obj := flattenNamed(f, str) obj := flattenNamed(f, str)
slice := types.NewSlice(obj) slice := types.NewSlice(obj)
field = types.NewField(field.Pos(), field.Pkg(), field.Name(), slice, field.Embedded()) field = types.NewField(field.Pos(), field.Pkg(), field.Name(), slice, field.Embedded())
}
} }
} }
if _, isBasic := f.Underlying().(*types.Basic); isBasic {
field = makePointer(field)
}
} }
case *types.Slice: case *types.Slice:
if f, fNamed := f.Elem().(*types.Named); fNamed { if f, fNamed := f.Elem().(*types.Named); fNamed {

View File

@ -9,16 +9,18 @@ import (
// FlatMockConfig is an auto-generated flat version of MockConfig. // FlatMockConfig is an auto-generated flat version of MockConfig.
// 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 FlatMockConfig struct { type FlatMockConfig struct {
String *string `mapstructure:"string" cty:"string"` String *string `mapstructure:"string" cty:"string"`
Int *int `mapstructure:"int" cty:"int"` Int *int `mapstructure:"int" cty:"int"`
Int64 *int64 `mapstructure:"int64" cty:"int64"` Int64 *int64 `mapstructure:"int64" cty:"int64"`
Bool *bool `mapstructure:"bool" cty:"bool"` Bool *bool `mapstructure:"bool" cty:"bool"`
Trilean *bool `mapstructure:"trilean" cty:"trilean"` Trilean *bool `mapstructure:"trilean" cty:"trilean"`
Duration *string `mapstructure:"duration" cty:"duration"` Duration *string `mapstructure:"duration" cty:"duration"`
MapStringString map[string]string `mapstructure:"map_string_string" cty:"map_string_string"` MapStringString map[string]string `mapstructure:"map_string_string" cty:"map_string_string"`
SliceString []string `mapstructure:"slice_string" cty:"slice_string"` SliceString []string `mapstructure:"slice_string" cty:"slice_string"`
Nested *FlatNestedMockConfig `mapstructure:"nested" cty:"nested"` NamedMapStringString NamedMapStringString `mapstructure:"named_map_string_string" cty:"named_map_string_string"`
NestedSlice []FlatNestedMockConfig `mapstructure:"nested_slice" cty:"nested_slice"` NamedString *NamedString `mapstructure:"named_string" cty:"named_string"`
Nested *FlatNestedMockConfig `mapstructure:"nested" cty:"nested"`
NestedSlice []FlatNestedMockConfig `mapstructure:"nested_slice" cty:"nested_slice"`
} }
// FlatMapstructure returns a new FlatMockConfig. // FlatMapstructure returns a new FlatMockConfig.
@ -33,16 +35,18 @@ func (*MockConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Sp
// The decoded values from this spec will then be applied to a FlatMockConfig. // The decoded values from this spec will then be applied to a FlatMockConfig.
func (*FlatMockConfig) HCL2Spec() map[string]hcldec.Spec { func (*FlatMockConfig) HCL2Spec() map[string]hcldec.Spec {
s := map[string]hcldec.Spec{ s := map[string]hcldec.Spec{
"string": &hcldec.AttrSpec{Name: "string", Type: cty.String, Required: false}, "string": &hcldec.AttrSpec{Name: "string", Type: cty.String, Required: false},
"int": &hcldec.AttrSpec{Name: "int", Type: cty.Number, Required: false}, "int": &hcldec.AttrSpec{Name: "int", Type: cty.Number, Required: false},
"int64": &hcldec.AttrSpec{Name: "int64", Type: cty.Number, Required: false}, "int64": &hcldec.AttrSpec{Name: "int64", Type: cty.Number, Required: false},
"bool": &hcldec.AttrSpec{Name: "bool", Type: cty.Bool, Required: false}, "bool": &hcldec.AttrSpec{Name: "bool", Type: cty.Bool, Required: false},
"trilean": &hcldec.AttrSpec{Name: "trilean", Type: cty.Bool, Required: false}, "trilean": &hcldec.AttrSpec{Name: "trilean", Type: cty.Bool, Required: false},
"duration": &hcldec.AttrSpec{Name: "duration", Type: cty.String, Required: false}, "duration": &hcldec.AttrSpec{Name: "duration", Type: cty.String, Required: false},
"map_string_string": &hcldec.BlockAttrsSpec{TypeName: "map_string_string", ElementType: cty.String, Required: false}, "map_string_string": &hcldec.BlockAttrsSpec{TypeName: "map_string_string", ElementType: cty.String, Required: false},
"slice_string": &hcldec.AttrSpec{Name: "slice_string", Type: cty.List(cty.String), Required: false}, "slice_string": &hcldec.AttrSpec{Name: "slice_string", Type: cty.List(cty.String), Required: false},
"nested": &hcldec.BlockSpec{TypeName: "nested", Nested: hcldec.ObjectSpec((*FlatNestedMockConfig)(nil).HCL2Spec())}, "named_map_string_string": &hcldec.BlockAttrsSpec{TypeName: "named_map_string_string", ElementType: cty.String, Required: false},
"nested_slice": &hcldec.BlockListSpec{TypeName: "nested_slice", Nested: hcldec.ObjectSpec((*FlatNestedMockConfig)(nil).HCL2Spec())}, "named_string": &hcldec.AttrSpec{Name: "named_string", Type: cty.String, Required: false},
"nested": &hcldec.BlockSpec{TypeName: "nested", Nested: hcldec.ObjectSpec((*FlatNestedMockConfig)(nil).HCL2Spec())},
"nested_slice": &hcldec.BlockListSpec{TypeName: "nested_slice", Nested: hcldec.ObjectSpec((*FlatNestedMockConfig)(nil).HCL2Spec())},
} }
return s return s
} }
@ -50,14 +54,16 @@ func (*FlatMockConfig) HCL2Spec() map[string]hcldec.Spec {
// FlatNestedMockConfig is an auto-generated flat version of NestedMockConfig. // FlatNestedMockConfig is an auto-generated flat version of NestedMockConfig.
// 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 FlatNestedMockConfig struct { type FlatNestedMockConfig struct {
String *string `mapstructure:"string" cty:"string"` String *string `mapstructure:"string" cty:"string"`
Int *int `mapstructure:"int" cty:"int"` Int *int `mapstructure:"int" cty:"int"`
Int64 *int64 `mapstructure:"int64" cty:"int64"` Int64 *int64 `mapstructure:"int64" cty:"int64"`
Bool *bool `mapstructure:"bool" cty:"bool"` Bool *bool `mapstructure:"bool" cty:"bool"`
Trilean *bool `mapstructure:"trilean" cty:"trilean"` Trilean *bool `mapstructure:"trilean" cty:"trilean"`
Duration *string `mapstructure:"duration" cty:"duration"` Duration *string `mapstructure:"duration" cty:"duration"`
MapStringString map[string]string `mapstructure:"map_string_string" cty:"map_string_string"` MapStringString map[string]string `mapstructure:"map_string_string" cty:"map_string_string"`
SliceString []string `mapstructure:"slice_string" cty:"slice_string"` SliceString []string `mapstructure:"slice_string" cty:"slice_string"`
NamedMapStringString NamedMapStringString `mapstructure:"named_map_string_string" cty:"named_map_string_string"`
NamedString *NamedString `mapstructure:"named_string" cty:"named_string"`
} }
// FlatMapstructure returns a new FlatNestedMockConfig. // FlatMapstructure returns a new FlatNestedMockConfig.
@ -72,14 +78,16 @@ func (*NestedMockConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcl
// The decoded values from this spec will then be applied to a FlatNestedMockConfig. // The decoded values from this spec will then be applied to a FlatNestedMockConfig.
func (*FlatNestedMockConfig) HCL2Spec() map[string]hcldec.Spec { func (*FlatNestedMockConfig) HCL2Spec() map[string]hcldec.Spec {
s := map[string]hcldec.Spec{ s := map[string]hcldec.Spec{
"string": &hcldec.AttrSpec{Name: "string", Type: cty.String, Required: false}, "string": &hcldec.AttrSpec{Name: "string", Type: cty.String, Required: false},
"int": &hcldec.AttrSpec{Name: "int", Type: cty.Number, Required: false}, "int": &hcldec.AttrSpec{Name: "int", Type: cty.Number, Required: false},
"int64": &hcldec.AttrSpec{Name: "int64", Type: cty.Number, Required: false}, "int64": &hcldec.AttrSpec{Name: "int64", Type: cty.Number, Required: false},
"bool": &hcldec.AttrSpec{Name: "bool", Type: cty.Bool, Required: false}, "bool": &hcldec.AttrSpec{Name: "bool", Type: cty.Bool, Required: false},
"trilean": &hcldec.AttrSpec{Name: "trilean", Type: cty.Bool, Required: false}, "trilean": &hcldec.AttrSpec{Name: "trilean", Type: cty.Bool, Required: false},
"duration": &hcldec.AttrSpec{Name: "duration", Type: cty.String, Required: false}, "duration": &hcldec.AttrSpec{Name: "duration", Type: cty.String, Required: false},
"map_string_string": &hcldec.BlockAttrsSpec{TypeName: "map_string_string", ElementType: cty.String, Required: false}, "map_string_string": &hcldec.BlockAttrsSpec{TypeName: "map_string_string", ElementType: cty.String, Required: false},
"slice_string": &hcldec.AttrSpec{Name: "slice_string", Type: cty.List(cty.String), Required: false}, "slice_string": &hcldec.AttrSpec{Name: "slice_string", Type: cty.List(cty.String), Required: false},
"named_map_string_string": &hcldec.BlockAttrsSpec{TypeName: "named_map_string_string", ElementType: cty.String, Required: false},
"named_string": &hcldec.AttrSpec{Name: "named_string", Type: cty.String, Required: false},
} }
return s return s
} }