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 ¶
func (attr *Attribute) ValidateIdentifier() error
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 ¶
type File struct {
*Parser
*hcl.File
ConfigPath string
}
func (*File) Blocks ¶
func (file *File) Blocks(name string, isMultipleAllowed bool) ([]*Block, error)
GetBlock takes a parsed HCL file and extracts a reference to the `name` block, if there are defined.
func (*File) Decode ¶
func (file *File) Decode(out interface{}, evalContext *hcl.EvalContext) (err error)
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 *File) HandleDiagnostics(diags hcl.Diagnostics) error
func (*File) JustAttributes ¶
func (file *File) JustAttributes() (Attributes, error)
type Option ¶
type Option func(*Parser) *Parser
func WithDiagnosticsHandler ¶ added in v0.61.0
func WithDiagnosticsHandler(fn func(file *hcl.File, diags hcl.Diagnostics) (hcl.Diagnostics, error)) Option
func WithDiagnosticsWriter ¶ added in v0.62.2
func WithDiagnosticsWriter(writer io.Writer, disableColor bool) Option
func WithFileUpdate ¶
func WithFileUpdate(fn func(*File) error) Option
WithFileUpdate sets the `fileUpdateHandlerFunc` func which is run before each file decoding.
func WithHaltOnErrorOnlyForBlocks ¶
func WithHaltOnErrorOnlyForBlocks(blockNames []string) Option
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 ¶
func WithLogger(logger log.Logger) Option
type PanicWhileParsingConfigError ¶
type PanicWhileParsingConfigError struct {
ConfigFile string
RecoveredValue interface{}
}
type Parser ¶
type Parser struct {
*hclparse.Parser
// contains filtered or unexported fields
}
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.
func (*Parser) ParseFromBytes ¶
func (parser *Parser) ParseFromBytes(content []byte, configPath string) (file *File, err error)
func (*Parser) ParseFromFile ¶
func (parser *Parser) ParseFromFile(configPath string) (*File, error)
func (*Parser) ParseFromString ¶
func (parser *Parser) ParseFromString(content, configPath string) (file *File, err error)
ParseFromString uses the HCL2 parser to parse the given string into an HCL file body.