Documentation ¶
Index ¶
- type Attribute
- type Attributes
- type Block
- type File
- func (file *File) Blocks(name string, isMultipleAllowed bool) ([]*Block, error)
- func (file *File) Content() string
- func (file *File) Decode(out interface{}, evalContext *hcl.EvalContext) (err error)
- func (file *File) JustAttributes() (Attributes, error)
- func (file *File) Update(content []byte) error
- type Option
- type PanicWhileParsingConfigError
- type Parser
- func (parser *Parser) ParseFromBytes(content []byte, configPath string) (file *File, err error)
- func (parser *Parser) ParseFromFile(configPath string) (*File, error)
- func (parser *Parser) ParseFromString(content, configPath string) (file *File, err error)
- func (parser *Parser) WithOptions(opts ...Option) *Parser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct { *File *hcl.Attribute }
func (*Attribute) ValidateIdentifier ¶
type Attributes ¶
type Attributes []*Attribute
func NewAttributes ¶
func NewAttributes(file *File, hclAttrs hcl.Attributes) Attributes
func (Attributes) ValidateIdentifier ¶
func (attrs Attributes) ValidateIdentifier() error
type Block ¶
type Block struct { *File *hcl.Block }
func (*Block) JustAttributes ¶
func (block *Block) JustAttributes() (Attributes, error)
GetAttrs loads the block into name expression pairs to assist with evaluation of the attrs prior to evaluating the whole config. Note that this is exactly the same as terraform/configs/named_values.go:decodeLocalsBlock
type File ¶
func (*File) Blocks ¶
GetBlock takes a parsed HCL file and extracts a reference to the `name` block, if there are defined.
func (*File) Decode ¶
Decode uses the HCL2 parser to decode the parsed HCL into the struct specified by out.
Note that we take a two pass approach to support parsing include blocks without a label. Ideally we can parse include blocks with and without labels in a single pass, but the HCL parser is fairly restrictive when it comes to parsing blocks with labels, requiring the exact number of expected labels in the parsing step. To handle this restriction, we first see if there are any include blocks without any labels, and if there is, we modify it in the file object to inject the label as "".
func (*File) JustAttributes ¶
func (file *File) JustAttributes() (Attributes, error)
type Option ¶
func WithFileUpdate ¶
WithFileUpdate sets the `fileUpdateHandlerFunc` func which is run before each file decoding.
func WithHaltOnErrorOnlyForBlocks ¶
WithHaltOnErrorOnlyForBlocks configures a diagnostic error handler that runs when diagnostic errors occur. If errors occur in the given `blockNames` blocks, parser returns the error to its caller, otherwise it skips the error.
func WithLogger ¶
type PanicWhileParsingConfigError ¶
type PanicWhileParsingConfigError struct { ConfigFile string RecoveredValue interface{} }
func (PanicWhileParsingConfigError) Error ¶
func (err PanicWhileParsingConfigError) Error() string
type Parser ¶
func (*Parser) ParseFromBytes ¶
func (*Parser) ParseFromFile ¶
func (*Parser) ParseFromString ¶
ParseFromString uses the HCL2 parser to parse the given string into an HCL file body.