Back to godoc.org

Package il

v2.11.0
Latest Go to latest

The latest major version is v2.

Published: Oct 9, 2020 | License: Apache-2.0 | Module: github.com/pulumi/pulumi-terraform-bridge/v2

Index

Constants

const (
	// IntrinsicApply is the name of the apply intrinsic.
	IntrinsicApply = "__apply"
	// IntrinsicApplyArg is the name of the apply arg intrinsic.
	IntrinsicApplyArg = "__applyArg"
	// IntrinsicArchive is the name of the archive intrinsic.
	IntrinsicArchive = "__archive"
	// IntrinsicAsset is the name of the asset intrinsic.
	IntrinsicAsset = "__asset"
	// IntrinsicCoerce is the name of the coerce intrinsic.
	IntrinsicCoerce = "__coerce"
	// IntrinsicGetStack is the name of the get stack intrinsic.
	IntrinsicGetStack = "__getStack"
)

Variables

var PluginProviderInfoSource = ProviderInfoSource(pluginProviderInfoSource{})

PluginProviderInfoSource is the ProviderInfoSource that retrieves tfbridge information by loading and interrogating the Pulumi resource provider that corresponds to a Terraform provider.

func DumpBoundNode

func DumpBoundNode(w io.Writer, e BoundNode)

DumpBoundNode dumps the string representation of the given bound node to the given writer.

func FilterProperties

func FilterProperties(r *ResourceNode, filter func(key string, property BoundNode) bool)

FilterProperties removes any properties at the root of the given resource for which the given filter function returns false.

func MarkConditionalResources

func MarkConditionalResources(g *Graph) map[*ResourceNode]bool

MarkConditionalResources finds all resources and data sources with a count that is known to be either 0 or 1 (this includes counts that are coerced from boolean values).

func MarkPromptDataSources

func MarkPromptDataSources(g *Graph) map[*ResourceNode]bool

MarkPromptDataSources finds all data sources with no Output-typed inputs, marks these data sources as prompt, and retypes all variable accesses rooted in these data sources appropriately.

func ParseApplyArgCall

func ParseApplyArgCall(c *BoundCall) int

ParseapplyArgCall extracts the argument index from a call to the apply arg intrinsic.

func ParseApplyCall

func ParseApplyCall(c *BoundCall) (applyArgs []*BoundVariableAccess, then BoundExpr)

ParseApplyCall extracts the apply arguments and the continuation from a call to the apply intrinsic.

func ParseCoerceCall

func ParseCoerceCall(c *BoundCall) (value BoundExpr, toType Type)

ParseCoerceCall extracts the value being coerced and the type to which it is being coerced from a call to the coerce intrinsic.

func VisitAllProperties

func VisitAllProperties(m *Graph, pre, post BoundNodeVisitor) error

VisitAllProperties visits all property nodes in the graph using the given pre- and post-order visitors.

type BoundArithmetic

type BoundArithmetic struct {
	// Op is the arithmetic operation used by this expression.
	Op ast.ArithmeticOp
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// Exprs is the bound list of the arithmetic expression's operands.
	Exprs []BoundExpr
	// ExprType is the type of the arithmetic expression.
	ExprType Type
}

BoundArithmetic is the bound form of an HIL arithmetic expression (e.g. `${a + b}`).

func (*BoundArithmetic) Comments

func (n *BoundArithmetic) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundArithmetic) Type

func (n *BoundArithmetic) Type() Type

Type returns the type of the arithmetic expression.

type BoundCall

type BoundCall struct {
	// Func is the name of the function to call.
	Func string
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// ExprType is the type of the call expression.
	ExprType Type
	// Args is the bound list of the call's arguments.
	Args []BoundExpr
}

BoundCall is the bound form of an HIL call expression (e.g. `${foo(bar, baz)}`).

func NewApplyArgCall

func NewApplyArgCall(argIndex int, argType Type) *BoundCall

