hcl2template

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package hcl2template defines code to parse hcl2 template files correctly.

In order to configure a packer builder,provisioner,communicator and post processor.

Checkout the files in testdata/complete/ to see what a packer config could look like.

Code generated by "mapstructure-to-hcl2 -type MockConfig,NestedMockConfig"; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildBlock added in v1.5.0

type BuildBlock struct {
	ProvisionerBlocks []*ProvisionerBlock

	PostProcessors []*PostProcessorBlock

	Froms []SourceRef

	HCL2Ref HCL2Ref
}

type Builds

type Builds []*BuildBlock

type Decodable

type Decodable interface {
	ConfigSpec() hcldec.ObjectSpec
}

type FlatMockConfig added in v1.5.0

type FlatMockConfig struct {
	String          *string                `mapstructure:"string" cty:"string"`
	Int             *int                   `mapstructure:"int" cty:"int"`
	Int64           *int64                 `mapstructure:"int64" cty:"int64"`
	Bool            *bool                  `mapstructure:"bool" cty:"bool"`
	Trilean         *bool                  `mapstructure:"trilean" cty:"trilean"`
	Duration        *string                `mapstructure:"duration" cty:"duration"`
	MapStringString map[string]string      `mapstructure:"map_string_string" cty:"map_string_string"`
	SliceString     []string               `mapstructure:"slice_string" cty:"slice_string"`
	Nested          *FlatNestedMockConfig  `mapstructure:"nested" cty:"nested"`
	NestedSlice     []FlatNestedMockConfig `mapstructure:"nested_slice" cty:"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.5.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 FlatNestedMockConfig added in v1.5.0

type FlatNestedMockConfig struct {
	String          *string           `mapstructure:"string" cty:"string"`
	Int             *int              `mapstructure:"int" cty:"int"`
	Int64           *int64            `mapstructure:"int64" cty:"int64"`
	Bool            *bool             `mapstructure:"bool" cty:"bool"`
	Trilean         *bool             `mapstructure:"trilean" cty:"trilean"`
	Duration        *string           `mapstructure:"duration" cty:"duration"`
	MapStringString map[string]string `mapstructure:"map_string_string" cty:"map_string_string"`
	SliceString     []string          `mapstructure:"slice_string" cty:"slice_string"`
}

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.5.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 HCL2Ref

type HCL2Ref struct {
	// reference to the source definition in configuration text file
	DeclRange hcl.Range

	// remainder of unparsed body
	Remain hcl.Body
}

reference to the source definition in configuration text file

type MockBuilder added in v1.5.0

type MockBuilder struct {
	Config MockConfig
}

func (*MockBuilder) ConfigSpec added in v1.5.0

func (b *MockBuilder) ConfigSpec() hcldec.ObjectSpec

func (*MockBuilder) Prepare added in v1.5.0

func (b *MockBuilder) Prepare(raws ...interface{}) ([]string, []string, error)

func (*MockBuilder) Run added in v1.5.0

func (b *MockBuilder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error)

type MockCommunicator added in v1.5.0

type MockCommunicator struct {
	Config MockConfig
	packer.Communicator
}

func (*MockCommunicator) ConfigSpec added in v1.5.0

func (b *MockCommunicator) ConfigSpec() hcldec.ObjectSpec

func (*MockCommunicator) Configure added in v1.5.0

func (b *MockCommunicator) Configure(raws ...interface{}) ([]string, error)

type MockConfig added in v1.5.0

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

func (*MockConfig) FlatMapstructure added in v1.5.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 MockPostProcessor added in v1.5.0

type MockPostProcessor struct {
	Config MockConfig
}

func (*MockPostProcessor) ConfigSpec added in v1.5.0

func (b *MockPostProcessor) ConfigSpec() hcldec.ObjectSpec

func (*MockPostProcessor) Configure added in v1.5.0

func (b *MockPostProcessor) Configure(raws ...interface{}) error

func (*MockPostProcessor) PostProcess added in v1.5.0

type MockProvisioner added in v1.5.0

type MockProvisioner struct {
	Config MockConfig
}

func (*MockProvisioner) ConfigSpec added in v1.5.0

func (b *MockProvisioner) ConfigSpec() hcldec.ObjectSpec

func (*MockProvisioner) Prepare added in v1.5.0

func (b *MockProvisioner) Prepare(raws ...interface{}) error

func (*MockProvisioner) Provision added in v1.5.0

func (b *MockProvisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ map[string]interface{}) error

type NestedMockConfig added in v1.5.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"`
}

func (*NestedMockConfig) FlatMapstructure added in v1.5.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.

type PackerConfig

type PackerConfig struct {
	Sources map[SourceRef]*Source

	Variables PackerV1Variables

	Builds Builds
}

PackerConfig represents a loaded packer config

type PackerV1Variables

type PackerV1Variables map[string]string

func (PackerV1Variables) Variables

func (variables PackerV1Variables) Variables() map[string]*template.Variable

type Parser

type Parser struct {
	*hclparse.Parser

	BuilderSchemas packer.BuilderStore

	ProvisionersSchemas packer.ProvisionerStore

	PostProcessorsSchemas packer.PostProcessorStore
}

func (*Parser) CoreBuildPostProcessors added in v1.5.0

func (p *Parser) CoreBuildPostProcessors(blocks []*PostProcessorBlock) ([]packer.CoreBuildPostProcessor, hcl.Diagnostics)

func (*Parser) CoreBuildProvisioners added in v1.5.0

func (p *Parser) CoreBuildProvisioners(blocks []*ProvisionerBlock, generatedVars []string) ([]packer.CoreBuildProvisioner, hcl.Diagnostics)

func (*Parser) Parse

func (p *Parser) Parse(path string) ([]packer.Build, hcl.Diagnostics)

func (*Parser) StartBuilder added in v1.5.0

func (p *Parser) StartBuilder(source *Source) (packer.Builder, hcl.Diagnostics, []string)

func (*Parser) StartPostProcessor added in v1.5.0

func (p *Parser) StartPostProcessor(pp *PostProcessorBlock) (packer.PostProcessor, hcl.Diagnostics)

func (*Parser) StartProvisioner added in v1.5.0

func (p *Parser) StartProvisioner(pb *ProvisionerBlock, generatedVars []string) (packer.Provisioner, hcl.Diagnostics)

type PostProcessorBlock added in v1.5.0

type PostProcessorBlock struct {
	PType string
	// contains filtered or unexported fields
}

PostProcessorBlock represents a parsed PostProcessorBlock

type ProvisionerBlock added in v1.5.0

type ProvisionerBlock struct {
	PType string
	// contains filtered or unexported fields
}

ProvisionerBlock represents a parsed provisioner

type Source

type Source struct {
	// Type of source; ex: virtualbox-iso
	Type string
	// Given name; if any
	Name string
	// contains filtered or unexported fields
}

A source field in an HCL file will load into the Source type.

func (*Source) Ref

func (source *Source) Ref() SourceRef

type SourceRef

type SourceRef struct {
	Type string
	Name string
}
var NoSource SourceRef

NoSource is the zero value of sourceRef, representing the absense of an source.

func (SourceRef) String

func (r SourceRef) String() string

Jump to

Keyboard shortcuts

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