hclparser

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0, MPL-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyBody added in v0.12.0

func EmptyBody() hcl.Body

EmptyBody returns a body with no content. This body can be used as a placeholder when a body is required but no body content is available.

func FilterExcludeBody added in v0.10.0

func FilterExcludeBody(body hcl.Body, schema *hcl.BodySchema) hcl.Body

func FilterIncludeBody added in v0.10.0

func FilterIncludeBody(body hcl.Body, schema *hcl.BodySchema) hcl.Body

func ImpliedType added in v0.19.0

func ImpliedType(gv interface{}) (cty.Type, error)

ImpliedType takes an arbitrary Go value (as an interface{}) and attempts to find a suitable cty.Type instance that could be used for a conversion with ToCtyValue.

This allows -- for simple situations at least -- types to be defined just once in Go and the cty types derived from the Go types, but in the process it makes some assumptions that may be undesirable so applications are encouraged to build their cty types directly if exacting control is required.

Not all Go types can be represented as cty types, so an error may be returned which is usually considered to be a bug in the calling program. In particular, ImpliedType will never use capsule types in its returned type, because it cannot know the capsule types supported by the calling program.

func MergeBodies added in v0.12.0

func MergeBodies(bodies []hcl.Body) hcl.Body

MergeBodies is like MergeFiles except it deals directly with bodies, rather than with entire files.

func MergeFiles added in v0.12.0

func MergeFiles(files []*hcl.File) hcl.Body

MergeFiles combines the given files to produce a single body that contains configuration from all of the given files.

The ordering of the given files decides the order in which contained elements will be returned. If any top-level attributes are defined with the same name across multiple files, a diagnostic will be produced from the Content and PartialContent methods describing this error in a user-friendly way.

func Stdlib added in v0.11.0

func Stdlib() map[string]function.Function

func ToCtyValue added in v0.19.0

func ToCtyValue(val any, ty cty.Type) (cty.Value, error)

func ToNativeValue added in v0.19.0

func ToNativeValue(in cty.Value) cty.Value

ToNativeValue will convert a value to only native cty types which will remove capsule types if possible.

Types

type CapsuleValue added in v0.19.0

type CapsuleValue interface {
	// FromCtyValue will initialize this value using a cty.Value.
	FromCtyValue(in cty.Value, path cty.Path) error

	// ToCtyValue will convert this capsule value into a native
	// cty.Value. This should not return a capsule type.
	ToCtyValue() cty.Value
}

type Opt

type Opt struct {
	LookupVar     func(string) (string, bool)
	Vars          map[string]string
	ValidateLabel func(string) error
}

type ParseMeta added in v0.16.0

type ParseMeta struct {
	Renamed      map[string]map[string][]string
	AllVariables []*Variable
}

func Parse

func Parse(b hcl.Body, opt Opt, val interface{}) (*ParseMeta, hcl.Diagnostics)

type Variable added in v0.16.0

type Variable struct {
	Name        string
	Description string
	Value       *string
}

type WithEvalContexts added in v0.11.0

type WithEvalContexts interface {
	GetEvalContexts(base *hcl.EvalContext, block *hcl.Block, loadDeps func(hcl.Expression) hcl.Diagnostics) ([]*hcl.EvalContext, error)
}

type WithGetName added in v0.11.0

type WithGetName interface {
	GetName(ectx *hcl.EvalContext, block *hcl.Block, loadDeps func(hcl.Expression) hcl.Diagnostics) (string, error)
}

Directories

Path Synopsis
Package gohcl allows decoding HCL configurations into Go data structures.
Package gohcl allows decoding HCL configurations into Go data structures.

Jump to

Keyboard shortcuts

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