terraform

package
v0.54.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Schema = &hcl.BodySchema{
	Blocks: []hcl.BlockHeaderSchema{
		{
			Type: "terraform",
		},
		{
			Type: "required_providers",
		},
		{
			Type:       "provider",
			LabelNames: []string{"name"},
		},
		{
			Type:       "variable",
			LabelNames: []string{"name"},
		},
		{
			Type: "locals",
		},
		{
			Type:       "output",
			LabelNames: []string{"name"},
		},
		{
			Type:       "module",
			LabelNames: []string{"name"},
		},
		{
			Type:       "check",
			LabelNames: []string{"name"},
		},
		{
			Type:       "resource",
			LabelNames: []string{"type", "name"},
		},
		{
			Type:       "data",
			LabelNames: []string{"type", "name"},
		},
		{
			Type: "moved",
		},
		{
			Type: "import",
		},
		{
			Type: "removed",
		},
	},
}

Schema is regularly lifted from terraform source to ensure compatibility

View Source
var TypeCheck = Type{
	// contains filtered or unexported fields
}
View Source
var TypeData = Type{
	// contains filtered or unexported fields
}
View Source
var TypeImport = Type{
	// contains filtered or unexported fields
}
View Source
var TypeLocal = Type{
	// contains filtered or unexported fields
}
View Source
var TypeModule = Type{
	// contains filtered or unexported fields
}
View Source
var TypeMoved = Type{
	// contains filtered or unexported fields
}
View Source
var TypeOutput = Type{
	// contains filtered or unexported fields
}
View Source
var TypeProvider = Type{
	// contains filtered or unexported fields
}
View Source
var TypeResource = Type{
	// contains filtered or unexported fields
}
View Source
var TypeTerraform = Type{
	// contains filtered or unexported fields
}
View Source
var TypeVariable = Type{
	// contains filtered or unexported fields
}

Functions

func IsValidBlockReference

func IsValidBlockReference(name string) bool

func IsValidType

func IsValidType(name string) bool

func MapNestedAttribute

func MapNestedAttribute[T any](block *Block, path string, f func(attr *Attribute, parent *Block) T) T

Types

type Attribute

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

func NewAttribute

func NewAttribute(attr *hcl.Attribute, ctx *context.Context, module string, parent iacTypes.Metadata, parentRef Reference, moduleSource string, moduleFS fs.FS) *Attribute

func (*Attribute) AllReferences

func (a *Attribute) AllReferences(blocks ...*Block) []*Reference

nolint

func (*Attribute) AsBoolValueOrDefault

func (a *Attribute) AsBoolValueOrDefault(defaultValue bool, parent *Block) iacTypes.BoolValue

func (*Attribute) AsBytesValueOrDefault

func (a *Attribute) AsBytesValueOrDefault(defaultValue []byte, parent *Block) iacTypes.BytesValue

func (*Attribute) AsIntValueOrDefault

func (a *Attribute) AsIntValueOrDefault(defaultValue int, parent *Block) iacTypes.IntValue

func (*Attribute) AsMapValue

func (a *Attribute) AsMapValue() iacTypes.MapValue

func (*Attribute) AsNumber

func (a *Attribute) AsNumber() float64

func (*Attribute) AsStringValueOrDefault

func (a *Attribute) AsStringValueOrDefault(defaultValue string, parent *Block) iacTypes.StringValue

func (*Attribute) AsStringValueSliceOrEmpty

func (a *Attribute) AsStringValueSliceOrEmpty() (stringValues []iacTypes.StringValue)

func (*Attribute) AsStringValues

func (a *Attribute) AsStringValues() iacTypes.StringValueList

func (*Attribute) AsStringValuesOrDefault

func (a *Attribute) AsStringValuesOrDefault(parent *Block, defaults ...string) []iacTypes.StringValue

func (*Attribute) Contains

func (a *Attribute) Contains(checkValue any, equalityOptions ...EqualityOption) bool

func (*Attribute) DecodeVarType

func (a *Attribute) DecodeVarType() (cty.Type, *typeexpr.Defaults, error)

func (*Attribute) Each

func (a *Attribute) Each(f func(key cty.Value, val cty.Value)) error

func (*Attribute) EndsWith

func (a *Attribute) EndsWith(suffix any) bool

func (*Attribute) Equals

func (a *Attribute) Equals(checkValue any, equalityOptions ...EqualityOption) bool

func (*Attribute) GetMetadata

func (a *Attribute) GetMetadata() iacTypes.Metadata

func (*Attribute) GetRawValue

func (a *Attribute) GetRawValue() any

func (*Attribute) GreaterThan

func (a *Attribute) GreaterThan(checkValue any) bool

func (*Attribute) GreaterThanOrEqualTo

func (a *Attribute) GreaterThanOrEqualTo(checkValue any) bool

func (*Attribute) HasIntersect

func (a *Attribute) HasIntersect(checkValues ...any) bool

func (*Attribute) IsAny

func (a *Attribute) IsAny(options ...any) bool

func (*Attribute) IsBool

func (a *Attribute) IsBool() bool

func (*Attribute) IsDataBlockReference

func (a *Attribute) IsDataBlockReference() bool

func (*Attribute) IsEmpty

func (a *Attribute) IsEmpty() bool

func (*Attribute) IsFalse

func (a *Attribute) IsFalse() bool

func (*Attribute) IsIterable

func (a *Attribute) IsIterable() bool

func (*Attribute) IsLiteral

func (a *Attribute) IsLiteral() bool

func (*Attribute) IsMapOrObject

func (a *Attribute) IsMapOrObject() bool

func (*Attribute) IsNil

func (a *Attribute) IsNil() bool

func (*Attribute) IsNone

func (a *Attribute) IsNone(options ...any) bool

func (*Attribute) IsNotAny

func (a *Attribute) IsNotAny(options ...any) bool

func (*Attribute) IsNotEmpty

func (a *Attribute) IsNotEmpty() bool

func (*Attribute) IsNotNil

func (a *Attribute) IsNotNil() bool

func (*Attribute) IsNotResolvable

func (a *Attribute) IsNotResolvable() bool

func (*Attribute) IsNumber

func (a *Attribute) IsNumber() bool

func (*Attribute) IsResolvable

func (a *Attribute) IsResolvable() bool

func (*Attribute) IsResourceBlockReference

func (a *Attribute) IsResourceBlockReference(resourceType string) bool

func (*Attribute) IsString

func (a *Attribute) IsString() bool

func (*Attribute) IsTrue

func (a *Attribute) IsTrue() bool

func (*Attribute) LessThan

func (a *Attribute) LessThan(checkValue any) bool

func (*Attribute) LessThanOrEqualTo

func (a *Attribute) LessThanOrEqualTo(checkValue any) bool

func (*Attribute) MapValue

func (a *Attribute) MapValue(mapKey string) cty.Value

func (*Attribute) Name

func (a *Attribute) Name() string

func (*Attribute) NotContains

func (a *Attribute) NotContains(checkValue any, equalityOptions ...EqualityOption) bool

func (*Attribute) NotEqual

func (a *Attribute) NotEqual(checkValue any, equalityOptions ...EqualityOption) bool

func (*Attribute) NullableValue

func (a *Attribute) NullableValue() (ctyVal cty.Value)

Allows a null value for a variable https://developer.hashicorp.com/terraform/language/expressions/types#null

func (*Attribute) OnlyContains

func (a *Attribute) OnlyContains(checkValue any) bool

func (*Attribute) References

func (a *Attribute) References(r Reference) bool

func (*Attribute) ReferencesBlock

func (a *Attribute) ReferencesBlock(b *Block) bool

func (*Attribute) RegexMatches

func (a *Attribute) RegexMatches(re regexp.Regexp) bool

func (*Attribute) StartsWith

func (a *Attribute) StartsWith(prefix any) bool

func (*Attribute) Type

func (a *Attribute) Type() cty.Type

func (*Attribute) Value

func (a *Attribute) Value() (ctyVal cty.Value)

type Block

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

func NewBlock

func NewBlock(hclBlock *hcl.Block, ctx *context.Context, moduleBlock *Block, parentBlock *Block, moduleSource string,
	moduleFS fs.FS, index ...cty.Value) *Block

func (*Block) AllBlocks

func (b *Block) AllBlocks() Blocks

func (*Block) Attributes

func (b *Block) Attributes() map[string]*Attribute

func (*Block) Clone

func (b *Block) Clone(index cty.Value) *Block

func (*Block) Context

func (b *Block) Context() *context.Context

func (*Block) FullName

func (b *Block) FullName() string

func (*Block) GetAttribute

func (b *Block) GetAttribute(name string) *Attribute

func (*Block) GetAttributes

func (b *Block) GetAttributes() []*Attribute

func (*Block) GetBlock

func (b *Block) GetBlock(name string) *Block

func (*Block) GetBlocks

func (b *Block) GetBlocks(name string) Blocks

func (*Block) GetFirstMatchingBlock

func (b *Block) GetFirstMatchingBlock(names ...string) *Block

func (*Block) GetMetadata

func (b *Block) GetMetadata() iacTypes.Metadata

func (*Block) GetNestedAttribute

func (b *Block) GetNestedAttribute(name string) (*Attribute, *Block)

func (*Block) GetRawValue

func (b *Block) GetRawValue() any

func (*Block) HasChild

func (b *Block) HasChild(childElement string) bool

func (*Block) ID

func (b *Block) ID() string

func (*Block) InModule

func (b *Block) InModule() bool

func (*Block) InjectBlock

func (b *Block) InjectBlock(block *Block, name string)

func (*Block) IsEmpty

func (b *Block) IsEmpty() bool

func (*Block) IsExpanded

func (b *Block) IsExpanded() bool

func (*Block) IsNil

func (b *Block) IsNil() bool

func (*Block) IsNotNil

func (b *Block) IsNotNil() bool

func (*Block) IsResourceType

func (b *Block) IsResourceType(resourceType string) bool

func (*Block) Label

func (b *Block) Label() string

func (*Block) Labels

func (b *Block) Labels() []string

func (*Block) LocalName

func (b *Block) LocalName() string

LocalName is the name relative to the current module

func (*Block) MarkExpanded

func (b *Block) MarkExpanded()

func (*Block) MissingChild

func (b *Block) MissingChild(childElement string) bool

func (*Block) MissingNestedChild

func (b *Block) MissingNestedChild(name string) bool

func (*Block) ModuleName

func (b *Block) ModuleName() string

func (*Block) NameLabel

func (b *Block) NameLabel() string

func (*Block) OverrideContext

func (b *Block) OverrideContext(ctx *context.Context)

func (*Block) Reference

func (b *Block) Reference() Reference

func (*Block) Type

func (b *Block) Type() string

func (*Block) TypeLabel

func (b *Block) TypeLabel() string

func (*Block) UniqueName

func (b *Block) UniqueName() string

func (*Block) Values

func (b *Block) Values() cty.Value

type Blocks

type Blocks []*Block

func (Blocks) OfType

func (blocks Blocks) OfType(t string) Blocks

func (Blocks) WithID

func (blocks Blocks) WithID(id string) *Block

type EqualityOption

type EqualityOption int
const (
	IgnoreCase EqualityOption = iota
)

type Module

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

func NewModule

func NewModule(rootPath, modulePath string, blocks Blocks, ignores ignore.Rules) *Module

func (*Module) GetBlockByID

func (c *Module) GetBlockByID(id string) (*Block, error)

func (*Module) GetBlocks

func (c *Module) GetBlocks() Blocks

func (*Module) GetBlocksByTypeLabel

func (h *Module) GetBlocksByTypeLabel(typeLabel string) Blocks

func (*Module) GetDatasByType

func (c *Module) GetDatasByType(label string) Blocks

func (*Module) GetProviderBlocksByProvider

func (c *Module) GetProviderBlocksByProvider(providerName, alias string) Blocks

func (*Module) GetReferencedBlock

func (c *Module) GetReferencedBlock(referringAttr *Attribute, parentBlock *Block) (*Block, error)

func (*Module) GetReferencingBlocks

func (c *Module) GetReferencingBlocks(originalBlock *Block, referencingType, referencingLabel, referencingAttributeName string) Blocks

func (*Module) GetReferencingResources

func (c *Module) GetReferencingResources(originalBlock *Block, referencingLabel, referencingAttributeName string) Blocks

func (*Module) GetResourcesByIDs

func (c *Module) GetResourcesByIDs(ids ...string) Blocks

func (*Module) GetResourcesByType

func (c *Module) GetResourcesByType(labels ...string) Blocks

func (*Module) GetsModulesBySource

func (c *Module) GetsModulesBySource(moduleSource string) (Blocks, error)

func (*Module) Ignores

func (c *Module) Ignores() ignore.Rules

func (*Module) RootPath

func (c *Module) RootPath() string

func (*Module) SetParent

func (c *Module) SetParent(parent *Module)

type Modules

type Modules []*Module

func (Modules) GetBlockById

func (m Modules) GetBlockById(id string) (*Block, error)

func (Modules) GetBlockByIgnoreRange

func (m Modules) GetBlockByIgnoreRange(blockMetadata *types.Metadata) *Block

func (Modules) GetBlocks

func (m Modules) GetBlocks() Blocks

func (Modules) GetChildResourceIDMapByType

func (m Modules) GetChildResourceIDMapByType(typeLabels ...string) ResourceIDResolutions

func (Modules) GetDatasByType added in v0.53.0

func (m Modules) GetDatasByType(typeLabel string) Blocks

func (Modules) GetReferencedBlock

func (m Modules) GetReferencedBlock(referringAttr *Attribute, parentBlock *Block) (*Block, error)

func (Modules) GetReferencingResources

func (m Modules) GetReferencingResources(originalBlock *Block, referencingLabel, referencingAttributeName string) Blocks

func (Modules) GetResourceByIDs

func (m Modules) GetResourceByIDs(id ...string) Blocks

func (Modules) GetResourcesByType

func (m Modules) GetResourcesByType(typeLabel ...string) Blocks

type PlanBlock

type PlanBlock struct {
	Type       string
	Name       string
	BlockType  string
	Blocks     map[string]map[string]any
	Attributes map[string]any
}

func NewPlanBlock

func NewPlanBlock(blockType, resourceType, resourceName string) *PlanBlock

func (*PlanBlock) HasAttribute

func (rb *PlanBlock) HasAttribute(attribute string) bool

func (*PlanBlock) ToHCL

func (rb *PlanBlock) ToHCL() string

type PlanReference

type PlanReference struct {
	Value any
}

type Reference

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

func (Reference) BlockType

func (r Reference) BlockType() Type

func (Reference) HumanReadable

func (r Reference) HumanReadable() string

func (Reference) Key

func (r Reference) Key() string

func (Reference) KeyBracketed

func (r Reference) KeyBracketed() string

func (Reference) LogicalID

func (r Reference) LogicalID() string

func (Reference) NameLabel

func (r Reference) NameLabel() string

func (Reference) RawKey

func (r Reference) RawKey() cty.Value

func (Reference) RefersTo

func (r Reference) RefersTo(other Reference) bool

func (*Reference) SetKey

func (r *Reference) SetKey(key cty.Value)

func (Reference) String

func (r Reference) String() string

func (Reference) TypeLabel

func (r Reference) TypeLabel() string

type ResourceIDResolutions

type ResourceIDResolutions map[string]bool

func (ResourceIDResolutions) Orphans

func (r ResourceIDResolutions) Orphans() (orphanIDs []string)

func (ResourceIDResolutions) Resolve

func (r ResourceIDResolutions) Resolve(id string)

type Type

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

func TypeFromRefName

func TypeFromRefName(name string) (*Type, error)

func (Type) Name

func (t Type) Name() string

func (Type) ShortName

func (t Type) ShortName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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