terraform

package
v0.94.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 17 Imported by: 15

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",
		},
	},
}

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 added in v0.93.0

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 defsecTypes.Metadata, parentRef Reference, moduleSource string, moduleFS fs.FS) *Attribute

func (*Attribute) AllReferences

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

func (*Attribute) AsBoolValueOrDefault

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

func (*Attribute) AsBytesValueOrDefault

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

func (*Attribute) AsIntValueOrDefault

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

func (*Attribute) AsMapValue added in v0.94.0

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

func (*Attribute) AsNumber added in v0.68.7

func (a *Attribute) AsNumber() float64

func (*Attribute) AsStringValueOrDefault

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

func (*Attribute) AsStringValueSliceOrEmpty added in v0.60.0

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

func (*Attribute) AsStringValues added in v0.60.0

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

func (*Attribute) AsStringValuesOrDefault added in v0.94.0

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

func (*Attribute) Contains

func (a *Attribute) Contains(checkValue interface{}, equalityOptions ...EqualityOption) bool

func (*Attribute) DecodeVarType added in v0.93.0

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 interface{}) bool

func (*Attribute) Equals

func (a *Attribute) Equals(checkValue interface{}, equalityOptions ...EqualityOption) bool

func (*Attribute) GetMetadata

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

func (*Attribute) GetRawValue

func (a *Attribute) GetRawValue() interface{}

func (*Attribute) GreaterThan

func (a *Attribute) GreaterThan(checkValue interface{}) bool

func (*Attribute) GreaterThanOrEqualTo

func (a *Attribute) GreaterThanOrEqualTo(checkValue interface{}) bool

func (*Attribute) HasIntersect

func (a *Attribute) HasIntersect(checkValues ...interface{}) bool

func (*Attribute) IsAny

func (a *Attribute) IsAny(options ...interface{}) 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 added in v0.94.0

func (a *Attribute) IsMapOrObject() bool

func (*Attribute) IsNil

func (a *Attribute) IsNil() bool

func (*Attribute) IsNone

func (a *Attribute) IsNone(options ...interface{}) bool

func (*Attribute) IsNotAny

func (a *Attribute) IsNotAny(options ...interface{}) 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 interface{}) bool

func (*Attribute) LessThanOrEqualTo

func (a *Attribute) LessThanOrEqualTo(checkValue interface{}) 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 interface{}, equalityOptions ...EqualityOption) bool

func (*Attribute) NotEqual

func (a *Attribute) NotEqual(checkValue interface{}, equalityOptions ...EqualityOption) bool

func (*Attribute) NullableValue added in v0.90.2

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 added in v0.76.0

func (a *Attribute) OnlyContains(checkValue interface{}) 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 interface{}) 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() defsecTypes.Metadata

func (*Block) GetNestedAttribute

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

func (*Block) GetRawValue

func (b *Block) GetRawValue() interface{}

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) IsCountExpanded

func (b *Block) IsCountExpanded() bool

func (*Block) IsEmpty

func (b *Block) IsEmpty() 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) 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 added in v0.77.0

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 Ignore

type Ignore struct {
	Range     defsecTypes.Range
	RuleID    string
	Expiry    *time.Time
	Workspace string
	Block     bool
	Params    map[string]string
}

func (Ignore) Covering

func (ignore Ignore) Covering(modules Modules, m defsecTypes.Metadata, workspace string, ids ...string) bool

func (Ignore) MatchParams

func (ignore Ignore) MatchParams(modules Modules, blockMetadata *defsecTypes.Metadata) bool

type Ignores

type Ignores []Ignore

func (Ignores) Covering

func (ignores Ignores) Covering(modules Modules, m defsecTypes.Metadata, workspace string, ids ...string) *Ignore

type Module

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

func NewModule

func NewModule(rootPath string, modulePath string, blocks Blocks, ignores Ignores, local bool) *Module

func (*Module) GetBlockByID added in v0.71.10

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 string, 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 string, referencingLabel string, referencingAttributeName string) Blocks

func (*Module) GetReferencingResources

func (c *Module) GetReferencingResources(originalBlock *Block, referencingLabel string, 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() Ignores

func (*Module) RootPath added in v0.48.0

func (c *Module) RootPath() string

func (*Module) SetParent added in v0.93.1

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

type Modules

type Modules []*Module

func (Modules) ChildModulesPaths added in v0.93.1

func (m Modules) ChildModulesPaths() []string

func (Modules) GetBlockById added in v0.71.10

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) GetReferencedBlock

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

func (Modules) GetReferencingResources

func (m Modules) GetReferencingResources(originalBlock *Block, referencingLabel string, 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 added in v0.39.0

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

func NewPlanBlock added in v0.39.0

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

func (*PlanBlock) HasAttribute added in v0.39.0

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

func (*PlanBlock) ToHCL added in v0.39.0

func (rb *PlanBlock) ToHCL() string

type PlanReference added in v0.39.0

type PlanReference struct {
	Value interface{}
}

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