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.
Index ¶
- type Artifact
- type ArtifactRef
- type Artifacts
- type Build
- type BuildFrom
- type BuildFromList
- type Builds
- type Communicator
- type CommunicatorRef
- type Decodable
- type HCL2Ref
- type PackerConfig
- type PackerV1Build
- type PackerV1Variables
- type Parser
- type Provisioner
- type ProvisionerGroup
- type ProvisionerGroups
- type SelfSpecified
- type Source
- type SourceRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArtifactRef ¶
var NoArtifact ArtifactRef
NoArtifact is the zero value of ArtifactRef, representing the absense of an artifact.
func (ArtifactRef) String ¶
func (r ArtifactRef) String() string
type Artifacts ¶
type Artifacts map[ArtifactRef]*Artifact
type Build ¶
type Build struct {
// Ordered list of provisioner groups
ProvisionerGroups ProvisionerGroups
// Ordered list of post-provisioner groups
PostProvisionerGroups ProvisionerGroups
// Ordered list of output stanzas
Froms BuildFromList
HCL2Ref HCL2Ref
}
type BuildFromList ¶
type BuildFromList []BuildFrom
type Communicator ¶
type Communicator struct {
// Type of communicator; ex: ssh
Type string
// Given name
Name string
Cfg interface{}
HCL2Ref HCL2Ref
}
func (*Communicator) Ref ¶
func (communicator *Communicator) Ref() CommunicatorRef
type CommunicatorRef ¶
var NoCommunicator CommunicatorRef
NoCommunicator is the zero value of CommunicatorRef, representing the absense of Communicator.
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 PackerConfig ¶
type PackerConfig struct {
Sources map[SourceRef]*Source
Variables PackerV1Variables
Builds Builds
Communicators map[CommunicatorRef]*Communicator
}
PackerConfig represents a loaded packer config
func (*PackerConfig) ToTemplate ¶
func (pkrCfg *PackerConfig) ToTemplate() (*template.Template, error)
func (*PackerConfig) ToV1Build ¶
func (pkrCfg *PackerConfig) ToV1Build() PackerV1Build
type PackerV1Build ¶
type PackerV1Build struct {
Builders []*template.Builder
Provisioners []*template.Provisioner
PostProcessors []*template.PostProcessor
}
type PackerV1Variables ¶
type Parser ¶
type Parser struct {
*hclparse.Parser
ProvisionersSchemas map[string]Decodable
PostProvisionersSchemas map[string]Decodable
CommunicatorSchemas map[string]Decodable
SourceSchemas map[string]Decodable
}
func (*Parser) Parse ¶
func (p *Parser) Parse(filename string) (*PackerConfig, hcl.Diagnostics)
func (*Parser) ParseFile ¶
func (p *Parser) ParseFile(f *hcl.File, cfg *PackerConfig) hcl.Diagnostics
ParseFile filename content into cfg.
ParseFile may be called multiple times with the same cfg on a different file.
ParseFile returns as complete a config as we can manage, even if there are errors, since a partial result can be useful for careful analysis by development tools such as text editor extensions.
type Provisioner ¶
type Provisioner struct {
// Cfg is a parsed config
Cfg interface{}
}
Provisioner represents a parsed provisioner
type ProvisionerGroup ¶
type ProvisionerGroup struct {
CommunicatorRef CommunicatorRef
Provisioners []Provisioner
HCL2Ref HCL2Ref
}
type ProvisionerGroups ¶
type ProvisionerGroups []*ProvisionerGroup
ProvisionerGroups is a slice of provision blocks; which contains provisioners
func (ProvisionerGroups) FirstCommunicatorRef ¶
func (pgs ProvisionerGroups) FirstCommunicatorRef() CommunicatorRef