hcl2shim

package
v1.7.9 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigValueFromHCL2

func ConfigValueFromHCL2(v cty.Value) interface{}

ConfigValueFromHCL2 converts a value from HCL2 (really, from the cty dynamic types library that HCL2 uses) to a value type that matches what would've been produced from the HCL-based interpolator for an equivalent structure.

This function will transform a cty null value into a Go nil value, which isn't a possible outcome of the HCL/HIL-based decoder and so callers may need to detect and reject any null values.

func WriteUnknownPlaceholderValues added in v1.7.0

func WriteUnknownPlaceholderValues(v cty.Value) cty.Value

WriteUnknownPlaceholderValues will replace every Unknown value with a equivalent placeholder. This is useful to use before marshaling the value to JSON. The default values are: - string: "<unknown>" - number: 0 - bool: false - objects/lists/tuples/sets/maps: empty

Types

type FlatMockConfig added in v1.7.0

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"`
	Datasource           *string                `mapstructure:"data_source" cty:"data_source" hcl:"data_source"`
	Nested               *FlatNestedMockConfig  `mapstructure:"nested" cty:"nested" hcl:"nested"`
	NestedSlice          []FlatNestedMockConfig `mapstructure:"nested_slice" cty:"nested_slice" hcl:"nested_slice"`
}

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

func (*FlatMockConfig) HCL2Spec added in v1.7.0

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

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.

type FlatMockTag added in v1.7.0

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

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

func (*FlatMockTag) HCL2Spec added in v1.7.0

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

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.

type FlatNestedMockConfig added in v1.7.0

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"`
	Datasource           *string              `mapstructure:"data_source" cty:"data_source" hcl:"data_source"`
}

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

func (*FlatNestedMockConfig) HCL2Spec added in v1.7.0

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

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.

type MockConfig added in v1.7.0

type MockConfig struct {
	NotSquashed      string `mapstructure:"not_squashed"`
	NestedMockConfig `mapstructure:",squash"`
	Nested           NestedMockConfig   `mapstructure:"nested"`
	NestedSlice      []NestedMockConfig `mapstructure:"nested_slice"`
}

func (*MockConfig) FlatMapstructure added in v1.7.0

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

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.

type MockTag added in v1.7.0

type MockTag struct {
	Key   string `mapstructure:"key"`
	Value string `mapstructure:"value"`
}

func (*MockTag) FlatMapstructure added in v1.7.0

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

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.

type NamedMapStringString added in v1.7.0

type NamedMapStringString map[string]string

type NamedString added in v1.7.0

type NamedString string

type NestedMockConfig added in v1.7.0

type NestedMockConfig struct {
	String               string               `mapstructure:"string"`
	Int                  int                  `mapstructure:"int"`
	Int64                int64                `mapstructure:"int64"`
	Bool                 bool                 `mapstructure:"bool"`
	Trilean              config.Trilean       `mapstructure:"trilean"`
	Duration             time.Duration        `mapstructure:"duration"`
	MapStringString      map[string]string    `mapstructure:"map_string_string"`
	SliceString          []string             `mapstructure:"slice_string"`
	SliceSliceString     [][]string           `mapstructure:"slice_slice_string"`
	NamedMapStringString NamedMapStringString `mapstructure:"named_map_string_string"`
	NamedString          NamedString          `mapstructure:"named_string"`
	Tags                 []MockTag            `mapstructure:"tag"`
	Datasource           string               `mapstructure:"data_source"`
}

func (*NestedMockConfig) FlatMapstructure added in v1.7.0

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

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.

Jump to

Keyboard shortcuts

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