addrs

package
v0.50.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MPL-2.0, MPL-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const Self selfT = 0

Self is the address of the special object "self" that behaves as an alias for a containing object currently in scope.

Variables

This section is empty.

Functions

This section is empty.

Types

type CountAttr

type CountAttr struct {
	Name string
	// contains filtered or unexported fields
}

CountAttr is the address of an attribute of the "count" object in the interpolation scope, like "count.index".

func (CountAttr) String

func (ca CountAttr) String() string

type ForEachAttr

type ForEachAttr struct {
	Name string
	// contains filtered or unexported fields
}

ForEachAttr is the address of an attribute referencing the current "for_each" object in the interpolation scope, addressed using the "each" keyword, ex. "each.key" and "each.value"

func (ForEachAttr) String

func (f ForEachAttr) String() string

type InputVariable

type InputVariable struct {
	Name string
	// contains filtered or unexported fields
}

InputVariable is the address of an input variable.

func (InputVariable) String

func (v InputVariable) String() string

type InstanceKey

type InstanceKey interface {
	String() string

	// Value returns the cty.Value of the appropriate type for the InstanceKey
	// value.
	Value() cty.Value
	// contains filtered or unexported methods
}

InstanceKey represents the key of an instance within an object that contains multiple instances due to using "count" or "for_each" arguments in configuration.

IntKey and StringKey are the two implementations of this type. No other implementations are allowed. The single instance of an object that _isn't_ using "count" or "for_each" is represented by NoKey, which is a nil InstanceKey.

var NoKey InstanceKey

NoKey represents the absense of an InstanceKey, for the single instance of a configuration object that does not use "count" or "for_each" at all.

func ParseInstanceKey

func ParseInstanceKey(key cty.Value) (InstanceKey, error)

ParseInstanceKey returns the instance key corresponding to the given value, which must be known and non-null.

If an unknown or null value is provided then this function will panic. This function is intended to deal with the values that would naturally be found in a hcl.TraverseIndex, which (when parsed from source, at least) can never contain unknown or null values.

type InstanceKeyType

type InstanceKeyType rune

InstanceKeyType represents the different types of instance key that are supported. Usually it is sufficient to simply type-assert an InstanceKey value to either IntKey or StringKey, but this type and its values can be used to represent the types themselves, rather than specific values of those types.

const (
	NoKeyType     InstanceKeyType = 0
	IntKeyType    InstanceKeyType = 'I'
	StringKeyType InstanceKeyType = 'S'
)

type IntKey

type IntKey int

IntKey is the InstanceKey representation representing integer indices, as used when the "count" argument is specified or if for_each is used with a sequence type.

func (IntKey) String

func (k IntKey) String() string

func (IntKey) Value

func (k IntKey) Value() cty.Value

type LocalValue

type LocalValue struct {
	Name string
	// contains filtered or unexported fields
}

LocalValue is the address of a local value.

func (LocalValue) String

func (v LocalValue) String() string

type Module

type Module []string

Module is an address for a module call within configuration. This is the static counterpart of ModuleInstance, representing a traversal through the static module call tree in configuration and does not take into account the potentially-multiple instances of a module that might be created by "count" and "for_each" arguments within those calls.

This type should be used only in very specialized cases when working with the static module call tree. Type ModuleInstance is appropriate in more cases.

Although Module is a slice, it should be treated as immutable after creation.

var RootModule Module

RootModule is the module address representing the root of the static module call tree, which is also the zero value of Module.

Note that this is not the root of the dynamic module tree, which is instead represented by RootModuleInstance.

func (Module) IsRoot

func (m Module) IsRoot() bool

IsRoot returns true if the receiver is the address of the root module, or false otherwise.

func (Module) String

func (m Module) String() string

func (Module) UnkeyedInstanceShim

func (m Module) UnkeyedInstanceShim() ModuleInstance

UnkeyedInstanceShim is a shim method for converting a Module address to the equivalent ModuleInstance address that assumes that no modules have keyed instances.

This is a temporary allowance for the fact that Terraform does not presently support "count" and "for_each" on modules, and thus graph building code that derives graph nodes from configuration must just assume unkeyed modules in order to construct the graph. At a later time when "count" and "for_each" support is added for modules, all callers of this method will need to be reworked to allow for keyed module instances.

type ModuleCall

type ModuleCall struct {
	Name string
	// contains filtered or unexported fields
}

ModuleCall is the address of a call from the current module to a child module.

func (ModuleCall) String

func (c ModuleCall) String() string

type ModuleCallInstance

type ModuleCallInstance struct {
	Call ModuleCall
	Key  InstanceKey
	// contains filtered or unexported fields
}

ModuleCallInstance is the address of one instance of a module created from a module call, which might create multiple instances using "count" or "for_each" arguments.

There is no "Abs" version of ModuleCallInstance because an absolute module path is represented by ModuleInstance.

func (ModuleCallInstance) String

func (c ModuleCallInstance) String() string

type ModuleCallInstanceOutput added in v0.34.0

type ModuleCallInstanceOutput struct {
	Call ModuleCallInstance
	Name string
	// contains filtered or unexported fields
}

ModuleCallInstanceOutput is the address of a particular named output produced by an instance of a module call.

func (ModuleCallInstanceOutput) String added in v0.34.0

func (co ModuleCallInstanceOutput) String() string

type ModuleInstance

type ModuleInstance []ModuleInstanceStep

ModuleInstance is an address for a particular module instance within the dynamic module tree. This is an extension of the static traversals represented by type Module that deals with the possibility of a single module call producing multiple instances via the "count" and "for_each" arguments.

Although ModuleInstance is a slice, it should be treated as immutable after creation.

var RootModuleInstance ModuleInstance

RootModuleInstance is the module instance address representing the root module, which is also the zero value of ModuleInstance.

func (ModuleInstance) IsRoot

func (m ModuleInstance) IsRoot() bool

IsRoot returns true if the receiver is the address of the root module instance, or false otherwise.

func (ModuleInstance) String

func (m ModuleInstance) String() string

String returns a string representation of the receiver, in the format used within e.g. user-provided resource addresses.

The address of the root module has the empty string as its representation.

type ModuleInstanceStep

type ModuleInstanceStep struct {
	Name        string
	InstanceKey InstanceKey
}

ModuleInstanceStep is a single traversal step through the dynamic module tree. It is used only as part of ModuleInstance.

func (ModuleInstanceStep) String

func (s ModuleInstanceStep) String() string

type ModuleSource added in v0.32.0

type ModuleSource interface {
	// String returns a full representation of the address, including any
	// additional components that are typically implied by omission in
	// user-written addresses.
	//
	// We typically use this longer representation in error message, in case
	// the inclusion of normally-omitted components is helpful in debugging
	// unexpected behavior.
	String() string
	// contains filtered or unexported methods
}

ModuleSource is the general type for all three of the possible module source address types. The concrete implementations of this are ModuleSourceLocal and ModuleSourceRemote.

func ParseModuleSource added in v0.32.0

func ParseModuleSource(raw string) (ModuleSource, error)

ParseModuleSource parses a module source address as given in the "source" argument inside a "module" block in the configuration.

Unlike Terraform, this function only categorizes sources into "local" and "remote".

type ModuleSourceLocal added in v0.32.0

type ModuleSourceLocal string

ModuleSourceLocal is a ModuleSource representing a local path reference from the caller's directory to the callee's directory within the same module package.

A "module package" here means a set of modules distributed together in the same archive, repository, or similar. That's a significant distinction because we always download and cache entire module packages at once, and then create relative references within the same directory in order to ensure all modules in the package are looking at a consistent filesystem layout. We also assume that modules within a package are maintained together, which means that cross-cutting maintenence across all of them would be possible.

The actual value of a ModuleSourceLocal is a normalized relative path using forward slashes, even on operating systems that have other conventions, because we're representing traversal within the logical filesystem represented by the containing package, not actually within the physical filesystem we unpacked the package into. We should typically not construct ModuleSourceLocal values directly, except in tests where we can ensure the value meets our assumptions. Use ParseModuleSource instead if the input string is not hard-coded in the program.

func (ModuleSourceLocal) String added in v0.32.0

func (s ModuleSourceLocal) String() string

type ModuleSourceRemote added in v0.32.0

type ModuleSourceRemote string

ModuleSourceRemote is a ModuleSource representing a remote location from which we can retrieve a module package.

Note that unlike Terraform, this also includes the address of the ModuleSourceRegistry equivalent. TFLint does not need to distinguish between ModuleSourceRemote and ModuleSourceRegistry, so they are all treated as ModuleSourceRemote.

func (ModuleSourceRemote) String added in v0.32.0

func (s ModuleSourceRemote) String() string

type OutputValue

type OutputValue struct {
	Name string
}

OutputValue is the address of an output value, in the context of the module that is defining it.

This is related to but separate from ModuleCallOutput, which represents a module output from the perspective of its parent module. Since output values cannot be represented from the module where they are defined, OutputValue is not Referenceable, while ModuleCallOutput is.

func (OutputValue) String

func (v OutputValue) String() string

type PathAttr

type PathAttr struct {
	Name string
	// contains filtered or unexported fields
}

PathAttr is the address of an attribute of the "path" object in the interpolation scope, like "path.module".

func (PathAttr) String

func (pa PathAttr) String() string

type Reference

type Reference struct {
	Subject     Referenceable
	SourceRange hcl.Range
	Remaining   hcl.Traversal
}

Reference describes a reference to an address with source location information.

func ParseRef

func ParseRef(traversal hcl.Traversal) (*Reference, hcl.Diagnostics)

ParseRef attempts to extract a referencable address from the prefix of the given traversal, which must be an absolute traversal or this function will panic.

If no error diagnostics are returned, the returned reference includes the address that was extracted, the source range it was extracted from, and any remaining relative traversal that was not consumed as part of the reference.

If error diagnostics are returned then the Reference value is invalid and must not be used.

func ParseRefStr

func ParseRefStr(str string) (*Reference, hcl.Diagnostics)

ParseRefStr is a helper wrapper around ParseRef that takes a string and parses it with the HCL native syntax traversal parser before interpreting it.

This should be used only in specialized situations since it will cause the created references to not have any meaningful source location information. If a reference string is coming from a source that should be identified in error messages then the caller should instead parse it directly using a suitable function from the HCL API and pass the traversal itself to ParseRef.

Error diagnostics are returned if either the parsing fails or the analysis of the traversal fails. There is no way for the caller to distinguish the two kinds of diagnostics programmatically. If error diagnostics are returned the returned reference may be nil or incomplete.

type Referenceable

type Referenceable interface {

	// String produces a string representation of the address that could be
	// parsed as a HCL traversal and passed to ParseRef to produce an identical
	// result.
	String() string
	// contains filtered or unexported methods
}

Referenceable is an interface implemented by all address types that can appear as references in configuration language expressions.

type Resource

type Resource struct {
	Mode ResourceMode
	Type string
	Name string
	// contains filtered or unexported fields
}

Resource is an address for a resource block within configuration, which contains potentially-multiple resource instances if that configuration block uses "count" or "for_each".

func (Resource) String

func (r Resource) String() string

type ResourceInstance

type ResourceInstance struct {
	Resource Resource
	Key      InstanceKey
	// contains filtered or unexported fields
}

ResourceInstance is an address for a specific instance of a resource. When a resource is defined in configuration with "count" or "for_each" it produces zero or more instances, which can be addressed using this type.

func (ResourceInstance) ContainingResource

func (r ResourceInstance) ContainingResource() Resource

func (ResourceInstance) String

func (r ResourceInstance) String() string

type ResourceMode

type ResourceMode rune

ResourceMode defines which lifecycle applies to a given resource. Each resource lifecycle has a slightly different address format.

const (
	// InvalidResourceMode is the zero value of ResourceMode and is not
	// a valid resource mode.
	InvalidResourceMode ResourceMode = 0

	// ManagedResourceMode indicates a managed resource, as defined by
	// "resource" blocks in configuration.
	ManagedResourceMode ResourceMode = 'M'

	// DataResourceMode indicates a data resource, as defined by
	// "data" blocks in configuration.
	DataResourceMode ResourceMode = 'D'
)

func (ResourceMode) String added in v0.32.0

func (i ResourceMode) String() string

type StringKey

type StringKey string

StringKey is the InstanceKey representation representing string indices, as used when the "for_each" argument is specified with a map or object type.

func (StringKey) String

func (k StringKey) String() string

func (StringKey) Value

func (k StringKey) Value() cty.Value

type TerraformAttr

type TerraformAttr struct {
	Name string
	// contains filtered or unexported fields
}

TerraformAttr is the address of an attribute of the "terraform" object in the interpolation scope, like "terraform.workspace".

func (TerraformAttr) String

func (ta TerraformAttr) String() string

Jump to

Keyboard shortcuts

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