variables

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertCtyToInterface

func ConvertCtyToInterface(val cty.Value) (any, error)

func IndentTypeString added in v0.4.2

func IndentTypeString(typeStr string, indent int) string

IndentTypeString indents all newlines in a type string by the given number of spaces. This is used to properly format multi-line object types in the output.

func PrintDefault added in v0.4.2

func PrintDefault(v cty.Value) string

PrintDefault recursively prints out a cty.Value specification in a format that matched the way it is defined. This allows us to not have to capture or replicate the original presentation. However, could this be captured in parsing?

func PrintType added in v0.4.2

func PrintType(t cty.Type) string

PrintType recursively prints out a cty.Type specification in a format that matched the way in which it is defined.

Types

type ID

type ID string

func (ID) String

func (p ID) String() string

type Override

type Override struct {
	Name  ID
	Path  pack.ID
	Type  cty.Type
	Value cty.Value
	Range hcl.Range
}

func (*Override) Equal

func (o *Override) Equal(a *Override) bool

type Overrides

type Overrides map[pack.ID][]*Override

type PackIDKeyedVarMap

type PackIDKeyedVarMap map[pack.ID][]*Variable

type Variable

type Variable struct {

	// Name is the variable label. This is used to identify variables being
	// overridden and during templating.
	Name ID

	// Description is an optional field which provides additional context to
	// users identifying what the variable is used for.
	Description string

	// Default is an optional field which provides a default value to be used
	// in the absence of a user-provided value. It is only in this struct for
	// documentation purposes
	Default cty.Value

	// Type represents the concrete cty type of this variable. If the type is
	// unable to be parsed into a cty type, it is invalid.
	Type cty.Type

	// ConstraintType represents the type constraint for this variable and is
	// used for decoding and type validation. This may contain nested
	// ObjectWithOptionalAttrs types.
	ConstraintType cty.Type
	TypeDefaults   *typeexpr.Defaults

	// Value stores the variable value and is used when converting the cty type
	// value into a Go type value.
	Value cty.Value

	// DeclRange is the position marker of the variable within the file it was
	// read from. This is used for diagnostics.
	DeclRange hcl.Range
	// contains filtered or unexported fields
}

Variable encapsulates a single variable as defined within a block according to variableFileSchema and variableBlockSchema.

func (*Variable) AsOverrideString

func (v *Variable) AsOverrideString(pID pack.ID) string

func (*Variable) Equal

func (v *Variable) Equal(ivp *Variable) bool

func (*Variable) Merge

func (v *Variable) Merge(in *Variable) hcl.Diagnostics

func (*Variable) SetDefault

func (v *Variable) SetDefault(d cty.Value)

func (*Variable) SetDescription

func (v *Variable) SetDescription(d string)

func (*Variable) SetType

func (v *Variable) SetType(t cty.Type)

func (*Variable) SetTypeDefaults added in v0.4.2

func (v *Variable) SetTypeDefaults(t *typeexpr.Defaults)

Jump to

Keyboard shortcuts

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