ast

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessorError added in v0.8.0

func AccessorError(parent Expr, accessor PropertyAccessor, summary string) *syntax.Diagnostic

AccessorError creates an error-level diagnostic associated with the given expression and accessor. If the accessor has range information, the error will cover its textual range. Otherwise, the error will cover the textual range of the parent expression.

func ExprError

func ExprError(expr Expr, summary string) *syntax.Diagnostic

ExprError creates an error-level diagnostic associated with the given expression. If the expression is non-nil and has an underlying syntax node, the error will cover the underlying textual range.

Types

type ArrayDecl added in v0.5.5

type ArrayDecl[T Node] struct {
	Elements []T
	// contains filtered or unexported fields
}

func (*ArrayDecl[T]) GetElements added in v0.5.5

func (d *ArrayDecl[T]) GetElements() []T

func (*ArrayDecl) Syntax added in v0.5.5

func (x *ArrayDecl) Syntax() syntax.Node

type ArrayExpr added in v0.5.5

type ArrayExpr struct {
	Elements []Expr
	// contains filtered or unexported fields
}

A ArrayExpr represents a list of expressions.

func Array added in v0.5.5

func Array(elements ...Expr) *ArrayExpr

Array creates a new list expression with the given elements.

func ArraySyntax added in v0.5.5

func ArraySyntax(node *syntax.ArrayNode, elements ...Expr) *ArrayExpr

ArraySyntax creates a new list expression with the given elements and associated syntax.

func (*ArrayExpr) Syntax added in v0.5.5

func (x *ArrayExpr) Syntax() syntax.Node

type BooleanExpr

type BooleanExpr struct {
	Value bool
	// contains filtered or unexported fields
}

A BooleanExpr represents a boolean literal.

func Boolean

func Boolean(value bool) *BooleanExpr

Boolean creates a new boolean literal expression with the given value.

func BooleanSyntax

func BooleanSyntax(node *syntax.BooleanNode) *BooleanExpr

BooleanSyntax creates a new boolean literal expression with the given value and associated syntax.

func (*BooleanExpr) Syntax

func (x *BooleanExpr) Syntax() syntax.Node

type BuiltinExpr

type BuiltinExpr interface {
	Expr

	Name() *StringExpr
	Args() Expr
	// contains filtered or unexported methods
}

BuiltinExpr represents a call to a builtin function.

type EnvironmentDecl

type EnvironmentDecl struct {
	Description *StringExpr
	Imports     ImportListDecl
	Values      PropertyMapDecl
	// contains filtered or unexported fields
}

An EnvironmentDecl represents a Pulumi environment.

func Environment

func Environment(description *StringExpr, imports ImportListDecl, values PropertyMapDecl) *EnvironmentDecl

func EnvironmentSyntax

func EnvironmentSyntax(node *syntax.ObjectNode, description *StringExpr, imports ImportListDecl, values PropertyMapDecl) *EnvironmentDecl

func ParseEnvironment

func ParseEnvironment(source []byte, node syntax.Node) (*EnvironmentDecl, syntax.Diagnostics)

ParseEnvironment parses a environment from the given syntax node. The source text is optional, and is only used to print diagnostics.

func (*EnvironmentDecl) NewDiagnosticWriter

func (d *EnvironmentDecl) NewDiagnosticWriter(w io.Writer, width uint, color bool) hcl.DiagnosticWriter

NewDiagnosticWriter returns a new hcl.DiagnosticWriter that can be used to print diagnostics associated with the environment.

func (*EnvironmentDecl) Syntax

func (d *EnvironmentDecl) Syntax() syntax.Node

type Expr

type Expr interface {
	Node

	Syntax() syntax.Node
	// contains filtered or unexported methods
}

Expr represents a Pulumi YAML expression. Expressions may be literals, interpolated strings, symbols, or builtin functions.

func ParseExpr

func ParseExpr(node syntax.Node) (Expr, syntax.Diagnostics)

ParseExpr parses an expression from the given syntax tree.

