Documentation ¶
Index ¶
- type BlockDefinition
- type BlockRegistrar
- type Builder
- type FunctionInjector
- type InjectableFunctions
- type InjectableVariables
- type NamedBlockDefinition
- type NamedBlockDefinitions
- type Parser
- type Registrar
- func (r *Registrar) AddRegistration(reg *Registration)
- func (r *Registrar) Build() hcldec.Spec
- func (r *Registrar) Parse(body hcl.Body, ctx *hcl.EvalContext) hcl.Diagnostics
- func (r *Registrar) RegisterBlock(blockName string, blockDef BlockDefinition)
- func (r *Registrar) Registrations() []*Registration
- type Registration
- type VariableInjector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockDefinition ¶
type BlockDefinition interface { // Spec must return a hcldec.Spec instance. This will be used to parse from // the root of the schema file. Spec() hcldec.Spec }
BlockDefinition describes the methods that must be implemented by all definition packages for each root-level key.
type BlockRegistrar ¶
type BlockRegistrar interface { RegisterBlock(blockName string, blockDef BlockDefinition) AddRegistration(reg *Registration) }
BlockRegistrar registers blocks by adding the given BlockDefinition for the root blockName.
type FunctionInjector ¶
type FunctionInjector interface { BlockDefinition // Functions must return an instance of InjectableFunctions. These functions // will be passed through all BlockDefinition's that follow it allowing functions // created from this block to be available for all that follow. Functions(v cty.Value) InjectableFunctions }
FunctionInjector allows injecting functions into a hcl.EvalContext after it has been created from the BlockDefinition's Spec() result.
type InjectableFunctions ¶
InjectableFunctions is a map of function names that correspond with a cty.Function of which will be injected into the context after processing Spec()
type InjectableVariables ¶
InjectableVariables is a map of variable names that correspond with a cty.Value of which will be injected into the running context after processing Spec()
type NamedBlockDefinition ¶
type NamedBlockDefinition interface { BlockDefinition // Name must return the name of the block to be registered. Name() string }
NamedBlockDefinition describes the methods that musy be implemented by all definition packages for each root-level key when the definition can be self-registered by it's block name.
type NamedBlockDefinitions ¶
type NamedBlockDefinitions []NamedBlockDefinition
NamedBlockDefinitions represents a slice of individual NamedBlockDefinition's pre-ordered in the order they should be processed.
type Parser ¶
type Parser interface {
Parse(body hcl.Body, ctx *hcl.EvalContext) hcl.Diagnostics
}
Parser accepts an hcl.Body and a pointer to an hcl.EvalContext, parses the hcl.Body against the hcl.EvalContext and returns any returned hcl.Diagnostics.
type Registrar ¶
type Registrar struct { NextOrder int IncreaseNextOrderBy int // contains filtered or unexported fields }
Registrar allows registering many root hcldec.Spec's at a given block or argument which are all called independently allowing variables to be injected into the context after each run for variable interpolation that includes variables created from previous schema blocks or arguments.
The registrar also allows injecting functions after specific hcldec.Spec's are processed, though in general this should be avoided.
func NewRegistrar ¶
NewRegistrar creates a new Registrar instance, returning the pointer to be used for registering DefinitionBlock's.
func (*Registrar) AddRegistration ¶
func (r *Registrar) AddRegistration(reg *Registration)
AddRegistration adds a raw Registration to the slice of registered specs. When using this method directly you will be responsible for assigning the appropriate order to the registration. If the order is not placed before any blocks that might depend on variable scopes, variables will remain unknown and ultimately unvalidated.
Unknown variables may lead to an invalid Result from a Schema.
func (*Registrar) Build ¶
Build generates a full hcldec.Spec out of the registered BlockDefinition's allowing the full schema, with all blocks, to be used in a HCL parser.
func (*Registrar) Parse ¶
func (r *Registrar) Parse(body hcl.Body, ctx *hcl.EvalContext) hcl.Diagnostics
Parse handles parsing the hcl.Body against the dynamically generated hcldec.Spec from the registered BlockDefinition's.
func (*Registrar) RegisterBlock ¶
func (r *Registrar) RegisterBlock(blockName string, blockDef BlockDefinition)
RegisterBlock registers the BlockDefinition with the given blockName, automatically ordering the schema to be processed at the NextOrder in the Registrar, then increasing the NextOrder by the Registrar's configured IncreaseNextOrderBy.
func (*Registrar) Registrations ¶
func (r *Registrar) Registrations() []*Registration
Registrations returns pointers to all of the registered registrations. These may be modified as needed before calling Build() which will then convert them to a full hcl.Spec.
type Registration ¶
type Registration struct { BlockName string Order int Definition BlockDefinition }
Registration adds a BlockDefinition for the BlockName to the Registrar that will allow parsing the block in the schema according to the returned hcldec.Spec from BlockDefinition's Spec() method.
type VariableInjector ¶
type VariableInjector interface { BlockDefinition // Variables must return an instance of InjectableVariables. These variables // will be passed through all BlockDefinition's that follow it allowing values // created from this block to be available for all that follow. Variables(v cty.Value) InjectableVariables }
VariableInjector allows injecting variables into a hcl.EvalContext after it has been created from the BlockDefinition's Spec() result.