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) HandleDiagnostics(diags hcl.Diagnostics) error
- func (file *File) JustAttributes() (Attributes, error)
- func (file *File) Update(content []byte) error
- type Option
- func WithDiagnosticsHandler(fn func(file *hcl.File, diags hcl.Diagnostics) (hcl.Diagnostics, error)) Option
- func WithDiagnosticsWriter(writer io.Writer, disableColor bool) Option
- func WithFileUpdate(fn func(*File) error) Option
- func WithHaltOnErrorOnlyForBlocks(blockNames []string) Option
- func WithLogger(logger log.Logger) Option
- type PanicWhileParsingConfigError
- type Parser
- func (parser *Parser) GetDiagnosticsWriter(writer io.Writer, disableColor bool) hcl.DiagnosticWriter
- 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)
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) Range ¶ added in v0.61.0
func (attrs Attributes) Range() hcl.Range
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) HandleDiagnostics ¶ added in v0.61.0
func (*File) JustAttributes ¶
func (file *File) JustAttributes() (Attributes, error)
type Option ¶
func WithDiagnosticsHandler ¶ added in v0.61.0
func WithDiagnosticsWriter ¶ added in v0.62.2
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) GetDiagnosticsWriter ¶ added in v0.67.5
func (parser *Parser) GetDiagnosticsWriter(writer io.Writer, disableColor bool) hcl.DiagnosticWriter
GetDiagnosticsWriter returns a hcl2 parsing diagnostics emitter for the current terminal.