40947c2bf6
This will allow to generate the config files: ```go package main import ( "fmt" "github.com/hashicorp/hcl/v2/gohcl" "github.com/hashicorp/hcl/v2/hclwrite" "github.com/hashicorp/packer/builder/alicloud/ecs" ) func main() { name := "name" app := ecs.FlatConfig{ AlicloudImageName: &name, ECSSystemDiskMapping: &ecs.FlatAlicloudDiskDevice{ DiskName: &name, }, } f := hclwrite.NewEmptyFile() block := gohcl.EncodeAsBlock(&app, `source "something" "something"`) f.Body().AppendBlock(block) fmt.Printf("%s", f.Bytes()) } ``` Will output: ``` source "something" "something" { packer_user_variables = null packer_sensitive_variables = null image_name = "name" image_share_account = null image_unshare_account = null image_copy_regions = null image_copy_names = null tags = null tag = null system_disk_mapping = { disk_category = null, disk_delete_with_instance = null, disk_descri ption = null, disk_device = null, disk_encrypted = null, disk_name = "name", disk_size = null, disk_ snapshot_id = null } image_disk_mappings = null ssh_remote_tunnels = null ssh_local_tunnels = null ssh_public_key = null ssh_private_key = null } ``` This is a good first step for #9015 and #9282 fix #9304
129 lines
8.5 KiB
Go
129 lines
8.5 KiB
Go
// Code generated by "mapstructure-to-hcl2 -type MockConfig,NestedMockConfig,MockTag"; DO NOT EDIT.
|
|
package hcl2template
|
|
|
|
import (
|
|
"github.com/hashicorp/hcl/v2/hcldec"
|
|
"github.com/zclconf/go-cty/cty"
|
|
)
|
|
|
|
// FlatMockConfig is an auto-generated flat version of MockConfig.
|
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
|
type FlatMockConfig struct {
|
|
NotSquashed *string `mapstructure:"not_squashed" cty:"not_squashed" hcl:"not_squashed"`
|
|
String *string `mapstructure:"string" cty:"string" hcl:"string"`
|
|
Int *int `mapstructure:"int" cty:"int" hcl:"int"`
|
|
Int64 *int64 `mapstructure:"int64" cty:"int64" hcl:"int64"`
|
|
Bool *bool `mapstructure:"bool" cty:"bool" hcl:"bool"`
|
|
Trilean *bool `mapstructure:"trilean" cty:"trilean" hcl:"trilean"`
|
|
Duration *string `mapstructure:"duration" cty:"duration" hcl:"duration"`
|
|
MapStringString map[string]string `mapstructure:"map_string_string" cty:"map_string_string" hcl:"map_string_string"`
|
|
SliceString []string `mapstructure:"slice_string" cty:"slice_string" hcl:"slice_string"`
|
|
SliceSliceString [][]string `mapstructure:"slice_slice_string" cty:"slice_slice_string" hcl:"slice_slice_string"`
|
|
NamedMapStringString NamedMapStringString `mapstructure:"named_map_string_string" cty:"named_map_string_string" hcl:"named_map_string_string"`
|
|
NamedString *NamedString `mapstructure:"named_string" cty:"named_string" hcl:"named_string"`
|
|
Tags []FlatMockTag `mapstructure:"tag" cty:"tag" hcl:"tag"`
|
|
Nested *FlatNestedMockConfig `mapstructure:"nested" cty:"nested" hcl:"nested"`
|
|
NestedSlice []FlatNestedMockConfig `mapstructure:"nested_slice" cty:"nested_slice" hcl:"nested_slice"`
|
|
}
|
|
|
|
// FlatMapstructure returns a new FlatMockConfig.
|
|
// FlatMockConfig is an auto-generated flat version of MockConfig.
|
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
|
func (*MockConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
|
return new(FlatMockConfig)
|
|
}
|
|
|
|
// HCL2Spec returns the hcl spec of a MockConfig.
|
|
// This spec is used by HCL to read the fields of MockConfig.
|
|
// The decoded values from this spec will then be applied to a FlatMockConfig.
|
|
func (*FlatMockConfig) HCL2Spec() map[string]hcldec.Spec {
|
|
s := map[string]hcldec.Spec{
|
|
"not_squashed": &hcldec.AttrSpec{Name: "not_squashed", 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},
|
|
"int64": &hcldec.AttrSpec{Name: "int64", Type: cty.Number, Required: false},
|
|
"bool": &hcldec.AttrSpec{Name: "bool", 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},
|
|
"map_string_string": &hcldec.AttrSpec{Name: "map_string_string", Type: cty.Map(cty.String), Required: false},
|
|
"slice_string": &hcldec.AttrSpec{Name: "slice_string", Type: cty.List(cty.String), Required: false},
|
|
"slice_slice_string": &hcldec.AttrSpec{Name: "slice_slice_string", Type: cty.List(cty.List(cty.String)), Required: false},
|
|
"named_map_string_string": &hcldec.AttrSpec{Name: "named_map_string_string", Type: cty.Map(cty.String), Required: false},
|
|
"named_string": &hcldec.AttrSpec{Name: "named_string", Type: cty.String, Required: false},
|
|
"tag": &hcldec.BlockListSpec{TypeName: "tag", Nested: hcldec.ObjectSpec((*FlatMockTag)(nil).HCL2Spec())},
|
|
"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
|
|
}
|
|
|
|
// FlatMockTag is an auto-generated flat version of MockTag.
|
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
|
type FlatMockTag struct {
|
|
Key *string `mapstructure:"key" cty:"key" hcl:"key"`
|
|
Value *string `mapstructure:"value" cty:"value" hcl:"value"`
|
|
}
|
|
|
|
// FlatMapstructure returns a new FlatMockTag.
|
|
// FlatMockTag is an auto-generated flat version of MockTag.
|
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
|
func (*MockTag) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
|
return new(FlatMockTag)
|
|
}
|
|
|
|
// HCL2Spec returns the hcl spec of a MockTag.
|
|
// This spec is used by HCL to read the fields of MockTag.
|
|
// The decoded values from this spec will then be applied to a FlatMockTag.
|
|
func (*FlatMockTag) HCL2Spec() map[string]hcldec.Spec {
|
|
s := map[string]hcldec.Spec{
|
|
"key": &hcldec.AttrSpec{Name: "key", Type: cty.String, Required: false},
|
|
"value": &hcldec.AttrSpec{Name: "value", Type: cty.String, Required: false},
|
|
}
|
|
return s
|
|
}
|
|
|
|
// FlatNestedMockConfig is an auto-generated flat version of NestedMockConfig.
|
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
|
type FlatNestedMockConfig struct {
|
|
String *string `mapstructure:"string" cty:"string" hcl:"string"`
|
|
Int *int `mapstructure:"int" cty:"int" hcl:"int"`
|
|
Int64 *int64 `mapstructure:"int64" cty:"int64" hcl:"int64"`
|
|
Bool *bool `mapstructure:"bool" cty:"bool" hcl:"bool"`
|
|
Trilean *bool `mapstructure:"trilean" cty:"trilean" hcl:"trilean"`
|
|
Duration *string `mapstructure:"duration" cty:"duration" hcl:"duration"`
|
|
MapStringString map[string]string `mapstructure:"map_string_string" cty:"map_string_string" hcl:"map_string_string"`
|
|
SliceString []string `mapstructure:"slice_string" cty:"slice_string" hcl:"slice_string"`
|
|
SliceSliceString [][]string `mapstructure:"slice_slice_string" cty:"slice_slice_string" hcl:"slice_slice_string"`
|
|
NamedMapStringString NamedMapStringString `mapstructure:"named_map_string_string" cty:"named_map_string_string" hcl:"named_map_string_string"`
|
|
NamedString *NamedString `mapstructure:"named_string" cty:"named_string" hcl:"named_string"`
|
|
Tags []FlatMockTag `mapstructure:"tag" cty:"tag" hcl:"tag"`
|
|
}
|
|
|
|
// FlatMapstructure returns a new FlatNestedMockConfig.
|
|
// FlatNestedMockConfig is an auto-generated flat version of NestedMockConfig.
|
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
|
func (*NestedMockConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
|
return new(FlatNestedMockConfig)
|
|
}
|
|
|
|
// HCL2Spec returns the hcl spec of a NestedMockConfig.
|
|
// This spec is used by HCL to read the fields of NestedMockConfig.
|
|
// The decoded values from this spec will then be applied to a FlatNestedMockConfig.
|
|
func (*FlatNestedMockConfig) HCL2Spec() map[string]hcldec.Spec {
|
|
s := map[string]hcldec.Spec{
|
|
"string": &hcldec.AttrSpec{Name: "string", Type: cty.String, Required: false},
|
|
"int": &hcldec.AttrSpec{Name: "int", 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},
|
|
"trilean": &hcldec.AttrSpec{Name: "trilean", Type: cty.Bool, Required: false},
|
|
"duration": &hcldec.AttrSpec{Name: "duration", Type: cty.String, Required: false},
|
|
"map_string_string": &hcldec.AttrSpec{Name: "map_string_string", Type: cty.Map(cty.String), Required: false},
|
|
"slice_string": &hcldec.AttrSpec{Name: "slice_string", Type: cty.List(cty.String), Required: false},
|
|
"slice_slice_string": &hcldec.AttrSpec{Name: "slice_slice_string", Type: cty.List(cty.List(cty.String)), Required: false},
|
|
"named_map_string_string": &hcldec.AttrSpec{Name: "named_map_string_string", Type: cty.Map(cty.String), Required: false},
|
|
"named_string": &hcldec.AttrSpec{Name: "named_string", Type: cty.String, Required: false},
|
|
"tag": &hcldec.BlockListSpec{TypeName: "tag", Nested: hcldec.ObjectSpec((*FlatMockTag)(nil).HCL2Spec())},
|
|
}
|
|
return s
|
|
}
|