NewApplyArgCall returns a new IL tree that represents a call to IntrinsicApplyArg.

func NewApplyCall

func NewApplyCall(args []*BoundVariableAccess, then BoundExpr) *BoundCall

NewApplyCall returns a new IL tree that represents a call to IntrinsicApply.

func NewArchiveCall

func NewArchiveCall(arg BoundExpr) *BoundCall

NewArchiveCall creates a call to IntrinsicArchive.

func NewAssetCall

func NewAssetCall(arg BoundExpr) *BoundCall

NewAssetCall creates a call to IntrinsicArchive.

func NewCoerceCall

func NewCoerceCall(value BoundExpr, toType Type) *BoundCall

NewCoerceCall creates a call to IntrisicCoerce, which is used to represent the coercion of a value from one type to another.

func NewGetStackCall

func NewGetStackCall() *BoundCall

NewGetStackCall creates a call to IntrinsicGetStack.

func (*BoundCall) Comments

func (n *BoundCall) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundCall) Type

func (n *BoundCall) Type() Type

Type returns the type of the call expression.

type BoundConditional

type BoundConditional struct {
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// ExprType is the type of the conditional expression.
	ExprType Type
	// CondExpr is the bound form of the conditional expression's predicate.
	CondExpr BoundExpr
	// TrueExpr is the bound form of the conditional expression's true branch.
	TrueExpr BoundExpr
	// FalseExpr is the bound from of the condition expression's false branch.
	FalseExpr BoundExpr
}

BoundConditional is the bound form of an HIL conditional expression (e.g. `foo ? bar : baz`).

func (*BoundConditional) Comments

func (n *BoundConditional) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundConditional) Type

func (n *BoundConditional) Type() Type

Type returns the type of the conditional expression.

type BoundError

type BoundError struct {
	// The type of the node.
	NodeType Type
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// A bound node (if any) associated with this error
	Value BoundNode
	// The binding error
	Error error
}

BoundError represents a binding error. This is used to preserve bound values in the case of type mismatches and other errors.

func (*BoundError) Comments

func (n *BoundError) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundError) Type

func (n *BoundError) Type() Type

Type returns the type of the variable access expression.

type BoundExpr

type BoundExpr interface {
	BoundNode
	// contains filtered or unexported methods
}

A BoundExpr represents a single node in a bound interpolation expression. This type is used to help ensure that bound interpolation expressions only reference nodes that may be present in such expressions.

func ParseArchiveCall

func ParseArchiveCall(c *BoundCall) (arg BoundExpr)

ParseArchiveCall extracts the single argument expression from a call to the archive intrinsic.

func ParseAssetCall

func ParseAssetCall(c *BoundCall) (arg BoundExpr)

ParseAssetCall extracts the single argument expression from a call to the asset intrinsic.

func SimplifyBooleanExpressions

func SimplifyBooleanExpressions(expr BoundExpr) BoundExpr

SimplifyBooleanExpressions recursively simplifies conditional and literal expressions with statically known values.

Note that this will convert a top-level literal that is coerceable to a boolean into a boolean literal, so this function should only be called if the resulting expression can be boolean-typed.

func VisitBoundExpr

func VisitBoundExpr(n BoundExpr, pre, post BoundNodeVisitor) (BoundExpr, error)

VisitBoundExpr visits each node in an expression tree using the given pre- and post-order visitors. Its behavior is identical to that of VisitBoundNode, but it requires that the given visitors return BoundExpr values.

type BoundIndex

type BoundIndex struct {
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// ExprType is the type of the index expression.
	ExprType Type
	// TargetExpr is the bound form of the index expression's target (e.g. `foo` in `${foo[bar]}`).
	TargetExpr BoundExpr
	// KeyExpr is the bound form of the index expression's key (e.g. `bar` in `${foo[bar]}`).
	KeyExpr BoundExpr
}

BoundIndex is the bound form of an HIL index expression (e.g. `${foo[bar]}`).

func (*BoundIndex) Comments

func (n *BoundIndex) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundIndex) Type

func (n *BoundIndex) Type() Type

Type returns the type of the index expression.

type BoundListProperty

type BoundListProperty struct {
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// Schemas are the Terraform and Pulumi schemas associated with the list.
	Schemas Schemas
	// Elements is the bound list of the list's elements.
	Elements []BoundNode
}

BoundListProperty is the bound form of an HCL list property. (e.g. `[ foo, bar ]`).

func (*BoundListProperty) Comments

func (n *BoundListProperty) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundListProperty) Type

func (n *BoundListProperty) Type() Type

Type returns the type of the list property (always a list type).

type BoundLiteral

type BoundLiteral struct {
	// ExprType is the type of the literal expression.
	ExprType Type
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// Value is the value of the literal expression. This may be a bool, string, float64, or in the case of the
	// argument to the __applyArg intrinsic, an int.
	Value interface{}
}

BoundLiteral is the bound form of a literal value.

func (*BoundLiteral) Comments

func (n *BoundLiteral) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundLiteral) Type

func (n *BoundLiteral) Type() Type

Type returns the type of the literal expression.

type BoundMapProperty

type BoundMapProperty struct {
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// Schemas are the Terraform and Pulumi schemas associated with the map.
	Schemas Schemas
	// Elements is a map from name to bound value of the map's elements.
	Elements map[string]BoundNode
}

BoundMapProperty is the bound form of an HCL map property. (e.g. `{ foo = bar ]`).

func (*BoundMapProperty) Comments

func (n *BoundMapProperty) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundMapProperty) Type

func (n *BoundMapProperty) Type() Type

Type returns the type of the map property (always TypeMap).

type BoundNode

type BoundNode interface {
	Type() Type
	Comments() *Comments
	// contains filtered or unexported methods
}

A BoundNode represents a single bound property map, property list, or interpolation expression. Every BoundNode has a Type.

func AddCoercions

func AddCoercions(prop BoundNode) (BoundNode, error)

AddCoercions inserts calls to the `__coerce` intrinsic in cases where a list or map element's type disagrees with the element type present in the list or map's schema.

func IdentityVisitor

func IdentityVisitor(n BoundNode) (BoundNode, error)

IdentityVisitor is a BoundNodeVisitor that returns the input node unchanged.

func RewriteApplies

func RewriteApplies(n BoundNode) (BoundNode, error)

RewriteApplies transforms all bound expression trees in the given BoundNode that reference output-typed properties into appropriate calls to the __apply and __applyArg intrinsic. Given an expression tree, the rewrite proceeds as follows: - let the list of outputs be an empty list - for each node in post-order:

- if the node is the root of the expression tree:
    - if the node is a variable access:
        - if the access has an output-typed element on its path, replace the variable access with a call to the
          __applyArg intrinsic and append the access to the list of outputs.
        - otherwise, the access does not need to be transformed; return it as-is.
    - if the list of outputs is empty, the root does not need to be transformed; return it as-is.
    - otherwise, replace the root with a call to the __apply intrinstic. The first n arguments to this call are
      the elementss of the list of outputs. The final argument is the original root node.
- otherwise, if the root is an output-typed variable access, replace the variable access with a call to the
  __applyArg instrinsic and append the access to the list of outputs.

As an example, this transforms the following expression:

(output string
    "#!/bin/bash -xe\n\nCA_CERTIFICATE_DIRECTORY=/etc/kubernetes/pki\necho \""
    (aws_eks_cluster.demo.certificate_authority.0.data output<unknown> *config.ResourceVariable)
    "\" | base64 -d >  $CA_CERTIFICATE_FILE_PATH\nsed -i s,MASTER_ENDPOINT,"
    (aws_eks_cluster.demo.endpoint output<string> *config.ResourceVariable)
    ",g /var/lib/kubelet/kubeconfig\nsed -i s,CLUSTER_NAME,"
    (var.cluster-name string *config.UserVariable)
    ",g /var/lib/kubelet/kubeconfig\nsed -i s,REGION,"
    (data.aws_region.current.name output<string> *config.ResourceVariable)
    ",g /etc/systemd/system/kubelet.servicesed -i s,MASTER_ENDPOINT,"
    (aws_eks_cluster.demo.endpoint output<string> *config.ResourceVariable)
    ",g /etc/systemd/system/kubelet.service"
)

into this expression:

(call output<unknown> __apply
    (aws_eks_cluster.demo.certificate_authority.0.data output<unknown> *config.ResourceVariable)
    (aws_eks_cluster.demo.endpoint output<string> *config.ResourceVariable)
    (data.aws_region.current.name output<string> *config.ResourceVariable)
    (aws_eks_cluster.demo.endpoint output<string> *config.ResourceVariable)
    (output string
        "#!/bin/bash -xe\n\nCA_CERTIFICATE_DIRECTORY=/etc/kubernetes/pki\necho \""
        (call unknown __applyArg
            0
        )
        "\" | base64 -d >  $CA_CERTIFICATE_FILE_PATH\nsed -i s,MASTER_ENDPOINT,"
        (call string __applyArg
            1
        )
        ",g /var/lib/kubelet/kubeconfig\nsed -i s,CLUSTER_NAME,"
        (var.cluster-name string *config.UserVariable)
        ",g /var/lib/kubelet/kubeconfig\nsed -i s,REGION,"
        (call string __applyArg
            2
        )
        ",g /etc/systemd/system/kubelet.servicesed -i s,MASTER_ENDPOINT,"
        (call string __applyArg
            3
        )
        ",g /etc/systemd/system/kubelet.service"
    )
)

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 RewriteAssets

func RewriteAssets(n BoundNode) (BoundNode, error)

RewriteAssets transforms all arguments to Terraform properties that are projected as Pulumi assets or archives into calls to the appropriate __asset or __archive intrinsic.

func VisitBoundNode

func VisitBoundNode(n BoundNode, pre, post BoundNodeVisitor) (BoundNode, error)

VisitBoundNode visits each node in a property tree using the given pre- and post-order visitors. If the preorder visitor returns a new node, that node's descendents will be visited. This function returns the result of the post-order visitor. If any visitor returns an error, the walk halts and that error is returned.

type BoundNodeVisitor

type BoundNodeVisitor func(n BoundNode) (BoundNode, error)

A BoundNodeVisitor is a function that visits and optionally replaces a node in a bound property tree.

type BoundOutput

type BoundOutput struct {
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// Exprs is the bound list of the output's operands.
	Exprs []BoundExpr
}

BoundOutput is the bound form of an HIL output expression (e.g. `foo ${bar} baz`).

func (*BoundOutput) Comments

func (n *BoundOutput) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundOutput) Type

func (n *BoundOutput) Type() Type

Type returns the type of the output expression (which is always TypeString).

type BoundPropertyValue

type BoundPropertyValue struct {
	// The type of the node.
	NodeType Type
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// The wrapped property.
	Value BoundNode
}

BoundPropertyValue wraps a BoundMapProperty or BoundListProperty in a BoundExpr. This is intended primarily for the use of transforms that must pass bound properties to intrinsics.

func (*BoundPropertyValue) Comments

func (n *BoundPropertyValue) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundPropertyValue) Type

func (n *BoundPropertyValue) Type() Type

Type returns the type of the expression.

type BoundVariableAccess

type BoundVariableAccess struct {
	// Comments is the set of comments associated with this node, if any.
	NodeComments *Comments
	// Elements are the path elements that comprise the variable access expression.
	Elements []string
	// Schemas are the Terraform and Pulumi schemas associated with the referenced variable.
	Schemas Schemas
	// ExprType is the type of the variable access expression.
	ExprType Type
	// TFVar is the Terraform representation of the variable access expression.
	TFVar config.InterpolatedVariable
	// ILNode is the dependency graph node associated with the accessed variable.
	ILNode Node
}

BoundVariableAccess is the bound form of an HIL variable access expression (e.g. `${foo.bar}`).

func (*BoundVariableAccess) Comments

func (n *BoundVariableAccess) Comments() *Comments

Comments returns the comments attached to this node, if any.

func (*BoundVariableAccess) IsMissingVariable

func (n *BoundVariableAccess) IsMissingVariable() bool

func (*BoundVariableAccess) Type

func (n *BoundVariableAccess) Type() Type

Type returns the type of the variable access expression.

type BuildOptions

type BuildOptions struct {
	// ProviderInfoSource allows the caller to override the default source for provider schema information, which
	// relies on resource provider plugins.
	ProviderInfoSource ProviderInfoSource
	// AllowMissingProviders allows binding to succeed even if schema information is not available for a provider.
	AllowMissingProviders bool
	// Logger allows the caller to provide a logger for diagnostics. If not provided, the default logger will be used.
	Logger *log.Logger
	// AllowMissingVariables allows binding to succeed even if unknown variables are encountered.
	AllowMissingVariables bool
	// AllowMissingComments allows binding to succeed even if there are errors extracting comments from the source.
	AllowMissingComments bool
}

BuildOptions defines the set of optional parameters to `BuildGraph`.

type CachingProviderInfoSource

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

CachingProviderInfoSource wraps a ProviderInfoSource in a cache for faster access.

func NewCachingProviderInfoSource

func NewCachingProviderInfoSource(source ProviderInfoSource) *CachingProviderInfoSource

NewCachingProviderInfoSource creates a new CachingProviderInfoSource that wraps the given ProviderInfoSource.

func (*CachingProviderInfoSource) GetProviderInfo

func (cache *CachingProviderInfoSource) GetProviderInfo(
	registryName, namespace, name, version string) (*tfbridge.ProviderInfo, error)

GetProviderInfo returns the tfbridge information for the indicated Terraform provider as well as the name of the corresponding Pulumi resource provider.

type Comments

type Comments struct {
	// Leading is the lines of the comment (sans comment tokens) that precedes a node, if any. Line endings (if any)
	// are present.
	Leading []string
	// Trailing is the lines of the comment (sans comment tokens) that succeeds a node, if any. Line ending (if any)
	// are present.
	Trailing []string
}

Comments represents the set of comments associated with a node.

type Graph

type Graph struct {
	// Tree is the module's entry in the module tree. The tree is used e.g. to determine the module's name.
	Tree *module.Tree
	// Name is the name of the module. May be the empty string when IsRoot is true.
	Name string
	// IsRoot is true if this is the root module.
	IsRoot bool
	// Path is the path to this module's directory.
	Path string
	// Modules maps from module name to module node for this module's module instantiations. This map is used to
	// bind a module variable access in an interpolation to the corresponding module node.
	Modules map[string]*ModuleNode
	// Providers maps from provider name to provider node for this module's provider instantiations. This map is
	// used to bind a provider reference to the corresponding provider node.
	Providers map[string]*ProviderNode
	// Resources maps from resource name to module node for this module's module instantiations. This map is used
	// to bind a resource variable access in an interpolation to the corresponding resource node.
	Resources map[string]*ResourceNode
	// Outputs maps from output name to output node for this module's outputs.
	Outputs map[string]*OutputNode
	// Locals maps from local value name to local value node for this module's local values. This map is used to bind a
	// local variable access in an interpolation to the corresponding local value node.
	Locals map[string]*LocalNode
	// Variables maps from variable name to variable node for this module's variables. This map is used to bind a
	// variable access in an interpolation to the corresponding variable node.
	Variables map[string]*VariableNode
}

