pkg

package
v0.0.0-...-9e3ca3c Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AbsDir func(string) (string, error) = filepath.Abs
View Source
var ToHclFunc = function.New(&function.Spec{
	Description: "Convert an cty.Value to HCL config in string format",
	Params: []function.Parameter{
		{
			Name: "input",
			Type: cty.DynamicPseudoType,
		},
	},
	Type: function.StaticReturnType(cty.String),
	Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
		input := args[0]
		return cty.StringVal(string(hclwrite.TokensForValue(input).BuildTokens(nil).Bytes())), nil
	},
})

Functions

func LoadMPTFHclBlocks

func LoadMPTFHclBlocks(ignoreUnsupportedBlock bool, dir string) ([]*golden.HclBlock, error)

Types

type AppendBlockBodyTransform

type AppendBlockBodyTransform struct {
	*golden.BaseBlock
	*BaseTransform
	TargetBlockAddress string `hcl:"target_block_address" validate:"required"`
	BlockBody          string `hcl:"block_body" validate:"required"`
}

func (*AppendBlockBodyTransform) Apply

func (u *AppendBlockBodyTransform) Apply() error

func (*AppendBlockBodyTransform) PatchWriteBlock

func (u *AppendBlockBodyTransform) PatchWriteBlock(dest terraform.Block, patch *hclwrite.Body)

func (*AppendBlockBodyTransform) String

func (u *AppendBlockBodyTransform) String() string

func (*AppendBlockBodyTransform) Type

func (u *AppendBlockBodyTransform) Type() string

type BaseData

type BaseData struct{}

func (*BaseData) AddressLength

func (rd *BaseData) AddressLength() int

func (*BaseData) BlockType

func (bd *BaseData) BlockType() string

func (*BaseData) CanExecutePrePlan

func (bd *BaseData) CanExecutePrePlan() bool

func (*BaseData) Data

func (bd *BaseData) Data()

type BaseTransform

type BaseTransform struct{}

func (*BaseTransform) AddressLength

func (bt *BaseTransform) AddressLength() int

func (*BaseTransform) BlockType

func (bt *BaseTransform) BlockType() string

func (*BaseTransform) CanExecutePrePlan

func (bt *BaseTransform) CanExecutePrePlan() bool

func (*BaseTransform) Transform

func (bt *BaseTransform) Transform()

type Data

type Data interface {
	golden.PlanBlock
	Data()
}

type DataSourceData

type DataSourceData struct {
	*BaseData
	*golden.BaseBlock

	DataSourceType string    `hcl:"data_source_type,optional"`
	UseCount       bool      `hcl:"use_count,optional" default:"false"`
	UseForEach     bool      `hcl:"use_for_each,optional" default:"false"`
	Result         cty.Value `attribute:"result"`
}

func (*DataSourceData) ExecuteDuringPlan

func (dd *DataSourceData) ExecuteDuringPlan() error

func (*DataSourceData) String

func (dd *DataSourceData) String() string

func (*DataSourceData) Type

func (dd *DataSourceData) Type() string

type MetaProgrammingTFConfig

type MetaProgrammingTFConfig struct {
	*golden.BaseConfig
	// contains filtered or unexported fields
}

func NewMetaProgrammingTFConfig

func NewMetaProgrammingTFConfig(m *TerraformModuleRef, varConfigDir *string, hclBlocks []*golden.HclBlock, cliFlagAssignedVars []golden.CliFlagAssignedVariables, ctx context.Context) (*MetaProgrammingTFConfig, error)

func (*MetaProgrammingTFConfig) AddBlock

func (c *MetaProgrammingTFConfig) AddBlock(filename string, block *hclwrite.Block)

func (*MetaProgrammingTFConfig) DataBlocks

func (c *MetaProgrammingTFConfig) DataBlocks() []*terraform.RootBlock

func (*MetaProgrammingTFConfig) Init

func (c *MetaProgrammingTFConfig) Init(hclBlocks []*golden.HclBlock) error

func (*MetaProgrammingTFConfig) LocalBlocks

func (c *MetaProgrammingTFConfig) LocalBlocks() []*terraform.RootBlock

func (*MetaProgrammingTFConfig) ModuleBlocks

func (c *MetaProgrammingTFConfig) ModuleBlocks() []*terraform.RootBlock

func (*MetaProgrammingTFConfig) OutputBlocks

func (c *MetaProgrammingTFConfig) OutputBlocks() []*terraform.RootBlock

func (*MetaProgrammingTFConfig) ResourceBlocks

func (c *MetaProgrammingTFConfig) ResourceBlocks() []*terraform.RootBlock

func (*MetaProgrammingTFConfig) RootBlock

func (c *MetaProgrammingTFConfig) RootBlock(address string) *terraform.RootBlock

func (*MetaProgrammingTFConfig) SaveToDisk

func (c *MetaProgrammingTFConfig) SaveToDisk() error

func (*MetaProgrammingTFConfig) TerraformBlock

func (c *MetaProgrammingTFConfig) TerraformBlock() *terraform.RootBlock

func (*MetaProgrammingTFConfig) VariableBlocks

func (c *MetaProgrammingTFConfig) VariableBlocks() []*terraform.RootBlock

type MetaProgrammingTFPlan

type MetaProgrammingTFPlan struct {
	Transforms []Transform
	// contains filtered or unexported fields
}

func (*MetaProgrammingTFPlan) Apply

func (m *MetaProgrammingTFPlan) Apply() error

func (*MetaProgrammingTFPlan) String

func (m *MetaProgrammingTFPlan) String() string

type NewBlockTransform

type NewBlockTransform struct {
	*golden.BaseBlock
	*BaseTransform
	NewBlockType string   `hcl:"new_block_type"`
	FileName     string   `hcl:"filename" validate:"endswith=.tf"`
	Labels       []string `hcl:"labels,optional"`
	NewBody      string   `hcl:"body,optional"`
	// contains filtered or unexported fields
}

func (*NewBlockTransform) Apply

func (n *NewBlockTransform) Apply() error

func (*NewBlockTransform) Decode

func (n *NewBlockTransform) Decode(block *golden.HclBlock, context *hcl.EvalContext) error

func (*NewBlockTransform) Format

func (n *NewBlockTransform) Format(block *hclwrite.Block) (*hclwrite.Block, error)

func (*NewBlockTransform) NewWriteBlock

func (n *NewBlockTransform) NewWriteBlock() *hclwrite.Block

func (*NewBlockTransform) Type

func (n *NewBlockTransform) Type() string

type ProviderSchemaData

type ProviderSchemaData struct {
	*BaseData
	*golden.BaseBlock

	Source    string    `hcl:"provider_source"`
	Version   string    `hcl:"provider_version"`
	Resources cty.Value `attribute:"resources"`
}

func (*ProviderSchemaData) Convert

func (r *ProviderSchemaData) Convert(schemas map[string]*tfjson.Schema) (cty.Value, error)

func (*ProviderSchemaData) ExecuteDuringPlan

func (r *ProviderSchemaData) ExecuteDuringPlan() error

func (*ProviderSchemaData) Type

func (r *ProviderSchemaData) Type() string

type RegexReplaceExpressionTransform

type RegexReplaceExpressionTransform struct {
	*golden.BaseBlock
	*BaseTransform
	Regex       string `hcl:"regex" validate:"required"`
	Replacement string `hcl:"replacement"`
}

func (*RegexReplaceExpressionTransform) Apply

func (*RegexReplaceExpressionTransform) Type

type RemoveBlockContentBlockTransform

type RemoveBlockContentBlockTransform struct {
	*golden.BaseBlock
	*BaseTransform
	TargetBlockAddress string   `hcl:"target_block_address"`
	Paths              []string `hcl:"paths"`
}

func (*RemoveBlockContentBlockTransform) Apply

func (*RemoveBlockContentBlockTransform) Type

type Rename

type Rename struct {
	ResourceType string `hcl:"resource_type"`
	// We'll deprecate `attribute_path` in favor of `element_path`.
	AttributePath           []string `hcl:"attribute_path,optional" validate:"excluded_with=element_path"`
	ElementPath             []string `hcl:"element_path,optional" validate:"excluded_with=attribute_path,required_without=attribute_path"`
	NewName                 string   `hcl:"new_name" validate:"required"`
	RenameOnlyNewNameAbsent bool     `hcl:"rename_only_new_name_absent,optional" default:"false"`
}

type RenameAttributeOrNestedBlockTransform

type RenameAttributeOrNestedBlockTransform struct {
	*golden.BaseBlock
	*BaseTransform
	Renames []Rename `hcl:"rename,block"`
}

func (*RenameAttributeOrNestedBlockTransform) Apply

func (*RenameAttributeOrNestedBlockTransform) Type

type RequiredProvider

type RequiredProvider struct {
	Source  *string `attribute:"source"`
	Version *string `attribute:"version"`
}

type ResourceData

type ResourceData struct {
	*BaseData
	*golden.BaseBlock

	ResourceType string    `hcl:"resource_type,optional"`
	UseCount     bool      `hcl:"use_count,optional" default:"false"`
	UseForEach   bool      `hcl:"use_for_each,optional" default:"false"`
	Result       cty.Value `attribute:"result"`
}

func (*ResourceData) ExecuteDuringPlan

func (rd *ResourceData) ExecuteDuringPlan() error

func (*ResourceData) String

func (rd *ResourceData) String() string

func (*ResourceData) Type

func (rd *ResourceData) Type() string

type TerraformCliProviderSchemaRetriever

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

func (TerraformCliProviderSchemaRetriever) Get

func (t TerraformCliProviderSchemaRetriever) Get(providerSource, versionConstraint string) (*tfjson.ProviderSchema, error)

type TerraformData

type TerraformData struct {
	*BaseData
	*golden.BaseBlock

	RequiredVersion   *string                     `attribute:"required_version"`
	RequiredProviders map[string]RequiredProvider `attribute:"required_providers"`
	Block             cty.Value                   `attribute:"block"`
}

func (*TerraformData) ExecuteDuringPlan

func (d *TerraformData) ExecuteDuringPlan() error

func (*TerraformData) Type

func (d *TerraformData) Type() string

type TerraformModuleRef

type TerraformModuleRef struct {
	Key     string `json:"Key"`
	Source  string `json:"Source"`
	Dir     string `json:"Dir"`
	AbsDir  string
	Version string `json:"Version"`
	GitHash string
}

func ModuleRefs

func ModuleRefs(tfDir string) ([]*TerraformModuleRef, error)

func NewTerraformModuleRef

func NewTerraformModuleRef(dir, key, source, version string) (*TerraformModuleRef, error)

func NewTerraformRootModuleRef

func NewTerraformRootModuleRef(dir string) (*TerraformModuleRef, error)

func (*TerraformModuleRef) Load

func (m *TerraformModuleRef) Load() error

func (*TerraformModuleRef) LoadAbsDir

func (m *TerraformModuleRef) LoadAbsDir() error

func (*TerraformModuleRef) LoadGitHash

func (m *TerraformModuleRef) LoadGitHash()

type TerraformProviderSchemaRetriever

type TerraformProviderSchemaRetriever interface {
	Get(providerSource, versionConstraint string) (*tfjson.ProviderSchema, error)
}

func NewTerraformCliProviderSchemaRetriever

func NewTerraformCliProviderSchemaRetriever(ctx context.Context) TerraformProviderSchemaRetriever

type Transform

type Transform interface {
	golden.ApplyBlock
	Transform()
}

type UpdateInPlaceTransform

type UpdateInPlaceTransform struct {
	*golden.BaseBlock
	*BaseTransform
	TargetBlockAddress string `hcl:"target_block_address" validate:"required"`
	DynamicBlockBody   string `hcl:"dynamic_block_body,optional"`
	// contains filtered or unexported fields
}

func (*UpdateInPlaceTransform) Apply

func (u *UpdateInPlaceTransform) Apply() error

func (*UpdateInPlaceTransform) Decode

func (u *UpdateInPlaceTransform) Decode(block *golden.HclBlock, context *hcl.EvalContext) error

func (*UpdateInPlaceTransform) PatchWriteBlock

func (u *UpdateInPlaceTransform) PatchWriteBlock(dest terraform.Block, patch *hclwrite.Block)

func (*UpdateInPlaceTransform) String

func (u *UpdateInPlaceTransform) String() string

func (*UpdateInPlaceTransform) Type

func (u *UpdateInPlaceTransform) Type() string

func (*UpdateInPlaceTransform) UpdateBlock

func (u *UpdateInPlaceTransform) UpdateBlock() *hclwrite.Block

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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