parser

package
v0.0.0-...-7c7bdea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2020 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlueprintSchema

type BlueprintSchema interface {
	Schema() hcldec.Spec
	Variables(cty.Value) InjectableVariables
	Functions(cty.Value) InjectableFunctions
}

BlueprintSchema describes the methods that must be implemented on a BlueprintSchema struct used to create the root schema's keys.

type InjectableFunctions

type InjectableFunctions map[string]function.Function

InjectableFunctions is a map of function names that correspond with a cty.Function of which will be injected into the context after processing Schema()

type InjectableVariables

type InjectableVariables map[string]cty.Value

InjectableVariables is a map of variable names that correspond with a cty.Value of which will be injected into the context after processing Schema()

type SchemaRegistrar

type SchemaRegistrar struct {
	NextOrder           int
	IncreaseNextOrderBy int
	// contains filtered or unexported fields
}

SchemaRegistrar 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 arguements.

The registrar also allows injecting functions after specific hcldec.Spec's are processed, though in general this should be avoided.

func NewSchemaRegistrar

func NewSchemaRegistrar(increaseNextOrderBy int) *SchemaRegistrar

NewSchemaRegistrar creates a new SchemaRegistrar instance that is used to

func (*SchemaRegistrar) AddSchemaRegistration

func (r *SchemaRegistrar) AddSchemaRegistration(reg *SchemaRegistration)

AddSchemaRegistration adds a SchemaRegistration 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 rely on variable scopes, variables will remain unkown and ultimately unvalidated.

Unknown variables may lead to an invalid Result from a Schema.

func (*SchemaRegistrar) Build

func (r *SchemaRegistrar) Build() hcldec.Spec

Build builds the schema to be parsed by the calling parser.

func (*SchemaRegistrar) Parse

func (r *SchemaRegistrar) Parse(body hcl.Body, ctx *hcl.EvalContext) hcl.Diagnostics

Parse handles parsing the hcldec.Spec specification generated dynamically using the SchemaRegistrar.

func (*SchemaRegistrar) RegisterSchema

func (r *SchemaRegistrar) RegisterSchema(root string, schema BlueprintSchema)

RegisterSchema registers the SchemaSchema for the given root name, automatically ordering the schema to be processed at the NextOrder in the SchemaRegistrar, then increasing the NextOrder by the specified IncreaseNextOrderBy.

type SchemaRegistration

type SchemaRegistration struct {
	RootName string
	Order    int
	Schema   BlueprintSchema
}

SchemaRegistration is an instance of a single registation processed at the root level of the schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL