Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2025 License: MPL-2.0 Imports: 15 Imported by: 292

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDecodeHookFuncs = []mapstructure.DecodeHookFunc{
	uint8ToStringHook,
	stringToTrilean,
	mapstructure.StringToSliceHookFunc(","),
	mapstructure.StringToTimeDurationHookFunc(),
}
View Source
var DeprecatedOptions = map[string][]string{
	"*":                                   []string{"iso_md5", "ssh_key_path", "ssh_disable_agent", "ssh_host_port_min", "ssh_host_port_max", "ssh_skip_nat_mapping", "ssh_wait_timeout", "iso_checksum_url", "iso_checksum_type"},
	"*amazon*":                            []string{"shutdown_behaviour", "enhanced_networking", "ssh_private_ip", "temporary_security_group_source_cidr", "clean_ami_name", "spot_price_auto_product"},
	"Azure*":                              []string{"clean_image_name", "exlude_from_latest"},
	"MSOpenTech.hyperv":                   []string{"vhd_temp_path", "clone_from_vmxc_path", "cpu", "ram_size"},
	"ansible":                             []string{"galaxycommand"},
	"hashicorp.scaleway":                  []string{"access_key"},
	"jetbrains.vsphere":                   []string{"network_card", "network", "networkCard", "disk_size", "disk_thin_provisioned", "disk_eagerly_scrub"},
	"mitchellh.virtualbox":                []string{"guest_additions_attach"},
	"packer.docker":                       []string{"login_email"},
	"packer.googlecompute":                []string{"clean_image_name"},
	"packer.parallels":                    []string{"headless", "parallels_tools_host_path", "guest_os_distribution"},
	"packer.post-processor.docker-import": []string{"login_email"},
	"packer.post-processor.docker-tag":    []string{"tag"},
	"packer.post-processor.manifest":      []string{"filename"},
	"transcend.qemu":                      []string{"ssh_host_port_max", "ssh_host_port_min"},
}

Functions

func Decode

func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error

Decode decodes the configuration into the target and optionally automatically interpolates all the configuration as it goes.

func DetectContext

func DetectContext(raws ...interface{}) (*interpolate.Context, error)

DetectContext builds a base interpolate.Context, automatically detecting things like user variables from the raw configuration params.

func DetectContextData

func DetectContextData(raws ...interface{}) (map[interface{}]interface{}, []interface{})

Types

type DecodeOpts

type DecodeOpts struct {
	// Metadata, if non-nil, will be set to the metadata post-decode
	Metadata *mapstructure.Metadata

	// Interpolate, if true, will automatically interpolate the
	// configuration with the given InterpolateContext. User variables
	// will be automatically detected and added in-place to the given
	// context.
	Interpolate        bool
	InterpolateContext *interpolate.Context
	InterpolateFilter  *interpolate.RenderFilter

	// PluginType is the BuilderID, etc of the plugin -- it is used to
	// determine whether to tell the user to "fix" their template if an
	// unknown option is a deprecated one for this plugin type.
	PluginType string

	DecodeHooks []mapstructure.DecodeHookFunc
}

DecodeOpts are the options for decoding configuration.

type FlatKeyValue

type FlatKeyValue struct {
	Key   *string `cty:"key" hcl:"key"`
	Value *string `cty:"value" hcl:"value"`
}

FlatKeyValue is an auto-generated flat version of KeyValue. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatKeyValue) HCL2Spec

func (*FlatKeyValue) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a KeyValue. This spec is used by HCL to read the fields of KeyValue. The decoded values from this spec will then be applied to a FlatKeyValue.

type FlatKeyValueFilter

type FlatKeyValueFilter struct {
	Filters map[string]string `cty:"filters" hcl:"filters"`
	Filter  []FlatKeyValue    `cty:"filter" hcl:"filter"`
}

FlatKeyValueFilter is an auto-generated flat version of KeyValueFilter. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatKeyValueFilter) HCL2Spec

func (*FlatKeyValueFilter) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a KeyValueFilter. This spec is used by HCL to read the fields of KeyValueFilter. The decoded values from this spec will then be applied to a FlatKeyValueFilter.

type FlatNameValue

type FlatNameValue struct {
	Name  *string `cty:"name" hcl:"name"`
	Value *string `cty:"value" hcl:"value"`
}

FlatNameValue is an auto-generated flat version of NameValue. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatNameValue) HCL2Spec

func (*FlatNameValue) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a NameValue. This spec is used by HCL to read the fields of NameValue. The decoded values from this spec will then be applied to a FlatNameValue.

type FlatNameValueFilter

type FlatNameValueFilter struct {
	Filters map[string]string `cty:"filters" hcl:"filters"`
	Filter  []FlatNameValue   `cty:"filter" hcl:"filter"`
}

FlatNameValueFilter is an auto-generated flat version of NameValueFilter. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatNameValueFilter) HCL2Spec

func (*FlatNameValueFilter) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a NameValueFilter. This spec is used by HCL to read the fields of NameValueFilter. The decoded values from this spec will then be applied to a FlatNameValueFilter.

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

These are used to convert HCL blocks to key-value pairs

func (*KeyValue) FlatMapstructure

func (*KeyValue) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatKeyValue. FlatKeyValue is an auto-generated flat version of KeyValue. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type KeyValueFilter

type KeyValueFilter struct {
	Filters map[string]string
	Filter  KeyValues
}

func (*KeyValueFilter) Empty

func (kvf *KeyValueFilter) Empty() bool

func (*KeyValueFilter) FlatMapstructure

func (*KeyValueFilter) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatKeyValueFilter. FlatKeyValueFilter is an auto-generated flat version of KeyValueFilter. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*KeyValueFilter) Prepare

func (kvf *KeyValueFilter) Prepare() []error

type KeyValues

type KeyValues []KeyValue

func (KeyValues) CopyOn

func (kvs KeyValues) CopyOn(to *map[string]string) []error

type NameValue

type NameValue struct {
	Name  string
	Value string
}

func (*NameValue) FlatMapstructure

func (*NameValue) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatNameValue. FlatNameValue is an auto-generated flat version of NameValue. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type NameValueFilter

type NameValueFilter struct {
	Filters map[string]string
	Filter  NameValues
}

func (*NameValueFilter) Empty

func (nvf *NameValueFilter) Empty() bool

func (*NameValueFilter) FlatMapstructure

func (*NameValueFilter) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatNameValueFilter. FlatNameValueFilter is an auto-generated flat version of NameValueFilter. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*NameValueFilter) Prepare

func (nvf *NameValueFilter) Prepare() []error

type NameValues

type NameValues []NameValue

func (NameValues) CopyOn

func (nvs NameValues) CopyOn(to *map[string]string) []error

type Trilean

type Trilean uint8
const (
	// This will assign unset to 0, which is the default value in interpolation
	TriUnset Trilean = iota
	TriTrue
	TriFalse
)

func TrileanFromBool

func TrileanFromBool(b bool) Trilean

func TrileanFromString

func TrileanFromString(s string) (Trilean, error)

func (Trilean) False

func (t Trilean) False() bool

func (Trilean) ToBoolPointer

func (t Trilean) ToBoolPointer() *bool

func (Trilean) ToString

func (t Trilean) ToString() string

func (Trilean) True

func (t Trilean) True() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL