terraform

package
v1.202.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTerraformCompatFlags

func AllTerraformCompatFlags() map[string]compat.CompatibilityFlag

AllTerraformCompatFlags returns a combined set of all terraform compatibility flags. This is used for preprocessing in Execute() to identify terraform pass-through flags. Before Cobra parses the command line, we combine all possible flags so we can correctly separate pass-through flags regardless of which subcommand is being called.

func ApplyCompatFlags

func ApplyCompatFlags() map[string]compat.CompatibilityFlag

ApplyCompatFlags returns compatibility flags specific to terraform apply.

func BackendExecutionFlags added in v1.202.1

func BackendExecutionFlags() *flags.FlagRegistry

BackendExecutionFlags returns flags for commands that generate backend files or run init. These flags are used by: init, workspace, plan, apply, deploy.

func CommonSubcommandFlags

func CommonSubcommandFlags() map[string]compat.CompatibilityFlag

CommonSubcommandFlags returns flags that are common across many terraform subcommands. These are NOT global terraform options - they only apply to specific subcommands like plan, apply, destroy. These flags are NOT parsed by Cobra but are passed through to terraform/tofu.

func ConsoleCompatFlags

func ConsoleCompatFlags() map[string]compat.CompatibilityFlag

ConsoleCompatFlags returns compatibility flags specific to terraform console.

func DestroyCompatFlags

func DestroyCompatFlags() map[string]compat.CompatibilityFlag

DestroyCompatFlags returns compatibility flags specific to terraform destroy.

func ExecuteVarfileGeneration

func ExecuteVarfileGeneration(config *VarfileConfig) error

ExecuteVarfileGeneration executes the varfile generation with the given config.

func FmtCompatFlags

func FmtCompatFlags() map[string]compat.CompatibilityFlag

FmtCompatFlags returns compatibility flags specific to terraform fmt.

func ForceUnlockCompatFlags

func ForceUnlockCompatFlags() map[string]compat.CompatibilityFlag

ForceUnlockCompatFlags returns compatibility flags specific to terraform force-unlock.

func GetCompatFlags

func GetCompatFlags() map[string]compat.CompatibilityFlag

GetCompatFlags returns compatibility flags specific to terraform get.

func GraphCompatFlags

func GraphCompatFlags() map[string]compat.CompatibilityFlag

GraphCompatFlags returns compatibility flags specific to terraform graph.

func ImportCompatFlags

func ImportCompatFlags() map[string]compat.CompatibilityFlag

ImportCompatFlags returns compatibility flags specific to terraform import.

func InitCompatFlags

func InitCompatFlags() map[string]compat.CompatibilityFlag

InitCompatFlags returns compatibility flags specific to terraform init.

func OutputCompatFlags

func OutputCompatFlags() map[string]compat.CompatibilityFlag

OutputCompatFlags returns compatibility flags specific to terraform output.

func PlanCompatFlags

func PlanCompatFlags() map[string]compat.CompatibilityFlag

PlanCompatFlags returns compatibility flags specific to terraform plan.

func ProvidersCompatFlags

func ProvidersCompatFlags() map[string]compat.CompatibilityFlag

ProvidersCompatFlags returns compatibility flags specific to terraform providers. Note: terraform providers has no special flags beyond standard terraform flags.

func RefreshCompatFlags

func RefreshCompatFlags() map[string]compat.CompatibilityFlag

RefreshCompatFlags returns compatibility flags specific to terraform refresh.

func RegisterTerraformCompletions

func RegisterTerraformCompletions(tfCmd *cobra.Command)

RegisterTerraformCompletions registers all completion functions for a terraform subcommand. This includes:

  • Component positional arg completion (first arg)
  • Identity flag completion

Note: Stack flag completion is handled by the flag handler's registerPersistentCompletions() method in pkg/flags/standard.go. Custom completion functions are configured in the flag definition.

func ShowCompatFlags

func ShowCompatFlags() map[string]compat.CompatibilityFlag

ShowCompatFlags returns compatibility flags specific to terraform show.

func StateCompatFlags

func StateCompatFlags() map[string]compat.CompatibilityFlag

StateCompatFlags returns compatibility flags specific to terraform state commands.

func TaintCompatFlags

func TaintCompatFlags() map[string]compat.CompatibilityFlag

TaintCompatFlags returns compatibility flags specific to terraform taint.

func TerraformAffectedFlags

func TerraformAffectedFlags() *flags.FlagRegistry

TerraformAffectedFlags returns a registry with flags for affected component detection. These flags are used by commands that support --affected mode.

func TerraformFlags

func TerraformFlags() *flags.FlagRegistry

