Documentation
¶
Overview ¶
Documentable wrapper types form
Index ¶
- func DecodeAndEvalAttr(ctx context.Context, hclAttr *hclsyntax.Attribute, spec *AttrSpec, ...) (val cty.Value, diags diagnostics.Diag)
- func EvalAttr(ctx context.Context, attr *Attr, dataCtx plugindata.Map) (val cty.Value, diags diagnostics.Diag)
- func EvalBlock(ctx context.Context, block *Block, dataCtx plugindata.Map) (diags diagnostics.Diag)
- func EvaluateDeferred(ctx context.Context, dataCtx plugindata.Map, val *Attr) (res cty.Value, diags diagnostics.Diag)
- func RenderDoc(spec *RootSpec, blockName string, labels ...string) string
- type Attr
- type AttrSpec
- type Attributes
- type Block
- func DecodeAndEvalBlock(ctx context.Context, block *hclsyntax.Block, rootSpec *RootSpec, ...) (res *Block, diags diagnostics.Diag)
- func DecodeBlock(ctx context.Context, block *hclsyntax.Block, rootSpec *RootSpec) (res *Block, diags diagnostics.Diag)
- func EvalBlockCopy(ctx context.Context, block *Block, dataCtx plugindata.Map) (evaluatedBlock *Block, diags diagnostics.Diag)
- func NewBlock(headers []string, attrs map[string]cty.Value, blocks ...*Block) *Blockdeprecated
- type BlockSpec
- type Blocks
- type ExactMatcher
- type HeadersSpec
- type NameMatcher
- type RootSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeAndEvalAttr ¶
func DecodeAndEvalAttr(ctx context.Context, hclAttr *hclsyntax.Attribute, spec *AttrSpec, dataCtx plugindata.Map) (val cty.Value, diags diagnostics.Diag)
DecodeAndEvalAttr decodes hclsyntax.Attribute into a Attr according to the given AttrSpec and evaluates it.
func EvalAttr ¶
func EvalAttr(ctx context.Context, attr *Attr, dataCtx plugindata.Map) (val cty.Value, diags diagnostics.Diag)
EvalAttr evaluates deferred values in the given attribute and validates it.
func EvalBlock ¶
func EvalBlock(ctx context.Context, block *Block, dataCtx plugindata.Map) (diags diagnostics.Diag)
EvalBlock evaluates deferred values in the given block and validates the attributes. WARNING: This function modifies the input block (its attributes and blocks) in place. Not suitable for evaluating deferred blocks
func EvaluateDeferred ¶
func EvaluateDeferred(ctx context.Context, dataCtx plugindata.Map, val *Attr) (res cty.Value, diags diagnostics.Diag)
EvaluateDeferred evaluates deferred values in the given attribute.
Types ¶
type Attr ¶
type Attr struct {
Name string
NameRange hcl.Range
Value cty.Value
ValueRange hcl.Range
Secret bool
// contains filtered or unexported fields
}
func DecodeAttr ¶
func DecodeAttr(ctx *hcl.EvalContext, attr *hclsyntax.Attribute, spec *AttrSpec) (val *Attr, diags diagnostics.Diag)
Decodes hclsyntax.Attribute into a cty.Value according to the given AttrSpec. No validation is performed on the value.
func (*Attr) GetStringList ¶
func (a *Attr) GetStringList() (_ []string, diags diagnostics.Diag)
type AttrSpec ¶
type AttrSpec struct {
Name string
Type cty.Type
DefaultVal cty.Value
ExampleVal cty.Value
Doc string
Constraints constraint.Constraints
// If set then value must be one of the specified values
OneOf constraint.OneOf
// For numbers - min value; for collections - min number of elements; for strings - min length
MinInclusive cty.Value
// For numbers - max value; for collections - max number of elements; for strings - max length
MaxInclusive cty.Value
// If specified – a deprecation warning would appear if an attribute is specified
Deprecated string
// If set then the value is hidden in logs
Secret bool
}
func (*AttrSpec) DocComment ¶
func (*AttrSpec) ValidateSpec ¶
func (a *AttrSpec) ValidateSpec() (diags diagnostics.Diag)
func (*AttrSpec) ValidateValue ¶
func (a *AttrSpec) ValidateValue(val cty.Value) (diags diagnostics.Diag)
type Attributes ¶
type Block ¶
type Block struct {
// Type + labels
Header []string
HeaderRanges []hcl.Range
Attrs Attributes
Blocks Blocks
// Full range of the block, between {} (inclusive)
ContentsRange hcl.Range
}
func DecodeAndEvalBlock ¶
func DecodeAndEvalBlock(ctx context.Context, block *hclsyntax.Block, rootSpec *RootSpec, dataCtx plugindata.Map) (res *Block, diags diagnostics.Diag)
Decodes hclsyntax.Block into a Block according to the given RootSpec. Deferred evaluation is performed immediatly.
func DecodeBlock ¶
func DecodeBlock(ctx context.Context, block *hclsyntax.Block, rootSpec *RootSpec) (res *Block, diags diagnostics.Diag)
Decodes hclsyntax.Block into a Block according to the given RootSpec. Basic validation is performed on the keys, values of attributes are not fully defined until deferred evaluation, so they are not type-checked in the resulting block. This function's result is expected to be processed later with EvalBlock to resolve the deferred values and validate everything.
func EvalBlockCopy ¶
func EvalBlockCopy(ctx context.Context, block *Block, dataCtx plugindata.Map) (evaluatedBlock *Block, diags diagnostics.Diag)
EvalBlockCopy evaluates deferred values in the given block and validates the attributes. The original block is not modified.
func (*Block) GetAttrChecked ¶
func (b *Block) GetAttrChecked(name string) (val *Attr, diags diagnostics.Diag)
func (*Block) GetAttrVal ¶
Attempts to get attribute value, returns cty.NilVal if it's missing
func (*Block) MissingItemRange ¶
type BlockSpec ¶
type BlockSpec struct {
Header HeadersSpec
Required bool
Repeatable bool
Doc string
Blocks []*BlockSpec
Attrs []*AttrSpec
AllowUnspecifiedBlocks bool
AllowUnspecifiedAttributes bool
}
func (*BlockSpec) ValidateSpec ¶
func (b *BlockSpec) ValidateSpec() (errs diagnostics.Diag)
func (*BlockSpec) WriteBlockDoc ¶
func (*BlockSpec) WriteBodyDoc ¶
type ExactMatcher ¶
type ExactMatcher []string
type HeadersSpec ¶
type HeadersSpec []NameMatcher
func (HeadersSpec) AsDocLabels ¶
func (hs HeadersSpec) AsDocLabels() (name string, labels []string)
type NameMatcher ¶
type RootSpec ¶
type RootSpec struct {
Doc string
Blocks []*BlockSpec
Attrs []*AttrSpec
Required bool
AllowUnspecifiedBlocks bool
AllowUnspecifiedAttributes bool
// contains filtered or unexported fields
}
A subset of BlockSpec that represents the root block.
func RootSpecFromBlock ¶
func (*RootSpec) IsRequired ¶
func (*RootSpec) ValidateSpec ¶
func (r *RootSpec) ValidateSpec() (errs diagnostics.Diag)