The syntax tree is parsed using the following rules:

  • *syntax.{Null,Boolean,Number}Node is parsed as a *{Null,Boolean,Number}Expr.
  • *syntax.ArrayNode is parsed as a *ArrayExpr.
  • *syntax.StringNode is parsed as an *InterpolateExpr, a *SymbolExpr, or a *StringExpr. The node's literal is first parsed as an interpolated string. If the result contains a single property access with no surrounding text, (i.e. the string is of the form "${resource.property}", it is treated as a symbol. If the result contains no property accesses, it is treated as a string literal. Otherwise, it it treated as an interpolated string.
  • *syntax.ObjectNode is parses as either an *ObjectExpr or a BuiltinExpr. If the object contains a single key and that key names a builtin function ("fn::invoke", "fn::join", "fn::select", "fn::*Asset", "fn::*Archive", or "fn::stackReference"), then the object is parsed as the corresponding BuiltinExpr. Otherwise, the object is parsed as a *syntax.ObjectNode.

type FromBase64Expr added in v0.5.5

type FromBase64Expr struct {
	String Expr
	// contains filtered or unexported fields
}

FromBase64 decodes a Base64 string.

func FromBase64 added in v0.5.5

func FromBase64(value Expr) *FromBase64Expr

func FromBase64Syntax added in v0.5.5

func FromBase64Syntax(node *syntax.ObjectNode, name *StringExpr, args Expr) *FromBase64Expr

func (*FromBase64Expr) Args added in v0.5.5

func (n *FromBase64Expr) Args() Expr

func (*FromBase64Expr) Name added in v0.5.5

func (n *FromBase64Expr) Name() *StringExpr

type FromJSONExpr added in v0.5.5

type FromJSONExpr struct {
	String Expr
	// contains filtered or unexported fields
}

FromJSON deserializes a JSON string into a value.

func FromJSON added in v0.5.5

func FromJSON(value Expr) *FromJSONExpr

func FromJSONSyntax added in v0.5.5

func FromJSONSyntax(node *syntax.ObjectNode, name *StringExpr, args Expr) *FromJSONExpr

func (*FromJSONExpr) Args added in v0.5.5

func (n *FromJSONExpr) Args() Expr

func (*FromJSONExpr) Name added in v0.5.5

func (n *FromJSONExpr) Name() *StringExpr

type ImportDecl

type ImportDecl struct {
	Environment *StringExpr
	Meta        *ImportMetaDecl
	// contains filtered or unexported fields
}

func (*ImportDecl) Syntax

func (x *ImportDecl) Syntax() syntax.Node

type ImportListDecl

type ImportListDecl = *ArrayDecl[*ImportDecl]

type ImportMetaDecl

type ImportMetaDecl struct {
	Merge *BooleanExpr
	// contains filtered or unexported fields
}

func (*ImportMetaDecl) Syntax

func (x *ImportMetaDecl) Syntax() syntax.Node

type InterpolateExpr

type InterpolateExpr struct {
	Parts []Interpolation
	// contains filtered or unexported fields
}

An InterpolateExpr represents an interpolated string.

Interpolated strings are represented syntactically as strings of the form "some text with ${property.accesses}". During evaluation, each access replaced with its evaluated value coerced to a string.

In order to allow convenient access to object properties without string coercion, a string of the form "${property.access}" is parsed as a symbol rather than an interpolated string.

func Interpolate

func Interpolate(value string) (*InterpolateExpr, syntax.Diagnostics)

Interpolate creates a new interpolated string expression by parsing the given input string.

func InterpolateSyntax

func InterpolateSyntax(node *syntax.StringNode) (*InterpolateExpr, syntax.Diagnostics)

InterpolateSyntax creates a new interpolated string expression with associated syntax by parsing the given input string literal.

func MustInterpolate

func MustInterpolate(value string) *InterpolateExpr

MustInterpolate creates a new interpolated string expression and panics if parsing fails.

func (*InterpolateExpr) String

func (n *InterpolateExpr) String() string

func (*InterpolateExpr) Syntax

func (x *InterpolateExpr) Syntax() syntax.Node

type Interpolation

type Interpolation struct {
	Text  string
	Value *PropertyAccess
}

type JoinExpr

type JoinExpr struct {
	Delimiter Expr
	Values    Expr
	// contains filtered or unexported fields
}

JoinExpr appends a set of values into a single value, separated by the specified delimiter. If a delimiter is the empty string, the set of values are concatenated with no delimiter.

func Join

func Join(delimiter Expr, values *ArrayExpr) *JoinExpr

func JoinSyntax

func JoinSyntax(node *syntax.ObjectNode, name *StringExpr, args, delimiter, values Expr) *JoinExpr

func (*JoinExpr) Args

func (n *JoinExpr) Args() Expr

func (*JoinExpr) Name

func (n *JoinExpr) Name() *StringExpr

type MapDecl

type MapDecl[T Node] struct {
	Entries []MapEntry[T]
	// contains filtered or unexported fields
}

func (*MapDecl[T]) GetEntries

func (d *MapDecl[T]) GetEntries() []MapEntry[T]

func (*MapDecl) Syntax

func (x *MapDecl) Syntax() syntax.Node

type MapEntry

type MapEntry[T Node] struct {
	Key   *StringExpr
	Value T
	// contains filtered or unexported fields
}

type Node

type Node interface {
	// contains filtered or unexported methods
}

type NullExpr

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

A NullExpr represents a null literal.

func Null

func Null() *NullExpr

Null creates a new null literal expression.

func NullSyntax

func NullSyntax(node *syntax.NullNode) *NullExpr

NullSyntax creates a new null literal expression with associated syntax.

func (*NullExpr) Syntax

func (x *NullExpr) Syntax() syntax.Node

type NumberExpr

type NumberExpr struct {
	Value json.Number
	// contains filtered or unexported fields
}

A NumberExpr represents a number literal.

func Number

func Number[T syntax.NumberValue](value T) *NumberExpr

Number creates a new number literal expression with the given value.

func NumberSyntax

func NumberSyntax(node *syntax.NumberNode) *NumberExpr

NumberSyntax creates a new number literal expression with the given value and associated syntax.

func (*NumberExpr) Syntax

func (x *NumberExpr) Syntax() syntax.Node

type ObjectExpr

type ObjectExpr struct {
	Entries []ObjectProperty
	// contains filtered or unexported fields
}

An ObjectExpr represents an object.

func Object

func Object(entries ...ObjectProperty) *ObjectExpr

Object creates a new object expression with the given properties.

func ObjectSyntax

func ObjectSyntax(node *syntax.ObjectNode, entries ...ObjectProperty) *ObjectExpr

ObjectSyntax creates a new object expression with the given properties and associated syntax.

func (*ObjectExpr) Syntax

func (x *ObjectExpr) Syntax() syntax.Node

type ObjectProperty

type ObjectProperty struct {
	Key   *StringExpr
	Value Expr
	// contains filtered or unexported fields
}

An ObjectProperty represents an object property. Key must be a string.

type OpenExpr

type OpenExpr struct {
	Provider *StringExpr
	Inputs   Expr
	// contains filtered or unexported fields
}

OpenExpr is a function expression that invokes an environment provider by name.

func Open

func Open(provider string, inputs *ObjectExpr) *OpenExpr

func OpenSyntax

func OpenSyntax(node *syntax.ObjectNode, name *StringExpr, args Expr, provider *StringExpr, inputs Expr) *OpenExpr

func (*OpenExpr) Args

func (n *OpenExpr) Args() Expr

func (*OpenExpr) Name

func (n *OpenExpr) Name() *StringExpr

type PropertyAccess

type PropertyAccess struct {
	Accessors []PropertyAccessor
}

func (*PropertyAccess) RootName

func (p *PropertyAccess) RootName() string

func (*PropertyAccess) String

func (p *PropertyAccess) String() string

type PropertyAccessor

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

type PropertyMapDecl

type PropertyMapDecl = *MapDecl[Expr]

type PropertyMapEntry

type PropertyMapEntry = MapEntry[Expr]

type PropertyName

type PropertyName struct {
	Name          string
	AccessorRange *hcl.Range
}

func (*PropertyName) Range added in v0.8.0

func (p *PropertyName) Range() *hcl.Range

type PropertySubscript

type PropertySubscript struct {
	Index         interface{}
	AccessorRange *hcl.Range
}

func (*PropertySubscript) Range added in v0.8.0

func (p *PropertySubscript) Range() *hcl.Range

type SecretExpr

type SecretExpr struct {
	Plaintext  *StringExpr
	Ciphertext *StringExpr
	// contains filtered or unexported fields
}

func Ciphertext added in v0.6.0

func Ciphertext(value *StringExpr) *SecretExpr

func CiphertextSyntax added in v0.6.0

func CiphertextSyntax(node *syntax.ObjectNode, name *StringExpr, args *ObjectExpr, value *StringExpr) *SecretExpr

func Plaintext added in v0.6.0

func Plaintext(value *StringExpr) *SecretExpr

func PlaintextSyntax added in v0.6.0

func PlaintextSyntax(node *syntax.ObjectNode, name, value *StringExpr) *SecretExpr

func (*SecretExpr) Args

func (n *SecretExpr) Args() Expr

func (*SecretExpr) Name

func (n *SecretExpr) Name() *StringExpr

type StringExpr

type StringExpr struct {
	Value string
	// contains filtered or unexported fields
}

A StringExpr represents a string literal.

func String

func String(value string) *StringExpr

String creates a new string literal expression with the given value.

func StringSyntax

func StringSyntax(node *syntax.StringNode) *StringExpr

StringSyntax creates a new string literal expression with the given value and associated syntax.

func StringSyntaxValue

func StringSyntaxValue(node *syntax.StringNode, value string) *StringExpr

StringSyntaxValue creates a new string literal expression with the given syntax and value.

func (*StringExpr) GetValue

func (x *StringExpr) GetValue() string

GetValue returns the expression's value. If the receiver is null, GetValue returns the empty string.

func (*StringExpr) Syntax

func (x *StringExpr) Syntax() syntax.Node

type SymbolExpr

type SymbolExpr struct {
	Property *PropertyAccess
	// contains filtered or unexported fields
}

A SymbolExpr represents a symbol: a reference to a resource or config property.

Symbol expressions are represented as strings of the form "${resource.property}".

func Symbol

func Symbol(accessors ...PropertyAccessor) *SymbolExpr

Symbol creates a new

func (*SymbolExpr) String

func (n *SymbolExpr) String() string

func (*SymbolExpr) Syntax

func (x *SymbolExpr) Syntax() syntax.Node

type ToBase64Expr

type ToBase64Expr struct {
	Value Expr
	// contains filtered or unexported fields
}

func ToBase64Syntax

func ToBase64Syntax(node *syntax.ObjectNode, name *StringExpr, args Expr) *ToBase64Expr

func (*ToBase64Expr) Args

func (n *ToBase64Expr) Args() Expr

func (*ToBase64Expr) Name

func (n *ToBase64Expr) Name() *StringExpr

type ToJSONExpr

type ToJSONExpr struct {
	Value Expr
	// contains filtered or unexported fields
}

ToJSON returns the underlying structure as a json string.

func ToJSON

func ToJSON(value Expr) *ToJSONExpr

func ToJSONSyntax

func ToJSONSyntax(node *syntax.ObjectNode, name *StringExpr, args Expr) *ToJSONExpr

func (*ToJSONExpr) Args

func (n *ToJSONExpr) Args() Expr

func (*ToJSONExpr) Name

func (n *ToJSONExpr) Name() *StringExpr

type ToStringExpr

type ToStringExpr struct {
	Value Expr
	// contains filtered or unexported fields
}

ToString returns the underlying structure as a string.

func ToString

func ToString(value Expr) *ToStringExpr

func ToStringSyntax

func ToStringSyntax(node *syntax.ObjectNode, name *StringExpr, args Expr) *ToStringExpr

func (*ToStringExpr) Args

func (n *ToStringExpr) Args() Expr

func (*ToStringExpr) Name

func (n *ToStringExpr) Name() *StringExpr

Jump to

Keyboard shortcuts

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