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
39 lines
1.8 KiB
Go
39 lines
1.8 KiB
Go
// Code generated by "mapstructure-to-hcl2 -type CloneConfig"; DO NOT EDIT.
|
|
package clone
|
|
|
|
import (
|
|
"github.com/hashicorp/hcl/v2/hcldec"
|
|
"github.com/zclconf/go-cty/cty"
|
|
)
|
|
|
|
// FlatCloneConfig is an auto-generated flat version of CloneConfig.
|
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
|
type FlatCloneConfig struct {
|
|
Template *string `mapstructure:"template" cty:"template" hcl:"template"`
|
|
DiskSize *int64 `mapstructure:"disk_size" cty:"disk_size" hcl:"disk_size"`
|
|
LinkedClone *bool `mapstructure:"linked_clone" cty:"linked_clone" hcl:"linked_clone"`
|
|
Network *string `mapstructure:"network" cty:"network" hcl:"network"`
|
|
Notes *string `mapstructure:"notes" cty:"notes" hcl:"notes"`
|
|
}
|
|
|
|
// FlatMapstructure returns a new FlatCloneConfig.
|
|
// FlatCloneConfig is an auto-generated flat version of CloneConfig.
|
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
|
func (*CloneConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
|
return new(FlatCloneConfig)
|
|
}
|
|
|
|
// HCL2Spec returns the hcl spec of a CloneConfig.
|
|
// This spec is used by HCL to read the fields of CloneConfig.
|
|
// The decoded values from this spec will then be applied to a FlatCloneConfig.
|
|
func (*FlatCloneConfig) HCL2Spec() map[string]hcldec.Spec {
|
|
s := map[string]hcldec.Spec{
|
|
"template": &hcldec.AttrSpec{Name: "template", Type: cty.String, Required: false},
|
|
"disk_size": &hcldec.AttrSpec{Name: "disk_size", Type: cty.Number, Required: false},
|
|
"linked_clone": &hcldec.AttrSpec{Name: "linked_clone", Type: cty.Bool, Required: false},
|
|
"network": &hcldec.AttrSpec{Name: "network", Type: cty.String, Required: false},
|
|
"notes": &hcldec.AttrSpec{Name: "notes", Type: cty.String, Required: false},
|
|
}
|
|
return s
|
|
}
|