bind

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Bind performs static analysis on a YAML document. The entry point for the package is `NewDecl`.

bind.go contains logic for the initial non-schema binding of an `ast.TemplateDecl` into a `Decl`. query.go contains logic to get information out of a `Decl`. schema.go handles loading appropriate schemas and binding them to an existing `Decl`. diags.go contains the diagnostic error messages used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDiagsFromLocation

func NewDiagsFromLocation(f func(*hcl.Range) *hcl.Diagnostic) diagsFromLocation

Types

type ConfigMapEntry

type ConfigMapEntry struct{ ast.ConfigMapEntry }

func (*ConfigMapEntry) DefinitionRange

func (c *ConfigMapEntry) DefinitionRange() *hcl.Range

func (*ConfigMapEntry) ResolveType

func (c *ConfigMapEntry) ResolveType(*Decl) schema.Type

type Decl

type Decl struct {
	// contains filtered or unexported fields
}

A bound template.

NOTE: the binding need not be complete, and the template need not be valid.

func NewDecl

func NewDecl(decl *ast.TemplateDecl) (*Decl, error)

func (*Decl) Diags

func (b *Decl) Diags() hcl.Diagnostics

Retrieve the diagnostic list for the Decl.

func (*Decl) GetResources

func (d *Decl) GetResources(tk, version string) ([]Resource, error)

Return a list of all resources whose token matches `tk`.

func (*Decl) Invokes

func (d *Decl) Invokes() []Invoke

Get all invokes used in the program.

func (*Decl) LoadSchema

func (d *Decl) LoadSchema(loader schema.ReferenceLoader)

Loads schemas as necessary from the loader to attach to resources and invokes. The schemas are cached internally to make searching faster. New diagnostics are appended to the internal diag list.

func (*Decl) References

func (d *Decl) References() []Reference

Return a list of all variable references bound in the Decl.

func (*Decl) Variables

func (d *Decl) Variables() map[string]*Variable

Return a list of all variables bound in the Decl.

type Definition

type Definition interface {
	ResolvableType
	DefinitionRange() *hcl.Range
	// contains filtered or unexported methods
}

type FunctionSpec

type FunctionSpec struct {
	*schema.Function
	// contains filtered or unexported fields
}

type Invoke

type Invoke struct {
	// contains filtered or unexported fields
}

func (*Invoke) Expr

func (f *Invoke) Expr() *ast.InvokeExpr

func (*Invoke) Schema

func (f *Invoke) Schema() *schema.Function

type MapKey

type MapKey struct {
	// contains filtered or unexported fields
}

type PropertyAccessor

type PropertyAccessor struct {
	ast.PropertyAccessor
	// contains filtered or unexported fields
}

type PropertyAccessorList

type PropertyAccessorList []PropertyAccessor

func (PropertyAccessorList) TypeFromRoot

func (l PropertyAccessorList) TypeFromRoot(root schema.Type) ([]schema.Type, *hcl.Diagnostic)

Compute out the type chain as long as possible. The completion chain always has 1 element since it includes the root.

type Reference

type Reference struct {
	// contains filtered or unexported fields
}

func (*Reference) Accessors

func (r *Reference) Accessors() PropertyAccessorList

Returns the property accessors that hang on the variable referenced. Examples:

${foo.bar}     => ["bar"]
${foo.bar.baz} => ["bar" "baz"]
${foo.}        => []
${foo}         => []

func (*Reference) Range

func (r *Reference) Range() *hcl.Range

func (*Reference) String

func (r *Reference) String() string

func (*Reference) Var

func (r *Reference) Var() *Variable

type ResolvableType

type ResolvableType interface {
	ResolveType(*Decl) schema.Type
}

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

func (*Resource) DefinitionRange

func (r *Resource) DefinitionRange() *hcl.Range

func (*Resource) ResolveType

func (r *Resource) ResolveType(*Decl) schema.Type

func (*Resource) Schema

func (r *Resource) Schema() *schema.Resource

type ResourceSpec

type ResourceSpec struct {
	*schema.Resource
	// contains filtered or unexported fields
}

type Variable

type Variable struct {
	// contains filtered or unexported fields
}

A value that a reference can bind to. This includes the variables, config and resources section of the yaml template.

func (*Variable) Name

func (v *Variable) Name() string

func (*Variable) Source

func (v *Variable) Source() Definition

type VariableMapEntry

type VariableMapEntry struct{ ast.VariablesMapEntry }

func (*VariableMapEntry) DefinitionRange

func (v *VariableMapEntry) DefinitionRange() *hcl.Range

func (*VariableMapEntry) ResolveType

func (v *VariableMapEntry) ResolveType(d *Decl) schema.Type

Jump to

Keyboard shortcuts

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