A Graph is the analyzed form of the configuration for a single Terraform module.

func BuildGraph

func BuildGraph(tree *module.Tree, opts *BuildOptions) (*Graph, error)

BuildGraph analyzes the various entities present in the given module's configuration and constructs the corresponding dependency graph. Building the graph involves binding each entity's properties (if any) and computing its list of dependency edges.

type LocalNode

type LocalNode struct {
	// Config is the local value's raw Terraform configuration.
	Config *config.Local
	// Location is the location of this node's definition in the original Terraform configuration.
	Location token.Pos
	// Comments is the set of comments associated with this node, if any.
	Comments *Comments
	// Deps is the list of the local value's dependencies as implied by the nodes referenced by its configuration.
	Deps []Node
	// Name is the name of this local.
	Name string
	// Value is the bound form of the local value's value.
	Value BoundNode
}

A LocalNode is the analyzed form of a local value in a Terraform configuration.

func (*LocalNode) Dependencies

func (l *LocalNode) Dependencies() []Node

Depdendencies returns the list of nodes the local value depends on.

func (*LocalNode) GetLocation

func (l *LocalNode) GetLocation() token.Pos

func (*LocalNode) ID

func (l *LocalNode) ID() string

type ModuleNode

type ModuleNode struct {
	// Config is the module's raw Terraform configuration.
	Config *config.Module
	// Location is the location of this node's definition in the original Terraform configuration.
	Location token.Pos
	// Comments is the set of comments associated with this node, if any.
	Comments *Comments
	// Deps is the list of the module's dependencies as implied by the nodes referenced by its configuration.
	Deps []Node
	// Name is the name of the module.
	Name string
	// Properties is the bound form of the module's configuration properties.
	Properties *BoundMapProperty
}

A ModuleNode is the analyzed form of a module instantiation in a Terraform configuration.

func (*ModuleNode) Dependencies

func (m *ModuleNode) Dependencies() []Node

Depdendencies returns the list of nodes the module depends on.

func (*ModuleNode) GetLocation

func (m *ModuleNode) GetLocation() token.Pos

func (*ModuleNode) ID

func (m *ModuleNode) ID() string

type Node

type Node interface {

	// Dependencies returns the list of nodes the node depends on.
	Dependencies() []Node
	// ID returns the unique ID for this node.
	ID() string
	// contains filtered or unexported methods
}

A Node represents a single node in a dependency graph. A node is connected to other nodes by dependency edges. The set of nodes and edges forms a DAG. Each concrete node type corresponds to a particular Terraform concept; ResourceNode, for example, represents a resource in a Terraform configuration.

In general, a node's dependencies are the union from its implicit dependencies (i.e. the nodes referenced by the interpolations in its properties, if any) and its explicit dependencies.

type OutputNode

type OutputNode struct {
	// Config is the output's raw Terraform configuration.
	Config *config.Output
	// Location is the location of this node's definition in the original Terraform configuration.
	Location token.Pos
	// Comments is the set of comments associated with this node, if any.
	Comments *Comments
	// Deps is the list of the output's dependencies as implied by the nodes referenced by its configuration.
	Deps []Node
	// ExplicitDeps is the list of the output's explicit dependencies. This is a subset of Deps.
	ExplicitDeps []Node
	// Name is the name of this output.
	Name string
	// Value is the bound from of the output's value.
	Value BoundNode
}

An OutputNode is the analyzed form of an output in a Terraform configuration. An OutputNode may never be referenced by another node, as its value is not nameable in a Terraform configuration.

func (*OutputNode) Dependencies

func (o *OutputNode) Dependencies() []Node

Depdendencies returns the list of nodes the output depends on.

func (*OutputNode) GetLocation

func (o *OutputNode) GetLocation() token.Pos

func (*OutputNode) ID

func (o *OutputNode) ID() string

type ProviderInfoSource

type ProviderInfoSource interface {
	// GetProviderInfo returns the tfbridge information for the indicated Terraform provider.
	GetProviderInfo(registry, namespace, name, version string) (*tfbridge.ProviderInfo, error)
}

ProviderInfoSource abstracts the ability to fetch tfbridge information for a Terraform provider. This is abstracted primarily for testing purposes.

func NewMultiProviderInfoSource

func NewMultiProviderInfoSource(sources ...ProviderInfoSource) ProviderInfoSource

type ProviderNode

type ProviderNode struct {
	// Config is the provider's raw Terraform configuration.
	Config *config.ProviderConfig
	// Location is the location of this node's definition in the original Terraform configuration.
	Location token.Pos
	// Comments is the set of comments associated with this node, if any.
	Comments *Comments
	// Deps is the list of the provider's dependencies as implied by the nodes referenced by its configuration.
	Deps []Node
	// Name is the name of the provider.
	Name string
	// Alias is the provider's alias, if any.
	Alias string
	// Properties is the bound form of the provider's configuration properties.
	Properties *BoundMapProperty
	// Info is the set of Pulumi-specific information about this particular resource provider. Of particular interest
	// is per-{resource,data source} schema information, which is used to calculate names and types for resources and
	// their properties.
	Info *tfbridge.ProviderInfo
	// PluginName is the name of the Pulumi plugin associated with this provider.
	PluginName string
	// Implicit is true if this provider node was generated by an implicit provider block.
	Implicit bool
}

A ProviderNode is the analyzed form of a provider instantiation in a Terraform configuration.

func (*ProviderNode) Dependencies

func (p *ProviderNode) Dependencies() []Node

Depdendencies returns the list of nodes the provider depends on.

func (*ProviderNode) GetLocation

func (p *ProviderNode) GetLocation() token.Pos

func (*ProviderNode) ID

func (p *ProviderNode) ID() string

type ResourceNode

type ResourceNode struct {
	// Config is the resource's raw Terraform configuration.
	Config *config.Resource
	// Location is the location of this node's definition in the original Terraform configuration.
	Location token.Pos
	// Comments is the set of comments associated with this node, if any.
	Comments *Comments
	// Deps is the list of the resource's dependencies as implied by the nodes referenced by its configuration.
	Deps []Node
	// ExplicitDeps is the list of the resource's explicit dependencies. This is a subset of Deps.
	ExplicitDeps []Node
	// Type is the type of the resource.
	Type string
	// Name is the name of the resource.
	Name string
	// IsDataSource is true if this resource represents a data source invocation.
	IsDataSource bool
	// Provider is a reference to the resource's provider. Consumers of this package will never observe a nil value in
	// this field.
	Provider *ProviderNode
	// Count is the bound form of the resource's count property.
	Count BoundNode
	// Properties is the bound form of the resource's configuration properties.
	Properties *BoundMapProperty
	// Timeouts is the bound set of timeout data, if any.
	Timeouts *BoundMapProperty
	// IgnoreChanges is the bound list of properties with ignored changes, if any.
	IgnoreChanges []string
}

A ResourceNode is the analyzed form of a resource or data source instatiation in a Terraform configuration. In keeping with Terraform's internal terminology, these concepts will be collectively referred to as resources: when it is necessary to differentiate between the two, the former are referred to as "managed resources" and the latter as "data resources".

func (*ResourceNode) Dependencies

func (r *ResourceNode) Dependencies() []Node

Depdendencies returns the list of nodes the resource depends on.

func (*ResourceNode) GetLocation

func (r *ResourceNode) GetLocation() token.Pos

func (*ResourceNode) ID

func (r *ResourceNode) ID() string

func (*ResourceNode) Schemas

func (r *ResourceNode) Schemas() Schemas

Schemas returns the Terraform and Pulumi schemas for this resource. These schemas can are principally used to calculate the types and names of a resource's properties during binding and code generation.