TerraformFlags returns a registry with flags specific to Terraform commands. Includes common flags plus Terraform-specific flags.

func TerraformGlobalCompatFlags

func TerraformGlobalCompatFlags() map[string]compat.CompatibilityFlag

TerraformGlobalCompatFlags returns TRUE global terraform flags. These can be used before any subcommand (e.g., `terraform -chdir=./foo plan`). These flags are NOT parsed by Cobra but are passed through to terraform/tofu.

func TestCompatFlags

func TestCompatFlags() map[string]compat.CompatibilityFlag

TestCompatFlags returns compatibility flags specific to terraform test.

func UntaintCompatFlags

func UntaintCompatFlags() map[string]compat.CompatibilityFlag

UntaintCompatFlags returns compatibility flags specific to terraform untaint.

func ValidateCompatFlags

func ValidateCompatFlags() map[string]compat.CompatibilityFlag

ValidateCompatFlags returns compatibility flags specific to terraform validate.

func ValidateVarfileConfig

func ValidateVarfileConfig(config *VarfileConfig) error

ValidateVarfileConfig validates the varfile configuration.

func WithBackendExecutionFlags added in v1.202.1

func WithBackendExecutionFlags() flags.Option

WithBackendExecutionFlags returns a flags.Option that adds backend execution flags.

func WithTerraformAffectedFlags

func WithTerraformAffectedFlags() flags.Option

WithTerraformAffectedFlags returns a flags.Option that adds affected component detection flags.

func WithTerraformFlags

func WithTerraformFlags() flags.Option

WithTerraformFlags returns a flags.Option that adds all Terraform-specific flags.

func WorkspaceCompatFlags

func WorkspaceCompatFlags() map[string]compat.CompatibilityFlag

WorkspaceCompatFlags returns compatibility flags specific to terraform workspace commands.

Types

type TerraformCommandProvider

type TerraformCommandProvider struct{}

TerraformCommandProvider implements the CommandProvider interface.

func (*TerraformCommandProvider) GetAliases

GetAliases returns command aliases.

func (*TerraformCommandProvider) GetCommand

func (t *TerraformCommandProvider) GetCommand() *cobra.Command

GetCommand returns the terraform command.

func (*TerraformCommandProvider) GetCompatibilityFlags

func (t *TerraformCommandProvider) GetCompatibilityFlags() map[string]compat.CompatibilityFlag

GetCompatibilityFlags returns compatibility flags for this command.

func (*TerraformCommandProvider) GetFlagsBuilder

func (t *TerraformCommandProvider) GetFlagsBuilder() flags.Builder

GetFlagsBuilder returns the flags builder for this command.

func (*TerraformCommandProvider) GetGroup

func (t *TerraformCommandProvider) GetGroup() string

GetGroup returns the command group for help organization.

func (*TerraformCommandProvider) GetName

func (t *TerraformCommandProvider) GetName() string

GetName returns the command name.

func (*TerraformCommandProvider) GetPositionalArgsBuilder

func (t *TerraformCommandProvider) GetPositionalArgsBuilder() *flags.PositionalArgsBuilder

GetPositionalArgsBuilder returns the positional args builder for this command.

type TerraformRunOptions

type TerraformRunOptions struct {
	// Processing flags.
	ProcessTemplates bool
	ProcessFunctions bool
	Skip             []string

	// Execution flags.
	DryRun       bool
	SkipInit     bool
	InitPassVars bool

	// Backend execution flags.
	AutoGenerateBackendFile string
	InitRunReconfigure      string

	// Plan/Apply/Deploy specific flags.
	PlanFile         string
	PlanSkipPlanfile bool
	DeployRunInit    bool

	// Multi-component flags.
	Query      string
	Components []string
	All        bool
	Affected   bool
}

TerraformRunOptions contains shared flags from terraformParser. Used by simple subcommands that only need the base terraform flags.

func ParseTerraformRunOptions

func ParseTerraformRunOptions(v *viper.Viper) *TerraformRunOptions

ParseTerraformRunOptions parses shared terraform flags from Viper.

type VarfileConfig

type VarfileConfig struct {
	Component        string
	Stack            string
	File             string
	ProcessTemplates bool
	ProcessFunctions bool
	Skip             []string
}

VarfileConfig holds the configuration for varfile generation.

func ParseVarfileFlags

func ParseVarfileFlags(v *viper.Viper) VarfileConfig

ParseVarfileFlags extracts varfile configuration from Viper after flag binding.

Directories

Path Synopsis
Package shared provides utilities shared between terraform and its subpackages.
Package shared provides utilities shared between terraform and its subpackages.

Jump to

Keyboard shortcuts

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