Documentation ¶
Index ¶
- Constants
- Variables
- func AllowMissingProperties(options *bindOptions)
- func AllowMissingVariables(options *bindOptions)
- func AnnotateAttributeValue(expr model.Expression, attributeType schema.Type) model.Expression
- func AnnotateResourceInputs(node *Resource)
- func DecomposeToken(tok string, sourceRange hcl.Range) (string, string, string, hcl.Diagnostics)
- func EnumMember(t *model.EnumType, value cty.Value) (*schema.Enum, bool)
- func FixupPulumiPackageTokens(r *Resource)
- func GenEnum(t *model.EnumType, from model.Expression, safeEnum func(member *schema.Enum), ...) *hcl.Diagnostic
- func GenerateMultiArguments(f *format.Formatter, w io.Writer, undefinedLiteral string, ...)
- func GetDiscriminatedUnionObjectMapping(t *model.UnionType) map[string]model.Type
- func GetSchemaForType(t model.Type) (schema.Type, bool)
- func HasEventualTypes(t model.Type) bool
- func IsOutputVersionInvokeCall(call *model.FunctionCallExpression) bool
- func LiteralValueString(x model.Expression) string
- func LookupFunction(pkg schema.PackageReference, token string) (*schema.Function, bool, error)
- func LookupResource(pkg schema.PackageReference, token string) (*schema.Resource, bool, error)
- func LowerConversion(from model.Expression, to model.Type) model.Type
- func MapProvidersAsResources(p *Program)
- func NewApplyCall(args []model.Expression, then *model.AnonymousFunctionExpression) *model.FunctionCallExpression
- func NewConvertCall(from model.Expression, to model.Type) *model.FunctionCallExpression
- func ParseApplyCall(c *model.FunctionCallExpression) (applyArgs []model.Expression, then *model.AnonymousFunctionExpression)
- func ParseConvertCall(c *model.FunctionCallExpression) (model.Expression, model.Type)
- func PreferOutputVersionedInvokes(options *bindOptions)
- func ReadPackageDescriptors(file *syntax.File) (map[string]*schema.PackageDescriptor, hcl.Diagnostics)
- func RecognizeOutputVersionedInvoke(expr *model.FunctionCallExpression) (bool, *model.ObjectConsExpression, model.Type)
- func RecognizeTypedObjectCons(theExpr model.Expression) (bool, *model.ObjectConsExpression, model.Type)
- func RewriteApplies(expr model.Expression, nameInfo NameInfo, applyPromises bool) (model.Expression, hcl.Diagnostics)
- func RewriteAppliesWithSkipToJSON(expr model.Expression, nameInfo NameInfo, applyPromises bool, skipToJSON bool) (model.Expression, hcl.Diagnostics)
- func RewriteConversions(x model.Expression, to model.Type) (model.Expression, hcl.Diagnostics)
- func RewritePropertyReferences(expr model.Expression) model.Expression
- func SkipInvokeTypechecking(options *bindOptions)
- func SkipRangeTypechecking(options *bindOptions)
- func SkipResourceTypechecking(options *bindOptions)
- func SortedFunctionParameters(expr *model.FunctionCallExpression) []*schema.Property
- func SortedStringKeys[V any](m map[string]V) []string
- func UnwrapOption(exprType model.Type) model.Type
- func VariableAccessed(variableName string, expr model.Expression) bool
- type BindOption
- type Component
- func (c *Component) DeclarationName() string
- func (c *Component) DirPath() string
- func (c *Component) LogicalName() string
- func (c *Component) Name() string
- func (c *Component) SyntaxNode() hclsyntax.Node
- func (c *Component) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
- func (c *Component) Type() model.Type
- func (c *Component) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
- type ComponentProgramBinder
- type ComponentProgramBinderArgs
- type ConfigVariable
- func (cv *ConfigVariable) LogicalName() string
- func (cv *ConfigVariable) Name() string
- func (cv *ConfigVariable) SyntaxNode() hclsyntax.Node
- func (cv *ConfigVariable) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
- func (cv *ConfigVariable) Type() model.Type
- func (cv *ConfigVariable) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
- type LocalVariable
- func (lv *LocalVariable) LogicalName() string
- func (lv *LocalVariable) Name() string
- func (lv *LocalVariable) SyntaxNode() hclsyntax.Node
- func (lv *LocalVariable) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
- func (lv *LocalVariable) Type() model.Type
- func (lv *LocalVariable) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
- type NameInfo
- type Node
- type OutputVariable
- func (ov *OutputVariable) LogicalName() string
- func (ov *OutputVariable) Name() string
- func (ov *OutputVariable) SyntaxNode() hclsyntax.Node
- func (ov *OutputVariable) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
- func (ov *OutputVariable) Type() model.Type
- func (ov *OutputVariable) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
- type PackageCache
- type PackageInfo
- type Program
- func (p *Program) BindExpression(node hclsyntax.Node) (model.Expression, hcl.Diagnostics)
- func (p *Program) CollectComponents() map[string]*Component
- func (p *Program) CollectNestedPackageSnapshots() (map[string]*schema.Package, error)
- func (p *Program) ConfigVariables() []*ConfigVariable
- func (p *Program) NewDiagnosticWriter(w io.Writer, width uint, color bool) hcl.DiagnosticWriter
- func (p *Program) OutputVariables() []*OutputVariable
- func (p *Program) PackageReferences() []schema.PackageReference
- func (p *Program) PackageSnapshots() ([]*schema.Package, error)
- func (p *Program) Packages() []*schema.Package
- func (p *Program) Source() map[string]string
- func (p *Program) WriteSource(fs afero.Fs) error
- type Resource
- func (r *Resource) DecomposeToken() (string, string, string, hcl.Diagnostics)
- func (r *Resource) LogicalName() string
- func (r *Resource) Name() stringdeprecated
- func (r *Resource) SyntaxNode() hclsyntax.Node
- func (r *Resource) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
- func (r *Resource) Type() model.Type
- func (r *Resource) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
- type ResourceOptions
- type ResourceProperty
Constants ¶
const ( // IntrinsicApply is the name of the apply intrinsic. IntrinsicApply = "__apply" // IntrinsicConvert is the name of the conversion intrinsic. IntrinsicConvert = "__convert" )
const Invoke = "invoke"
const (
LogicalNamePropertyKey = "__logicalName"
)
Variables ¶
var ( // ArchiveType represents the set of Pulumi Archive values. ArchiveType model.Type = model.NewOpaqueType("Archive") // AssetType represents the set of Pulumi Asset values. AssetType model.Type = model.NewOpaqueType("Asset") // ResourcePropertyType represents a resource property reference. ResourcePropertyType model.Type = model.NewOpaqueType("Property") // AssetOrArchiveType represents the set of Pulumi Archive values. AssetOrArchiveType model.Type = model.NewUnionType(ArchiveType, AssetType) )
Functions ¶
func AllowMissingProperties ¶
func AllowMissingProperties(options *bindOptions)
func AllowMissingVariables ¶
func AllowMissingVariables(options *bindOptions)
func AnnotateAttributeValue ¶ added in v3.43.0
func AnnotateAttributeValue(expr model.Expression, attributeType schema.Type) model.Expression
func AnnotateResourceInputs ¶ added in v3.43.0
func AnnotateResourceInputs(node *Resource)
func DecomposeToken ¶
func EnumMember ¶ added in v3.30.0
EnumMember returns the name of the member that matches the given `value`. If no member if found, (nil, true) returned. If the query is nonsensical, either because no schema is associated with the EnumMember or if the type of value mismatches the type of the schema, (nil, false) is returned.
func FixupPulumiPackageTokens ¶ added in v3.39.0
func FixupPulumiPackageTokens(r *Resource)
func GenEnum ¶ added in v3.30.0
func GenEnum( t *model.EnumType, from model.Expression, safeEnum func(member *schema.Enum), unsafeEnum func(from model.Expression), ) *hcl.Diagnostic
GenEnum is a helper function when generating an enum. Given an enum, and instructions on what to do when you find a known value, and an unknown value, return a function that will generate an the given enum from the given expression.
This function should probably live in the `codegen` namespace, but cannot because of import cycles.
func GenerateMultiArguments ¶ added in v3.50.0
func GenerateMultiArguments( f *format.Formatter, w io.Writer, undefinedLiteral string, expr *model.ObjectConsExpression, multiArguments []*schema.Property, )
GenerateMultiArguments takes the input bag (object) of a function invoke and spreads the values of that object into multi-argument function call. For example, { a: 1, b: 2 } with multiInputArguments: ["a", "b"] would become: 1, 2
However, when optional parameters are omitted, then <undefinedLiteral> is used where they should be. Take for example { a: 1, c: 3 } with multiInputArguments: ["a", "b", "c"], it becomes 1, <undefinedLiteral>, 3 because b was omitted and c was provided so b had to be the provided <undefinedLiteral>
func GetDiscriminatedUnionObjectMapping ¶
GetDiscriminatedUnionObjectMapping calculates a map of type names to object types for a given union type.
func GetSchemaForType ¶
GetSchemaForType extracts the schema.Type associated with a model.Type, if any.
The result may be a *schema.UnionType if multiple schema types are associated with the input type.
func HasEventualTypes ¶ added in v3.66.0
func IsOutputVersionInvokeCall ¶ added in v3.18.0
func IsOutputVersionInvokeCall(call *model.FunctionCallExpression) bool
Detects invoke calls that use an output version of a function.
func LiteralValueString ¶ added in v3.139.0
func LiteralValueString(x model.Expression) string
LiteralValueString evaluates the given expression and returns the string value if it is a literal value expression otherwise returns an empty string for anything else.
func LookupFunction ¶ added in v3.49.0
Lookup a PCL invoke token in a schema.
func LookupResource ¶ added in v3.49.0
Lookup a PCL resource token in a schema.
func LowerConversion ¶ added in v3.30.0
LowerConversion lowers a conversion for a specific value, such that converting `from` to a value of the returned type will produce valid code. The algorithm prioritizes safe conversions over unsafe conversions. If no conversion can be found, nil, false is returned.
This is useful because it cuts out conversion steps which the caller doesn't need to worry about. For example: Given inputs
from = string("foo") # a constant string with value "foo" to = union(enum(string: "foo", "bar"), input(enum(string: "foo", "bar")), none)
We would receive output type:
enum(string: "foo", "bar")
since the caller can convert string("foo") to the enum directly, and does not need to consider the union.
For another example consider inputs:
from = var(string) # A variable of type string to = union(enum(string: "foo", "bar"), string)
We would return type:
string
since var(string) can be safely assigned to string, but unsafely assigned to enum(string: "foo", "bar").
func MapProvidersAsResources ¶ added in v3.37.0
func MapProvidersAsResources(p *Program)
Remaps the "pulumi:providers:$Package" token style to "$Package:index:Provider", consistent with code generation. This mapping is consistent with how provider resources are projected into the schema and removes special casing logic to generate registering explicit providers.
The resultant program should be a shallow copy of the source with only the modified resource nodes copied.
func NewApplyCall ¶
func NewApplyCall(args []model.Expression, then *model.AnonymousFunctionExpression) *model.FunctionCallExpression
NewApplyCall returns a new expression that represents a call to IntrinsicApply.
func NewConvertCall ¶
func NewConvertCall(from model.Expression, to model.Type) *model.FunctionCallExpression
NewConvertCall returns a new expression that represents a call to IntrinsicConvert.
func ParseApplyCall ¶
func ParseApplyCall(c *model.FunctionCallExpression) (applyArgs []model.Expression, then *model.AnonymousFunctionExpression, )
ParseApplyCall extracts the apply arguments and the continuation from a call to the apply intrinsic.
func ParseConvertCall ¶
func ParseConvertCall(c *model.FunctionCallExpression) (model.Expression, model.Type)
ParseConvertCall extracts the value being converted and the type it is being converted to from a call to the convert intrinsic.
func PreferOutputVersionedInvokes ¶ added in v3.74.0
func PreferOutputVersionedInvokes(options *bindOptions)
func ReadPackageDescriptors ¶ added in v3.138.0
func ReadPackageDescriptors(file *syntax.File) (map[string]*schema.PackageDescriptor, hcl.Diagnostics)
ReadPackageDescriptors reads the package blocks in the given file and returns a map of package names to the package. The descriptors blocks are top-level program blocks have the following format:
package <name> { baseProviderName = <name> baseProviderVersion = <version> baseProviderDownloadUrl = <url> parameterization { name = <name> version = <version> value = <base64 encoded string> } }
Notes:
- parameterization block is optional.
- the value of the parameterization is base64-encoded string because we want to specify binary data in PCL form
These package descriptors allow the binder loader to load package schema information from a package source.
func RecognizeOutputVersionedInvoke ¶ added in v3.18.0
func RecognizeOutputVersionedInvoke( expr *model.FunctionCallExpression, ) (bool, *model.ObjectConsExpression, model.Type)
Pattern matches to recognize an encoded call to an output-versioned invoke, such as `invoke(token, __convert(objCons(..)))`. If matching, returns the `args` expression and its schema-bound type.
func RecognizeTypedObjectCons ¶ added in v3.18.0
func RecognizeTypedObjectCons(theExpr model.Expression) (bool, *model.ObjectConsExpression, model.Type)
Pattern matches to recognize `__convert(objCons(..))` pattern that is used to annotate object constructors with appropriate nominal types. If the expression matches, returns true followed by the constructor expression and the appropriate type.
func RewriteApplies ¶
func RewriteApplies(expr model.Expression, nameInfo NameInfo, applyPromises bool) (model.Expression, hcl.Diagnostics)
RewriteApplies transforms all expressions that observe the resolved values of outputs and promises into calls to the __apply intrinsic. Expressions that generate or inspect outputs or promises are passed as arguments to these calls, and are replaced by references to the corresponding parameter.
As an example, assuming that resource.id is an output, this transforms the following expression:
toJSON({ Version = "2012-10-17" Statement = [{ Effect = "Allow" Principal = "*" Action = [ "s3:GetObject" ] Resource = [ "arn:aws:s3:::${resource.id}/*" ] }] })
into this expression:
__apply(resource.id, eval(id, toJSON({ Version = "2012-10-17" Statement = [{ Effect = "Allow" Principal = "*" Action = [ "s3:GetObject" ] Resource = [ "arn:aws:s3:::${id}/*" ] }] })))
Here is a more advanced example, assuming that resource is an object whose properties are all outputs, this expression:
"v: ${resource[resource.id]}"
is transformed into this expression:
__apply(__apply(resource.id,eval(id, resource[id])),eval(id, "v: ${id}"))
This form is amenable to code generation for targets that require that outputs are resolved before their values are accessible (e.g. Pulumi's JS/TS libraries).
func RewriteAppliesWithSkipToJSON ¶ added in v3.107.0
func RewriteAppliesWithSkipToJSON( expr model.Expression, nameInfo NameInfo, applyPromises bool, skipToJSON bool, ) (model.Expression, hcl.Diagnostics)
func RewriteConversions ¶
func RewriteConversions(x model.Expression, to model.Type) (model.Expression, hcl.Diagnostics)
RewriteConversions wraps automatic conversions indicated by the HCL2 spec and conversions to schema-annotated types in calls to the __convert intrinsic.
Note that the result is a bit out of line with the HCL2 spec, as static conversions may happen earlier than they would at runtime. For example, consider the case of a tuple of strings that is being converted to a list of numbers:
[a, b, c]
Calling RewriteConversions on this expression with a destination type of list(number) would result in this IR:
[__convert(a), __convert(b), __convert(c)]
If any of these conversions fail, the evaluation of the tuple itself fails. The HCL2 evaluation semantics, however, would convert the tuple _after_ it has been evaluated. The IR that matches these semantics is
__convert([a, b, c])
This transform uses the former representation so that it can appropriately insert calls to `__convert` in the face of schema-annotated types. There is a reasonable argument to be made that RewriteConversions should not be responsible for propagating schema annotations, and that this pass should be split in two: one pass would insert conversions that match HCL2 evaluation semantics, and another would insert calls to some separate intrinsic in order to propagate schema information.
func RewritePropertyReferences ¶
func RewritePropertyReferences(expr model.Expression) model.Expression
func SkipInvokeTypechecking ¶ added in v3.75.0
func SkipInvokeTypechecking(options *bindOptions)
func SkipRangeTypechecking ¶ added in v3.76.0
func SkipRangeTypechecking(options *bindOptions)
func SkipResourceTypechecking ¶
func SkipResourceTypechecking(options *bindOptions)
func SortedFunctionParameters ¶ added in v3.50.0
func SortedFunctionParameters(expr *model.FunctionCallExpression) []*schema.Property
SortedFunctionParameters returns a list of properties of the input type from the schema for an invoke function call which has multi argument inputs. We assume here that the expression is an invoke which has it's args (2nd parameter) annotated with the original schema type. The original schema type has properties sorted. This is important because model.ObjectType has no guarantee of property order.
func SortedStringKeys ¶ added in v3.61.1
func UnwrapOption ¶ added in v3.66.0
UnwrapOption returns type T if the input is an Option(T)
func VariableAccessed ¶ added in v3.78.0
func VariableAccessed(variableName string, expr model.Expression) bool
VariableAccessed returns whether the given variable name is accessed in the given expression.
Types ¶
type BindOption ¶
type BindOption func(*bindOptions)
func Cache ¶
func Cache(cache *PackageCache) BindOption
func ComponentBinder ¶ added in v3.58.0
func ComponentBinder(binder ComponentProgramBinder) BindOption
func DirPath ¶ added in v3.58.0
func DirPath(path string) BindOption
func Loader ¶
func Loader(loader schema.Loader) BindOption
func NonStrictBindOptions ¶ added in v3.76.0
func NonStrictBindOptions() []BindOption
NonStrictBindOptions returns a set of bind options that make the binder lenient about type checking. Changing errors into warnings when possible
func PluginHost ¶
func PluginHost(host plugin.Host) BindOption
type Component ¶
type Component struct { // The inner Program that makes up this Component. Program *Program // The type of the resource variable. VariableType model.Type // The definition of the component. Definition *model.Block // The component's input attributes, in source order. Inputs []*model.Attribute // The component resource's options, if any. Options *ResourceOptions // contains filtered or unexported fields }
Component represents a component reference in a program.
func (*Component) DeclarationName ¶ added in v3.77.0
DeclarationName returns the name of the component to use in the generated program's declaration. It is the name of the component's directory, with invalid characters replaced with underscores.
func (*Component) LogicalName ¶ added in v3.58.0
func (*Component) SyntaxNode ¶ added in v3.58.0
SyntaxNode returns the syntax node associated with the component.
func (*Component) Traverse ¶ added in v3.58.0
func (c *Component) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
func (*Component) VisitExpressions ¶ added in v3.58.0
func (c *Component) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
type ComponentProgramBinder ¶ added in v3.58.0
type ComponentProgramBinder = func(ComponentProgramBinderArgs) (*Program, hcl.Diagnostics, error)
func ComponentProgramBinderFromFileSystem ¶ added in v3.58.0
func ComponentProgramBinderFromFileSystem() ComponentProgramBinder
ComponentProgramBinderFromFileSystem returns the default component program binder which uses the file system to parse and bind PCL files into a program.
type ComponentProgramBinderArgs ¶ added in v3.58.0
type ComponentProgramBinderArgs struct { AllowMissingVariables bool AllowMissingProperties bool SkipResourceTypecheck bool SkipInvokeTypecheck bool SkipRangeTypecheck bool PreferOutputVersionedInvokes bool BinderDirPath string BinderLoader schema.Loader ComponentSource string ComponentNodeRange hcl.Range PackageCache *PackageCache }
type ConfigVariable ¶
type ConfigVariable struct { // The variable definition. Definition *model.Block // The default value for the config variable, if any. DefaultValue model.Expression Description string // Whether the config variable is nullable Nullable bool // contains filtered or unexported fields }
ConfigVariable represents a program- or component-scoped input variable. The value for a config variable may come from stack configuration or component inputs, respectively, and may have a default value.
func (*ConfigVariable) LogicalName ¶ added in v3.46.0
func (cv *ConfigVariable) LogicalName() string
func (*ConfigVariable) Name ¶
func (cv *ConfigVariable) Name() string
func (*ConfigVariable) SyntaxNode ¶
func (cv *ConfigVariable) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the config variable.
func (*ConfigVariable) Traverse ¶
func (cv *ConfigVariable) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
func (*ConfigVariable) Type ¶
func (cv *ConfigVariable) Type() model.Type
Type returns the type of the config variable.
func (*ConfigVariable) VisitExpressions ¶
func (cv *ConfigVariable) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
type LocalVariable ¶
type LocalVariable struct { // The variable definition. Definition *model.Attribute // contains filtered or unexported fields }
LocalVariable represents a program- or component-scoped local variable.
func (*LocalVariable) LogicalName ¶ added in v3.31.0
func (lv *LocalVariable) LogicalName() string
func (*LocalVariable) Name ¶
func (lv *LocalVariable) Name() string
func (*LocalVariable) SyntaxNode ¶
func (lv *LocalVariable) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the local variable.
func (*LocalVariable) Traverse ¶
func (lv *LocalVariable) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
func (*LocalVariable) Type ¶
func (lv *LocalVariable) Type() model.Type
Type returns the type of the local variable.
func (*LocalVariable) VisitExpressions ¶
func (lv *LocalVariable) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
type Node ¶
type Node interface { model.Definition // Name returns the lexical name of the node. Name() string // Type returns the type of the node. Type() model.Type // VisitExpressions visits the expressions that make up the node's body. VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics // contains filtered or unexported methods }
Node represents a single definition in a program or component. Nodes may be config, locals, resources, components, or outputs.
func Linearize ¶
Linearize performs a topological sort of the nodes in the program so that they can be processed by tools that need to see all of a node's dependencies before the node itself (e.g. a code generator for a programming language that requires variables to be defined before they can be referenced). The sort is stable, and nodes are kept in source order as much as possible.
func SourceOrderNodes ¶
type OutputVariable ¶
type OutputVariable struct { // The definition of the output. Definition *model.Block // The value of the output. Value model.Expression // contains filtered or unexported fields }
OutputVariable represents a program- or component-scoped output variable.
func (*OutputVariable) LogicalName ¶ added in v3.31.0
func (ov *OutputVariable) LogicalName() string
Returns the ID of the output, if the output has an ID it is returned surrounded by double quotes, otherwise the defaultValue is returned as is.
func (*OutputVariable) Name ¶
func (ov *OutputVariable) Name() string
func (*OutputVariable) SyntaxNode ¶
func (ov *OutputVariable) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the output variable.
func (*OutputVariable) Traverse ¶
func (ov *OutputVariable) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
func (*OutputVariable) Type ¶
func (ov *OutputVariable) Type() model.Type
Type returns the type of the output variable.
func (*OutputVariable) VisitExpressions ¶
func (ov *OutputVariable) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
type PackageCache ¶
type PackageCache struct {
// contains filtered or unexported fields
}
func NewPackageCache ¶
func NewPackageCache() *PackageCache
type PackageInfo ¶ added in v3.40.2
type PackageInfo struct {
// contains filtered or unexported fields
}
type Program ¶
type Program struct { Nodes []Node // contains filtered or unexported fields }
Program represents a semantically-analyzed Pulumi HCL2 program.
func BindDirectory ¶ added in v3.70.0
func BindDirectory( directory string, loader schema.ReferenceLoader, extraOptions ...BindOption, ) (*Program, hcl.Diagnostics, error)
Used by language plugins to bind a PCL program in the given directory.
func BindProgram ¶
func BindProgram(files []*syntax.File, opts ...BindOption) (*Program, hcl.Diagnostics, error)
BindProgram performs semantic analysis on the given set of HCL2 files that represent a single program. The given host, if any, is used for loading any resource plugins necessary to extract schema information.
func (*Program) BindExpression ¶
func (p *Program) BindExpression(node hclsyntax.Node) (model.Expression, hcl.Diagnostics)
BindExpression binds an HCL2 expression in the top-level context of the program.
func (*Program) CollectComponents ¶ added in v3.58.0
CollectComponents finds all used components in a program and recursively searches of nested components from sub programs.
func (*Program) CollectNestedPackageSnapshots ¶ added in v3.59.0
func (*Program) ConfigVariables ¶ added in v3.58.0
func (p *Program) ConfigVariables() []*ConfigVariable
ConfigVariables returns the config variable nodes of the program
func (*Program) NewDiagnosticWriter ¶
NewDiagnosticWriter creates a new hcl.DiagnosticWriter for use with diagnostics generated by the program.
func (*Program) OutputVariables ¶ added in v3.58.0
func (p *Program) OutputVariables() []*OutputVariable
OutputVariables returns the output variable nodes of the program
func (*Program) PackageReferences ¶ added in v3.33.2
func (p *Program) PackageReferences() []schema.PackageReference
PackageReferences returns the list of package referenced used by this program.
func (*Program) PackageSnapshots ¶ added in v3.33.2
PackageSnapshots returns the list of packages schemas used by this program. If a referenced package is partial, its returned value is a snapshot that contains only the package members referenced by the program. Otherwise, its returned value is the full package definition.
type Resource ¶
type Resource struct { // The definition of the resource. Definition *model.Block // When set to true, allows traversing unknown properties through a resource. i.e. `resource.unknownProperty` // will be valid and the type of the traversal is dynamic. This property is set to false by default LenientTraversal bool // Token is the type token for this resource. Token string // Schema is the schema definition for this resource, if any. Schema *schema.Resource // The type of the resource's inputs. This will always be either Any or an object type. InputType model.Type // The type of the resource's outputs. This will always be either Any or an object type. OutputType model.Type // The type of the resource variable. VariableType model.Type // The resource's input attributes, in source order. Inputs []*model.Attribute // The resource's options, if any. Options *ResourceOptions // contains filtered or unexported fields }
Resource represents a resource instantiation inside of a program or component.
func (*Resource) DecomposeToken ¶
DecomposeToken attempts to decompose the resource's type token into its package, module, and type. If decomposition fails, a description of the failure is returned in the diagnostics.
func (*Resource) LogicalName ¶ added in v3.31.0
Returns the unique name of the resource; if the resource has an unique name it is formatted with the format string and returned, otherwise the defaultValue is returned as is.
func (*Resource) SyntaxNode ¶
SyntaxNode returns the syntax node associated with the resource.
func (*Resource) Traverse ¶
func (r *Resource) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
func (*Resource) VisitExpressions ¶
func (r *Resource) VisitExpressions(pre, post model.ExpressionVisitor) hcl.Diagnostics
type ResourceOptions ¶
type ResourceOptions struct { // The definition of the resource options. Definition *model.Block // An expression to range over when instantiating the resource. Range model.Expression // The resource's parent, if any. Parent model.Expression // The provider to use. Provider model.Expression // The explicit dependencies of the resource. DependsOn model.Expression // Whether or not the resource is protected. Protect model.Expression // Whether the resource should be left in the cloud provider // when it's deleted from the Pulumi state. RetainOnDelete model.Expression // A list of properties that are not considered when diffing the resource. IgnoreChanges model.Expression // The version of the provider for this resource. Version model.Expression // The plugin download URL for this resource. PluginDownloadURL model.Expression // If set, the provider's Delete method will not be called for this resource if the specified resource is being // deleted as well. DeletedWith model.Expression }
ResourceOptions represents a resource instantiation's options.
type ResourceProperty ¶
ResourceProperty represents a resource property.
func (*ResourceProperty) SyntaxNode ¶
func (*ResourceProperty) SyntaxNode() hclsyntax.Node
func (*ResourceProperty) Traverse ¶
func (p *ResourceProperty) Traverse(traverser hcl.Traverser) (model.Traversable, hcl.Diagnostics)
func (*ResourceProperty) Type ¶
func (p *ResourceProperty) Type() model.Type