func (*ResourceNode) Tok

func (r *ResourceNode) Tok() (string, bool)

Tok returns the Pulumi token for this resource. These tokens are of the form "provider:module/func:member".

type Schemas

type Schemas struct {
	TF     shim.Schema
	TFRes  shim.Resource
	Pulumi *tfbridge.SchemaInfo
}

Schemas bundles a property's Terraform and Pulumi schema information into a single type. This information is then used to determine type and name information for the property. If the Terraform property is of a composite type--a map, list, or set--the property's schemas may also be used to access child schemas.

func (Schemas) ElemSchemas

func (s Schemas) ElemSchemas() Schemas

ElemSchemas returns the element Schemas for a list property.

func (Schemas) ModelType

func (s Schemas) ModelType() model.Type

ModelType returns the appropriate model type for the property associated with these Schemas.

func (Schemas) PropertySchemas

func (s Schemas) PropertySchemas(key string) Schemas

PropertySchemas returns the Schemas for the child property with the given name. If the name is an integer, this function returns the value of a call to ElemSchemas.

func (Schemas) Type

func (s Schemas) Type() Type

Type returns the appropriate bound type for the property associated with these Schemas.

type Type

type Type uint32

Type represents the type of a single node in a bound property tree. Types are fairly simplistic: in addition to the primitive types--bool, string, number, map, and unknown--there are the composite types list and output. A type that is both a list and an output is considered to be an output of a list. Outputs have the semantic that their values may not be known promptly; in particular, the target language may need to introduce special elements (e.g. `apply`) to access the concrete value of an output.

const (
	// TypeInvalid is self-explanatory.
	TypeInvalid Type = 0
	// TypeBool represents the universe of boolean values.
	TypeBool Type = 1
	// TypeString represents the universe of string values.
	TypeString Type = 1 << 1
	// TypeNumber represents the universe of real number values.
	TypeNumber Type = 1 << 2
	// TypeMap represents the universe of string -> unknown values.
	TypeMap Type = 1 << 3
	// TypeUnknown represnets the universe of unknown values. These values may have any type at runtime, and dynamic
	// conversions may be necessary when assigning these values to differently-typed destinations.
	TypeUnknown Type = 1 << 4

	// TypeList represents the universe of list values. A list's element type must be a primitive type.
	TypeList Type = 1 << 5
	// TypeOutput represents the universe of output value.
	TypeOutput Type = 1 << 6
)

func (Type) ElementType

func (t Type) ElementType() Type

ElementType returns the element type of this value.

func (Type) IsList

func (t Type) IsList() bool

IsList returns true if this value represents a list type.

func (Type) IsOutput

func (t Type) IsOutput() bool

IsOutput returns true if this value represents an output type.

func (Type) ListOf

func (t Type) ListOf() Type

ListOf returns this a list type with this value as its element type.

func (Type) OutputOf

func (t Type) OutputOf() Type

ListOf returns this an output type with this value as its element type.

func (Type) String

func (t Type) String() string

String returns the string representation of this type.

type VariableNode

type VariableNode struct {
	// Config is the variable's raw Terraform configuration.
	Config *config.Variable
	// Location is the location of this node's definition in the original Terraform configuration.
	Location token.Pos
	// Comments is the set of comments associated with this node, if any.
	Comments *Comments
	// Name is the name of this variable.
	Name string
	// DefaultValue is the bound form of the variable's default value (if any).
	DefaultValue BoundNode
}

A VariableNode is the analyzed form of a Terraform variable. A VariableNode's list of dependencies is always empty.

func (*VariableNode) Dependencies

func (v *VariableNode) Dependencies() []Node

Depdendencies returns the list of nodes the variable depends on. This list is always empty.

func (*VariableNode) GetLocation

func (v *VariableNode) GetLocation() token.Pos

func (*VariableNode) ID

func (v *VariableNode) ID() string

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier