command

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MPL-2.0 Imports: 156 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBackupExtension = ".backup"

DefaultBackupExtension is added to the state file to form the path

View Source
const DefaultParallelism = 10

DefaultParallelism is the limit Terraform places on total parallel operations as it walks the dependency graph.

View Source
const DefaultPluginVendorDir = "terraform.d/plugins/" + pluginMachineName

DefaultPluginVendorDir is the location in the config directory to look for user-added plugin binaries. OpenTofu only reads from this path if it exists, it is never created by tofu.

View Source
const DefaultVarsExtension = ".tfvars"

DefaultVarsExtension is the default file extension used for vars

View Source
const DefaultVarsFilename = "terraform" + DefaultVarsExtension

DefaultVarsFilename is the default filename used for vars

View Source
const EnvReads = "CHOUDOUFU_READS"

EnvReads overrides the live block's "reads" argument for one run: "selective" or "full", any other value ignored with a warning. The same layering EnvStateCache already has - the block sets estate policy, the environment wins for the session running it.

View Source
const EnvStateCache = "CHOUDOUFU_STATE_CACHE"

EnvStateCache names a path where a live-block run writes its state snapshot as an ordinary statefile, for the next run to start from. Empty or unset writes none, which is the behaviour every release up to and including v0.5.0 had. Issue #685.

View Source
const ErrUnsupportedLocalOp = `` /* 288-byte string literal not displayed */

ErrUnsupportedLocalOp is the common error message shown for operations that require a backend.Local.

View Source
const ExitApprovalRefused = 3

ExitApprovalRefused is the exit status "apply <planfile>" uses when the approved plan and this run's fresh plan of the live system disagree.

It is deliberately neither of the two codes a pipeline already reads on this path. 1 is every ordinary failure, and routing a failed provider call back to a human reviewer would be wrong. 2 is "-detailed-exitcode"'s "there are changes", which the plan half of the very same pipeline returns. 3 is the lowest code with no meaning on the plan/apply pair, so a pipeline can read 0 as applied, 3 as "send it back to review", and anything else as broken. ("choudoufu fmt -check" also uses 3, in a different command's namespace; nothing routes an apply's exit code through fmt's meanings.)

View Source
const (
	// InputModeEnvVar is the environment variable that, if set to "false" or
	// "0", causes tofu commands to behave as if the `-input=false` flag was
	// specified.
	InputModeEnvVar = "TF_INPUT"
)
View Source
const LiveAffectedExitIndeterminate = 2

LiveAffectedExitIndeterminate is live-affected's exit status when some change could not be attributed and the consumer should plan every root.

View Source
const (
	MainStateIdentifier = ""
)
View Source
const PluginPathFile = "plugin_path"

PluginPathFile is the name of the file in the data dir which stores the list of directories supplied by the user with the `-plugin-dir` flag during init.

View Source
const SummaryRecordStoreNotRead = "The record store was not read"

SummaryRecordStoreNotRead is the warning `live-plan` and `live-mv` raise when the record store could not be reached and they went on without it.

View Source
const TraceNameLivePlanSet = "live-plan-set"

TraceNameLivePlanSet is the live-plan-set command's span name (#1898).

View Source
const TraceNameLiveWaveApply = "live-wave-apply"

TraceNameLiveWaveApply is the live-wave-apply command's span name (#1898).

View Source
const UnmigrateEnvVar = "CHOUDOUFU_UNMIGRATE"

UnmigrateEnvVar is the deliberate-revert escape hatch for [statefulMarkerGuard]: the name of the estate whose ownership markers this run is allowed to remove, or several separated by commas.

It takes an estate name rather than a bare on/off value on purpose. An on/off value set once in a CI environment covers every estate that directory ever migrates, including one migrated a year later by someone who never saw the setting. A name covers the estate the operator was looking at and nothing else.

It is an environment variable rather than a flag because the guard has to serve plan, apply and apply-a-saved-plan identically, and a flag on one of them is a flag missing from the others.

View Source
const VarEnvPrefix = "TF_VAR_"

VarEnvPrefix is the prefix for environment variables that represent values for root module input variables.

View Source
const WorkspaceNameEnvVar = "TF_WORKSPACE"

WorkspaceNameEnvVar is the name of the environment variable that can be used to set the name of the OpenTofu workspace, overriding the workspace chosen by `tofu workspace select`.

Note that this environment variable is ignored by `tofu workspace new` and `tofu workspace delete`.

Variables

View Source
var (
	MainCommandGroup  = Group{ID: "main", Title: "Main commands:", NoSort: true}
	OtherCommandGroup = Group{ID: "", Title: "All other commands:"}
)
View Source
var RunResultHelp = cli.RunResultHelp

RunResultHelp is a specific exit code that implies that help text should be shown. This will be modified or removed when we rip out mitchellh/cli in 1.14.x

Functions

func CommandUsage added in v0.21.0

func CommandUsage(namespace string, cmd Command, w io.Writer)

CommandUsage writes usage/help text to the given writer. This function standardizes how we format usage/help text.

func RunCli added in v0.21.0

func RunCli(namespace string, cmd Command, meta Meta, diags tfdiags.Diagnostics) int

RunCli is how the cli package executes a command after performing flag and argument parsing. The oddity here is that certain arg handling diags need to be printed from a properly configured meta and are therefore passed in here.

func RunCommand added in v0.21.0

func RunCommand(cmd Command, meta Meta, args []string) int

RunCommand is how the legacy command structure calls into the new command structure. This will be removed in 1.14.x

Types

type AliasCommand

type AliasCommand struct {
	cli.Command
}

AliasCommand is a Command implementation that wraps another Command for the purpose of aliasing.

func (*AliasCommand) Help

func (c *AliasCommand) Help() string

Help returns the text with information about the command. The returned text needs to be hard-wrapped at 80 columns.

func (*AliasCommand) Run

func (c *AliasCommand) Run(args []string) int

func (*AliasCommand) Synopsis

func (c *AliasCommand) Synopsis() string

type ApplyCommand

type ApplyCommand struct {
	Meta

	// If true, then this apply command will become the "destroy"
	// command. It is just like apply but only processes a destroy.
	Destroy bool
}

ApplyCommand is a Command implementation that applies a OpenTofu configuration and actually builds or changes infrastructure.

func (ApplyCommand) Execute added in v0.21.0

func (c ApplyCommand) Execute(args *arguments.Apply, view views.Apply) int

func (*ApplyCommand) Help

func (c *ApplyCommand) Help() string

func (*ApplyCommand) LoadPlanFile

func (*ApplyCommand) OperationRequest

func (c *ApplyCommand) OperationRequest(
	ctx context.Context,
	be backend.Enhanced,
	view views.Apply,
	applyArgs *arguments.Apply,
	planFile *planfile.WrappedPlanFile,
	enc encryption.Encryption,
) (*backend.Operation, tfdiags.Diagnostics)

func (*ApplyCommand) PrepareBackend

func (*ApplyCommand) Run

func (c *ApplyCommand) Run(rawArgs []string) int

func (*ApplyCommand) Synopsis

func (c *ApplyCommand) Synopsis() string

type BackendOpts

type BackendOpts struct {
	// Config is a representation of the backend configuration block given in
	// the root module, or nil if no such block is present.
	Config *configs.Backend

	// ConfigOverride is an hcl.Body that, if non-nil, will be used with
	// configs.MergeBodies to override the type-specific backend configuration
	// arguments in Config.
	ConfigOverride hcl.Body

	// Init should be set to true if initialization is allowed. If this is
	// false, then any configuration that requires configuration will show
	// an error asking the user to reinitialize.
	Init bool

	// ForceLocal will force a purely local backend, including state.
	// You probably don't want to set this.
	ForceLocal bool

	// ViewOptions will set console output format for the
	// initialization operation (JSON or human-readable).
	View views.Backend
}

BackendOpts are the options used to initialize a backend.Backend.

type BackendWithRemoteTerraformVersion

type BackendWithRemoteTerraformVersion interface {
	IgnoreVersionConflict()
	VerifyWorkspaceTerraformVersion(workspace string) tfdiags.Diagnostics
	IsLocalOperations() bool
}

BackendWithRemoteTerraformVersion is a shared interface between the 'remote' and 'cloud' backends for simplified type checking when calling functions common to those particular backends.

type Command added in v0.21.0

type Command struct {
	Name    string
	Aliases []string
	// Short is the text that accompanies it in the parent command's help text.
	Short string
	// Long is the full description that is printed as part of the command's help text.
	Long string
	// GroupID if set determines what group to show the command under in the parent command's help text.
	GroupID string
	// If this command should not be shown in the help text of the parent command.
	Hidden bool

	// Commands are the sub-commands of the current command.
	Commands []Command
	// Groups to split the sub Commands into
	Groups []Group

	// UsageOverride are custom overrides for special cases.
	// Ideally we can retire this eventually as we unify the help/usage text.
	UsageOverride UsageOverride

	// CommandLine defines what flags and arguments are available to this command.
	CommandLine arguments.CommandLine
	// Run is the action that will be executed if this command is selected.
	Run func(Meta) int

	// A legacy option that will be removed at some point
	// This was introduced during the migration to proper
	// diagnostic error printing during the meta-refactor
	DiagsWithNewline bool
}

Command is the metadata and action associated with a command available to the CLI. This is eventually translated into a parsable/runnable CLI in cmd/tofu.

func ApplyCommander added in v0.21.0

func ApplyCommander() Command

func ConsoleCommander added in v0.21.0

func ConsoleCommander() Command

func DestroyCommander added in v0.21.0

func DestroyCommander() Command

func FmtCommander added in v0.21.0

func FmtCommander(input io.Reader) Command

func GetCommander added in v0.21.0

func GetCommander() Command

func GraphCommander added in v0.21.0

func GraphCommander() Command

func ImportCommander added in v0.21.0

func ImportCommander() Command

func InitCommander added in v0.21.0

func InitCommander() Command

func LiveAffectedCommander added in v0.22.0

func LiveAffectedCommander() Command

LiveAffectedCommander is live-affected's entry in the new CLI's command tree. See LiveCommanders.

func LiveBucketCommander added in v0.21.0

func LiveBucketCommander() Command

LiveBucketCommander is live-bucket's entry in the new CLI's command tree. See LiveCommanders.

func LiveCheckCommander added in v0.21.0

func LiveCheckCommander() Command

LiveCheckCommander is live-check's entry in the new CLI's command tree. See LiveCommanders.

func LiveClusterCommander added in v0.21.0

func LiveClusterCommander() Command

LiveClusterCommander is live-cluster's entry in the new CLI's command tree. See LiveCommanders.

func LiveCommanders added in v0.21.0

func LiveCommanders() []Command

LiveCommanders are this fork's twelve live-* commands, as entries in the new CLI's command tree. RootCommander appends them after the stock commands; the legacy CLI's command map (cmd/choudoufu/commands.go) reaches the same Execute methods through each command's Run.

OpenTofu v1.13.0 made the urfave/cli tree the default CLI. That tree is static and built here, not from the legacy map, so a command registered only in the map is "no command named" under the default CLI. The test TestNewCLIDispatchesLiveCommands walks RootCommander and fails if any of the twelve is missing.

func LiveImportCommander added in v0.21.0

func LiveImportCommander() Command

LiveImportCommander is live-import's entry in the new CLI's command tree. See LiveCommanders.

func LiveLsCommander added in v0.21.0

func LiveLsCommander() Command

LiveLsCommander is live-ls's entry in the new CLI's command tree. See LiveCommanders.

func LiveMvCommander added in v0.21.0

func LiveMvCommander() Command

LiveMvCommander is live-mv's entry in the new CLI's command tree. See LiveCommanders.

func LivePlanCommander added in v0.21.0

func LivePlanCommander() Command

LivePlanCommander is live-plan's entry in the new CLI's command tree (RootCommander). The legacy CLI reaches the same Execute through LivePlanCommand.Run.

func LivePlanSetCommander added in v0.22.0

func LivePlanSetCommander() Command

LivePlanSetCommander is live-plan-set's entry in the new CLI's command tree.

func LiveSummaryCommander added in v0.22.0

func LiveSummaryCommander() Command

LiveSummaryCommander is live-summary's entry in the new CLI's command tree. See LiveCommanders.

func LiveWaveApplyCommander added in v0.22.0

func LiveWaveApplyCommander() Command

LiveWaveApplyCommander is live-wave-apply's entry in the new CLI's command tree. See LiveCommanders.

func LiveWavesCommander added in v0.22.0

func LiveWavesCommander() Command

LiveWavesCommander is live-waves' entry in the new CLI's command tree. See LiveCommanders.

func LoginCommander added in v0.21.0

func LoginCommander() Command

func LogoutCommander added in v0.21.0

func LogoutCommander() Command

func MetadataCommander added in v0.21.0

func MetadataCommander() Command

func MetadataFunctionsCommander added in v0.21.0

func MetadataFunctionsCommander() Command

func OutputCommander added in v0.21.0

func OutputCommander() Command

func PlanCommander added in v0.21.0

func PlanCommander() Command

func ProvidersCommander added in v0.21.0

func ProvidersCommander() Command

func ProvidersLockCommander added in v0.21.0

func ProvidersLockCommander() Command

func ProvidersMirrorCommander added in v0.21.0

func ProvidersMirrorCommander() Command

func ProvidersSchemaCommander added in v0.21.0

func ProvidersSchemaCommander() Command

func RefreshCommander added in v0.21.0

func RefreshCommander() Command

func RootCommander added in v0.21.0

func RootCommander(help *bool, ver *bool, chdir *string) Command

RootCommander builds the standard tofu root command.

func ShowCommander added in v0.21.0

func ShowCommander() Command

func StateCommander added in v0.21.0

func StateCommander() Command

func StateListCommander added in v0.21.0

func StateListCommander() Command

func StateMvCommander added in v0.21.0

func StateMvCommander() Command

func StatePullCommander added in v0.21.0

func StatePullCommander() Command

func StatePushCommander added in v0.21.0

func StatePushCommander() Command

func StateReplaceProviderCommander added in v0.21.0

func StateReplaceProviderCommander() Command

func StateRmCommander added in v0.21.0

func StateRmCommander() Command

func StateShowCommander added in v0.21.0

func StateShowCommander() Command

func TaintCommander added in v0.21.0

func TaintCommander() Command

func TestCommander added in v0.21.0

func TestCommander() Command

func UnlockCommander added in v0.21.0

func UnlockCommander() Command

func UntaintCommander added in v0.21.0

func UntaintCommander() Command

func ValidateCommander added in v0.21.0

func ValidateCommander() Command

func VersionCommander added in v0.21.0

func VersionCommander(version string, versionPrerelease string, platform getproviders.Platform) Command

func WorkspaceCommander added in v0.21.0

func WorkspaceCommander(legacyName bool) Command

func WorkspaceDeleteCommander added in v0.21.0

func WorkspaceDeleteCommander(legacyName bool) Command

func WorkspaceListCommander added in v0.21.0

func WorkspaceListCommander(legacyName bool) Command

func WorkspaceNewCommander added in v0.21.0

func WorkspaceNewCommander(legacyName bool) Command

func WorkspaceSelectCommander added in v0.21.0

func WorkspaceSelectCommander(legacyName bool) Command

func WorkspaceShowCommander added in v0.21.0

func WorkspaceShowCommander() Command

type ConsoleCommand

type ConsoleCommand struct {
	Meta
}

ConsoleCommand is a Command implementation that starts an interactive console that can be used to try expressions with the current config.

func (ConsoleCommand) Execute added in v0.21.0

func (c ConsoleCommand) Execute(args *arguments.Console, view views.Console) int

func (*ConsoleCommand) Help

func (c *ConsoleCommand) Help() string

func (*ConsoleCommand) Run

func (c *ConsoleCommand) Run(rawArgs []string) int

func (*ConsoleCommand) Synopsis

func (c *ConsoleCommand) Synopsis() string

type FmtCommand

type FmtCommand struct {
	Meta
	// contains filtered or unexported fields
}

FmtCommand is a Command implementation that rewrites OpenTofu config files to a canonical format and style.

func (FmtCommand) Execute added in v0.21.0

func (c FmtCommand) Execute(args *arguments.Fmt, view views.Fmt) int

func (*FmtCommand) Help

func (c *FmtCommand) Help() string

func (*FmtCommand) Run

func (c *FmtCommand) Run(rawArgs []string) int

func (*FmtCommand) Synopsis

func (c *FmtCommand) Synopsis() string

type GetCommand

type GetCommand struct {
	Meta
}

GetCommand is a Command implementation that takes a OpenTofu configuration and downloads all the modules.

func (GetCommand) Execute added in v0.21.0

func (c GetCommand) Execute(args *arguments.Get, view views.Get) int

func (*GetCommand) Help

func (c *GetCommand) Help() string

func (*GetCommand) Run

func (c *GetCommand) Run(rawArgs []string) int

func (*GetCommand) Synopsis

func (c *GetCommand) Synopsis() string

type GraphCommand

type GraphCommand struct {
	Meta
}

GraphCommand is a Command implementation that takes a OpenTofu configuration and outputs the dependency tree in graphical form.

func (GraphCommand) Execute added in v0.21.0

func (c GraphCommand) Execute(args *arguments.Graph, view views.Graph) int

func (*GraphCommand) Help

func (c *GraphCommand) Help() string

func (*GraphCommand) Run

func (c *GraphCommand) Run(rawArgs []string) int

func (*GraphCommand) Synopsis

func (c *GraphCommand) Synopsis() string

type Group added in v0.21.0

type Group struct {
	ID     string
	Title  string
	NoSort bool
}

Group defines a command group and it's metadata In practice, this is only used for the special formatting in the root command

type ImportCommand

type ImportCommand struct {
	Meta
}

ImportCommand is a cli.Command implementation that imports resources into the OpenTofu state.

func (ImportCommand) Execute added in v0.21.0

func (c ImportCommand) Execute(args *arguments.Import, view views.Import) int

func (*ImportCommand) Help

func (c *ImportCommand) Help() string

func (*ImportCommand) Run

func (c *ImportCommand) Run(rawArgs []string) int

func (*ImportCommand) Synopsis

func (c *ImportCommand) Synopsis() string

type InitCommand

type InitCommand struct {
	Meta
}

InitCommand is a Command implementation that takes a Terraform module and clones it to the working directory.

func (*InitCommand) AutocompleteArgs

func (c *InitCommand) AutocompleteArgs() complete.Predictor

func (*InitCommand) AutocompleteFlags

func (c *InitCommand) AutocompleteFlags() complete.Flags

func (InitCommand) Execute added in v0.21.0

func (c InitCommand) Execute(args *arguments.Init, view views.Init) int

func (*InitCommand) Help

func (c *InitCommand) Help() string

func (*InitCommand) Run

func (c *InitCommand) Run(rawArgs []string) int

func (*InitCommand) Synopsis

func (c *InitCommand) Synopsis() string

type LiveAffectedCommand added in v0.22.0

type LiveAffectedCommand struct {
	Meta
}

LiveAffectedCommand names the estate roots a git range touches (GitHub issue #1751, part of #1749; it takes over #1106 section 4). It reads configuration at both ends of the range and plans nothing.

func (*LiveAffectedCommand) Execute added in v0.22.0

func (c *LiveAffectedCommand) Execute(args *arguments.LiveAffected) int

func (*LiveAffectedCommand) Help added in v0.22.0

func (c *LiveAffectedCommand) Help() string

func (*LiveAffectedCommand) Run added in v0.22.0

func (c *LiveAffectedCommand) Run(rawArgs []string) int

func (*LiveAffectedCommand) Synopsis added in v0.22.0

func (c *LiveAffectedCommand) Synopsis() string

type LiveBucketCommand added in v0.18.0

type LiveBucketCommand struct {
	Meta
}

LiveBucketCommand reports whether a record store bucket satisfies its contract (GitHub issues #1339 and #1341): versioning, a lifecycle that expires noncurrent versions, and public-access block.

It reports the bucket, not the configuration

A plan or an apply honours allow_insecure (#1340), because whether a RUN may proceed is the operator's call. This command answers a different question - is this bucket correct - and answering it through the run's path would print green for a bucket with versioning off, which is the opposite of what someone runs it for. So a waiver never changes a verdict or the exit status here. It is named, separately, together with whether it is hiding anything.

It writes nothing: no sentinel, no record, no tag.

func (*LiveBucketCommand) Execute added in v0.21.0

func (c *LiveBucketCommand) Execute(args *arguments.LiveBucket) int

func (*LiveBucketCommand) Help added in v0.18.0

func (c *LiveBucketCommand) Help() string

func (*LiveBucketCommand) Run added in v0.18.0

func (c *LiveBucketCommand) Run(rawArgs []string) int

func (*LiveBucketCommand) Synopsis added in v0.18.0

func (c *LiveBucketCommand) Synopsis() string

type LiveCheckCommand added in v0.3.0

type LiveCheckCommand struct {
	Meta
}

LiveCheckCommand answers "will my configuration work under live resource markers" from a directory, with no cloud, no state, and no live block required in the configuration under test.

It is GitHub issue #114, and it is deliberately a thin renderer over internal/live/check rather than an analysis of its own. That package is also what tools/corpus-gen runs across a corpus for #102, so the compatibility claim this project publishes and the verdict a user gets on their own repository are computed by the same code. Two implementations would eventually disagree, and the user's would be the one that mattered.

Three things are answered, in the order someone reads them: whether it can move at all, what stops it, and what to do about each. The report then names the stages it did not check - stamping, discovery and projection all need a cloud - because a clean verdict that read as "this ships" while three stages went unexamined would be the same overstatement #101 spent a campaign removing.

func (*LiveCheckCommand) Execute added in v0.21.0

func (c *LiveCheckCommand) Execute(args *arguments.LiveCheck) int

func (*LiveCheckCommand) Help added in v0.3.0

func (c *LiveCheckCommand) Help() string

func (*LiveCheckCommand) Run added in v0.3.0

func (c *LiveCheckCommand) Run(rawArgs []string) int

func (*LiveCheckCommand) Synopsis added in v0.3.0

func (c *LiveCheckCommand) Synopsis() string

type LiveClusterCommand added in v0.19.0

type LiveClusterCommand struct {
	Meta
}

LiveClusterCommand reports whether the cluster a record_store "kubernetes" keeps its records in satisfies its contract (GitHub issue #1393): the records namespace and this identity's access to it, read isolation, encryption at rest, and the estate boundary policy.

It is `live-bucket` (#1341) for the other remote store, and it answers the same question in the same way and for the same reason.

It reports the cluster, not the configuration

A plan or an apply honours allow_insecure (#1340), because whether a RUN may proceed is the operator's call. This command answers a different question - is this cluster correct - and answering it through the run's path would print green for a cluster whose Secrets are not encrypted, which is the opposite of what someone runs it for. So a waiver never changes a verdict or the exit status here. It is named, separately, together with whether it is hiding anything.

Not checked is not correct

Two of the four properties cannot be read on every distribution. A finding the cluster could not answer is NOT CHECKED, it is not a pass, and it makes the verdict "NOT correct" the same way a failure does. That is the whole reason for a report a person runs on purpose: an operator who wants the answer can go and get it from outside the cluster.

It writes nothing: no sentinel, no record, no Secret. The only object it creates is a SelfSubjectAccessReview, which is a question, not a change - the API server evaluates it and stores nothing.

func (*LiveClusterCommand) Execute added in v0.21.0

func (c *LiveClusterCommand) Execute(args *arguments.LiveCluster) int

func (*LiveClusterCommand) Help added in v0.19.0

func (c *LiveClusterCommand) Help() string

func (*LiveClusterCommand) Run added in v0.19.0

func (c *LiveClusterCommand) Run(rawArgs []string) int

func (*LiveClusterCommand) Synopsis added in v0.19.0

func (c *LiveClusterCommand) Synopsis() string

type LiveImportCommand added in v0.3.0

type LiveImportCommand struct {
	Meta
}

LiveImportCommand is the bulk migration path from a state-backed estate to live resource markers (issue #61): read an existing tfstate file once, verify every root-module managed resource it names against the live system, print the ratification report, and - only on a second run given -approve - stamp this estate's markers onto everything that verified.

The pipeline is the observe/stamp split github.com/intentius/choudoufu/internal/live/liveimport's package doc describes, adapted from chant's carve: liveImportRatify is entirely read-only (it opens the state file exactly once, and calls only GetProviderSchema and ReadResource on every provider it reaches), and its report is what gets printed whether or not -approve was given. Only when it was does this command call liveimport.Ratification.Approve, which is the one thing in the whole command that writes.

func (*LiveImportCommand) Execute added in v0.21.0

func (c *LiveImportCommand) Execute(args *arguments.LiveImport) int

func (*LiveImportCommand) Help added in v0.3.0

func (c *LiveImportCommand) Help() string

func (*LiveImportCommand) Run added in v0.3.0

func (c *LiveImportCommand) Run(rawArgs []string) int

func (*LiveImportCommand) Synopsis added in v0.3.0

func (c *LiveImportCommand) Synopsis() string

type LiveLsCommand added in v0.12.0

type LiveLsCommand struct {
	Meta
}

LiveLsCommand answers "what does this account hold under estate X", read straight off the live system rather than off anything a configuration declares - live-plan's own question, and a different one. It is GitHub issue #789.

The prior art is examples/live-mv-workbench/tlmig/govern.py's read_inventory, which this command ports rather than reimplements against: two passes, because the Resource Groups Tagging API does not index IAM on a real account (an aws_iam_role created and tagged natively still comes back empty from GetResources - live/floci-capabilities.json records the same gap against floci before lex00/floci#229's fix, and the fact is real AWS's regardless of what any one emulator pin does about it), so an inventory that trusted the tagging index alone would silently under-report every estate that owns a role. The second pass - iam:ListRoles, then iam:ListRoleTags per role, kept only where the role's own tofu-estate tag names this estate - is what closes that gap, at the cost this command's own doc comment on liveLsIAMRoles states plainly rather than hides.

What this command deliberately does NOT do is reuse internal/live/discovery's sweep (Discover, sweepViaTagging): that machinery answers "what does this estate's CONFIGURATION not yet know about", which needs a loaded configuration, a running provider and a resolved identity map before it can list anything at all. This command answers a narrower, cheaper question - what carries the estate's tag, full stop - that an inheritor or an auditor with nothing but read-only IAM can ask with no configuration in hand. The lower-level primitives discovery's own tagging sweep is built from (cloudcontrol.Client.GetResources, markers's decode functions) are exactly what this command reuses; the configuration-aware parts are not.

The Kubernetes listing (GitHub issue #1081) is the one part that does need DIR, because the substrate is learned from the configuration's provider blocks and the cluster client is built from one of them, the way live-plan's own sweep builds it ([projectionProviders.kubernetesClient]). What it lists is what the sweep lists - one cluster-wide, label-selected list per kind the cluster serves, controller-made objects excluded (kubesweep.Client) - and what it calls declared is what the sweep calls declared ([discovery.DeclaredKubernetesObjects]), so the inventory and the removal plan cannot disagree about an object.

func (*LiveLsCommand) Execute added in v0.21.0

func (c *LiveLsCommand) Execute(args *arguments.LiveLs) int

func (*LiveLsCommand) Help added in v0.12.0

func (c *LiveLsCommand) Help() string

func (*LiveLsCommand) Run added in v0.12.0

func (c *LiveLsCommand) Run(rawArgs []string) int

func (*LiveLsCommand) Synopsis added in v0.12.0

func (c *LiveLsCommand) Synopsis() string

type LiveMvCommand

type LiveMvCommand struct {
	Meta
}

LiveMvCommand renames a resource in a live-mode estate: it rewrites the tofu-address ownership marker on the live resource that carries the old address.

This is the whole replacement for `moved` blocks and state surgery. There is no record to edit, because there is no record - a resource's address lives in one tag value on the resource itself, and overwriting that value is the move (live/MARKERS.md, "The rename rule"). Nothing about the old address survives the write, because a single tag value cannot hold two addresses.

The order of operations is config first, marker second: rename the resource block, then run this. That is the ordering that never leaves a marker naming an address nothing declares, and it is why a destination address absent from configuration is refused rather than written (-allow-missing-config is the deliberate opt out, for the operator who wants both halves in one change).

The write is a real, minimal apply through the provider, on one instance: the resource is materialized exactly as a projection materializes it, the same object is synthesized with one tag changed, and PlanResourceChange and ApplyResourceChange run for that instance alone. No cloud CLI, no provider-specific code, and no plan over the rest of the configuration.

func (*LiveMvCommand) Execute added in v0.21.0

func (c *LiveMvCommand) Execute(args *arguments.LiveMv) int

func (*LiveMvCommand) Help

func (c *LiveMvCommand) Help() string

func (*LiveMvCommand) Run

func (c *LiveMvCommand) Run(rawArgs []string) int

func (*LiveMvCommand) Synopsis

func (c *LiveMvCommand) Synopsis() string

type LivePlanCommand

type LivePlanCommand struct {
	Meta
}

LivePlanCommand plans a configuration with no authoritative state: no backend, no lock. Prior state is a projection, rebuilt by reading the live system at the start of the run and discarded when the run ends - this standalone command neither reads nor writes the #685 state cache, which belongs to plain plan/apply's LiveRun seam (live_mode.go's runner wires it); a diagnostic command that wrote the cache would overwrite the last real run's snapshot with its own.

The pipeline is lint -> identity -> discovery -> projection -> the ordinary plan engine:

  1. The configuration is loaded exactly as the plan command loads it, and no backend is prepared. There is deliberately no state manager of any kind, not even an in-memory one, because there is no operation here that reads or writes a state snapshot: the prior state is passed to tofu.Context.Plan as a value and the resulting plan is rendered and dropped. Avoiding the backend rather than stubbing it is what makes "no state was read or written" a structural property instead of a promise, and it is why this command works in a directory whose backend was never initialized.
  2. The providers the configuration names are launched from the ordinary plugin library (the providercache that "choudoufu init" populated), unconfigured, far enough to read their resource identity schemas.
  3. lint.CheckWith decides whether the configuration is in the live-mode subset at all, with those schemas in hand: a type absent from the v0 admission table still passes when the schemas describe it completely enough (see identity.SynthesizeTypeIdentity), and a refused type is explained in the identity layer's own words. Any remaining issue is fatal.
  4. identity.Resolve classifies every instance, from the same schemas lint just used. Error diagnostics are fatal, because a partial identity map plans creates for things that already exist. The providers are configured only later, once a projection needs to make provider calls.
  5. [discovery.Discover] lists the live resources of every type that has an instance waiting on marker discovery, binds the ones carrying this estate's markers, and - because it is asked for unclaimed resources too - brings back everything of those types that carries no marker at all. A count block's instances are bound as a set rather than one address at a time, so the live members past the declared count come back at the instance addresses above it and the plan below destroys them the way it destroys any shrunken count's leftovers. When the estate's managed resources span more than one provider configuration (aliased providers, typically multi-region), liveDiscover runs this step once per distinct provider configuration and [discovery.Merge] combines the results into one, so this step still reads as "discovery ran" even though it may have run several times under the hood (issue #69).
  6. foreign.Classify sorts those unclaimed resources into foreign, bind candidate and other-estate, and reports the owned resources sitting at a for_each key the configuration no longer declares as rename candidates. All of it goes into one section. Nothing it finds is ever fed back into the run: an unclaimed resource has no declared address, so it never enters the prior state, and the plan engine has nothing to propose destroying. That is the protection property, and it holds by construction rather than by a filter someone has to remember to apply.
  7. projection.BuildFrom materializes the prior state from the merged resolutions, admitting a live object only when it carries this estate's ownership marker or discovery already bound it by one. That check is what keeps a client-named resource - whose identity comes out of the configuration and which therefore never passes through step 5 or step 6 at all - from being adopted on the strength of a name. Whatever it could not read, and whatever it refused, is reported in its own section above the plan, which is the transparency surface for "why does this plan propose a create".
  8. [stamp.Stamp] injects this estate's ownership markers into every taggable resource whose configuration does not already declare them, by rewriting the resource bodies before the plan reads them. That is what makes markers a property of the tool rather than of the author's discipline: the plan below shows the tags being added, and an apply of it writes them. A marker the configuration declares and this run disagrees with is fatal rather than overwritten. Count instances also get their tofu-slot tag here, from the assignment discovery worked out in step 5 - which is why stamping runs after discovery and not before.
  9. The plan runs with refresh disabled, because the projection was built from live reads moments earlier and refreshing it would read every object a second time to learn the same thing.

func (*LivePlanCommand) Execute added in v0.21.0

func (c *LivePlanCommand) Execute(args *arguments.LivePlan) int

Execute runs live-plan over already-parsed arguments. Its view is built here rather than handed in, unlike most Execute methods in this package, because which view it may build depends on -json in a way the caller cannot settle: see jsonRequested below.

func (*LivePlanCommand) Help

func (c *LivePlanCommand) Help() string

func (*LivePlanCommand) Run

func (c *LivePlanCommand) Run(rawArgs []string) int

func (*LivePlanCommand) Synopsis

func (c *LivePlanCommand) Synopsis() string

type LivePlanSetCommand added in v0.22.0

type LivePlanSetCommand struct {
	Meta
}

LivePlanSetCommand plans a set of estate roots in one invocation (GitHub issue #1752, part of epic #1749). The orchestration, and why it runs each root's stages as child processes rather than in this one, is internal/live/setplan's package documentation.

It is its own command rather than a flag on live-plan because the two answer different questions with different contracts: live-plan's option set is the plan command's, every one of which applies to one root, and its -json is GitHub issue #788's bound/omissions/unowned document for that root. A set plan has one output directory instead of -out, a document of per-root stock plans instead of #788's, and an exit code that can say "some roots failed" - three places a flag on live-plan would have had to refuse or reinterpret live-plan's own options.

func (*LivePlanSetCommand) Execute added in v0.22.0

func (c *LivePlanSetCommand) Execute(args *arguments.LivePlanSet) (exitCode int)

func (*LivePlanSetCommand) Help added in v0.22.0

func (c *LivePlanSetCommand) Help() string

func (*LivePlanSetCommand) Run added in v0.22.0

func (c *LivePlanSetCommand) Run(rawArgs []string) int

func (*LivePlanSetCommand) Synopsis added in v0.22.0

func (c *LivePlanSetCommand) Synopsis() string

type LiveSummaryCommand added in v0.22.0

type LiveSummaryCommand struct {
	Meta
	// contains filtered or unexported fields
}

LiveSummaryCommand prints a grouped summary of many plans (GitHub issue #1753, part of #1749): the set plan's -json document, or one stock plan's JSON, read from a file or stdin. Units with identical changes, after the names that identify each unit are stripped, are one group, so a reviewer reads each distinct change once. The rules are github.com/intentius/choudoufu/internal/live/plansummary's package doc.

It reads a document and prints; it touches no configuration, no cloud and no record. It is output only: it approves and refuses nothing.

func (*LiveSummaryCommand) Execute added in v0.22.0

func (c *LiveSummaryCommand) Execute(args *arguments.LiveSummary) int

func (*LiveSummaryCommand) Help added in v0.22.0

func (c *LiveSummaryCommand) Help() string

func (*LiveSummaryCommand) Run added in v0.22.0

func (c *LiveSummaryCommand) Run(rawArgs []string) int

func (*LiveSummaryCommand) Synopsis added in v0.22.0

func (c *LiveSummaryCommand) Synopsis() string

type LiveWaveApplyCommand added in v0.22.0

type LiveWaveApplyCommand struct {
	Meta
}

LiveWaveApplyCommand applies one wave of an approved set (GitHub issue #1754, part of #1749). The approval itself is not stored here: the caller names the set plan document and the digest that was approved, and this command refuses with exit 3 unless every root of the wave still plans to exactly that. The rules are internal/live/waves' Apply.

func (*LiveWaveApplyCommand) Execute added in v0.22.0

func (c *LiveWaveApplyCommand) Execute(args *arguments.LiveWaveApply) (exitCode int)

func (*LiveWaveApplyCommand) Help added in v0.22.0

func (c *LiveWaveApplyCommand) Help() string

func (*LiveWaveApplyCommand) Run added in v0.22.0

func (c *LiveWaveApplyCommand) Run(rawArgs []string) int

func (*LiveWaveApplyCommand) Synopsis added in v0.22.0

func (c *LiveWaveApplyCommand) Synopsis() string

type LiveWavesCommand added in v0.22.0

type LiveWavesCommand struct {
	Meta
}

LiveWavesCommand splits a set of estate roots into ordered waves (GitHub issue #1754, part of #1749): canaries first, then every root after each root whose estate it reads. With a set plan document it also prints the set digest and each wave's. It applies nothing; the 2026-10-01 scope addition is that another tool can read one wave's roots from it and open one change per wave.

func (*LiveWavesCommand) Execute added in v0.22.0

func (c *LiveWavesCommand) Execute(args *arguments.LiveWaves) int

func (*LiveWavesCommand) Help added in v0.22.0

func (c *LiveWavesCommand) Help() string

func (*LiveWavesCommand) Run added in v0.22.0

func (c *LiveWavesCommand) Run(rawArgs []string) int

func (*LiveWavesCommand) Synopsis added in v0.22.0

func (c *LiveWavesCommand) Synopsis() string

type LoginCommand

type LoginCommand struct {
	Meta
}

LoginCommand is a Command implementation that runs an interactive login flow for a remote service host. It then stashes credentials in a tfrc file in the user's home directory.

func (LoginCommand) Execute added in v0.21.0

func (c LoginCommand) Execute(args *arguments.Login, view views.Login) int

func (*LoginCommand) Help

func (c *LoginCommand) Help() string

Help implements cli.Command.

func (*LoginCommand) Run

func (c *LoginCommand) Run(rawArgs []string) int

func (*LoginCommand) Synopsis

func (c *LoginCommand) Synopsis() string

Synopsis implements cli.Command.

type LogoutCommand

type LogoutCommand struct {
	Meta
}

LogoutCommand is a Command implementation which removes stored credentials for a remote service host.

func (LogoutCommand) Execute added in v0.21.0

func (c LogoutCommand) Execute(args *arguments.Logout, view views.Logout) int

func (*LogoutCommand) Help

func (c *LogoutCommand) Help() string

Help implements cli.Command.

func (*LogoutCommand) Run

func (c *LogoutCommand) Run(rawArgs []string) int

func (*LogoutCommand) Synopsis

func (c *LogoutCommand) Synopsis() string

Synopsis implements cli.Command.

type Meta

type Meta struct {

	// WorkingDir is an object representing the "working directory" where we're
	// running commands. In the normal case this literally refers to the
	// working directory of the OpenTofu process, though this can take on
	// a more symbolic meaning when the user has overridden default behavior
	// to specify a different working directory or to override the special
	// data directory where we'll persist settings that must survive between
	// consecutive commands.
	//
	// We're currently gradually migrating the various bits of state that
	// must persist between consecutive commands in a session to be encapsulated
	// in here, but we're not there yet and so there are also some methods on
	// Meta which directly read and modify paths inside the data directory.
	WorkingDir *workdir.Dir

	// SystemCfg holds the configuration attributes that are global for all
	// the commands and are used by different parts of the system.
	//SystemCfg system.Config
	SystemCfg system.Config

	View *views.View

	// Services provides access to remote endpoint information for
	// 'tofu-native' services running at a specific user-facing hostname.
	Services *disco.Disco

	// PluginCacheMayBreakDependencyLockFile is a temporary CLI configuration-based
	// opt out for the behavior of only using the plugin cache dir if its
	// contents match checksums recorded in the dependency lock file.
	//
	// This is an accommodation for those who currently essentially ignore the
	// dependency lock file -- treating it only as transient working directory
	// state -- and therefore don't care if the plugin cache dir causes the
	// checksums inside to only be sufficient for the computer where OpenTofu
	// is currently running.
	//
	// We intend to remove this exception again (making the CLI configuration
	// setting a silent no-op) in future once we've improved the dependency
	// lock file mechanism so that it's usable for everyone and there are no
	// longer any compelling reasons for folks to not lock their dependencies.
	PluginCacheMayBreakDependencyLockFile bool

	// ProviderSource allows determining the available versions of a provider
	// and determines where a distribution package for a particular
	// provider version can be obtained.
	ProviderSource getproviders.Source

	// ModulePackageFetcher is the client to use when fetching module packages
	// from remote locations. This object effectively represents the policy
	// for how to fetch remote module packages, which is decided by the caller.
	//
	// Leaving this nil means that only local modules (using relative paths
	// in the source address) are supported, which is only reasonable for
	// unit testing.
	ModulePackageFetcher *getmodules.PackageFetcher

	// MakeRegistryHTTPClient is a function called each time a command needs
	// an HTTP client that will be used to make requests to a module or
	// provider registry.
	//
	// This is used by package main to deal with some operator-configurable
	// settings for retries and timeouts. If this isn't set then a new client
	// with reasonable defaults for tests will be used instead.
	MakeRegistryHTTPClient func() *retryablehttp.Client

	// BrowserLauncher is used by commands that need to open a URL in a
	// web browser.
	BrowserLauncher webbrowser.Launcher

	// A context.Context provided by the caller -- typically "package main" --
	// which might be carrying telemetry-related metadata and so should be
	// used when creating downstream traces, etc.
	//
	// This isn't guaranteed to be set, so use [Meta.CommandContext] to
	// safely create a context for the entire execution of a command, which
	// will be connected to this parent context if it's present.
	CallerContext context.Context

	// When this channel is closed, the command will be cancelled.
	ShutdownCh <-chan struct{}

	// ProviderDevOverrides are providers where we ignore the lock file, the
	// configured version constraints, and the local cache directory and just
	// always use exactly the path specified. This is intended to allow
	// provider developers to easily test local builds without worrying about
	// what version number they might eventually be released as, or what
	// checksums they have.
	ProviderDevOverrides map[addrs.Provider]getproviders.PackageLocalDir

	// UnmanagedProviders are a set of providers that exist as processes
	// predating OpenTofu, which OpenTofu should use but not worry about the
	// lifecycle of.
	//
	// This is essentially a more extreme version of ProviderDevOverrides where
	// OpenTofu doesn't even worry about how the provider server gets launched,
	// just trusting that someone else did it before running OpenTofu.
	UnmanagedProviders map[addrs.Provider]*plugin.ReattachConfig

	// Since `tofu providers lock` and `tofu providers mirror` have their own
	// logic to create the source to fetch providers through, we had to
	// plumb this configuration through the [Meta] type to reach that part too.
	// In any other cases, this configuration is built and used directly in `realMain`
	// when the providers sources are built.
	ProviderSourceLocationConfig getproviders.LocationConfig
	OCICredentialsPolicyBuilder  oci.OCICredsPolicyBuilder
	// contains filtered or unexported fields
}

Meta are the meta-options that are available on all or most commands.

func (*Meta) Backend

Backend initializes and returns the backend for this CLI session.

The backend is used to perform the actual OpenTofu operations. This abstraction enables easily sliding in new OpenTofu behavior such as remote state storage, remote operations, etc. while allowing the CLI to remain mostly identical.

This will initialize a new backend for each call, which can carry some overhead with it. Please reuse the returned value for optimal behavior.

Only one backend should be used per Meta. This function is stateful and is unsafe to create multiple backends used at once. This function can be called multiple times with each backend being "live" (usable) one at a time.

A side-effect of this method is the population of m.backendState, recording the final resolved backend configuration after dealing with overrides from the "tofu init" command line, etc.

func (*Meta) BackendForLocalPlan

func (m *Meta) BackendForLocalPlan(ctx context.Context, settings plans.Backend, enc encryption.StateEncryption) (backend.Enhanced, tfdiags.Diagnostics)

BackendForLocalPlan is similar to Backend, but uses backend settings that were stored in a plan.

The current workspace name is also stored as part of the plan, and so this method will check that it matches the currently-selected workspace name and produce error diagnostics if not.

func (*Meta) CommandContext

func (m *Meta) CommandContext() context.Context

CommandContext returns the "root context" to use in the main Run function of a command.

This method is just a substitute for passing a context directly to the "Run" method of a command, which we can't do because that API is owned by mitchellh/cli rather than by OpenTofu. Use this only in situations comparable to the context having been passed in as an argument to Run.

If the caller (e.g. "package main") provided a context when it instantiated the Meta then the returned context will inherit all of its values, deadlines, etc. If the caller did not provide a context then the result is an inert background context ready to be passed to other functions.

func (*Meta) Encryption

func (*Meta) EncryptionFromModule

func (m *Meta) EncryptionFromModule(ctx context.Context, module *configs.Module) (encryption.Encryption, tfdiags.Diagnostics)

func (*Meta) EncryptionFromPath

func (m *Meta) EncryptionFromPath(ctx context.Context, path string) (encryption.Encryption, tfdiags.Diagnostics)

func (*Meta) Input

func (m *Meta) Input() bool

Input returns whether or not input asking is enabled.

func (*Meta) InputMode

func (m *Meta) InputMode() tofu.InputMode

InputMode returns the type of input we should ask for in the form of tofu.InputMode which is passed directly to Context.Input.

func (*Meta) InterruptibleContext

func (m *Meta) InterruptibleContext(base context.Context) (context.Context, context.CancelFunc)

InterruptibleContext returns a context.Context that will be cancelled if the process is interrupted by a platform-specific interrupt signal.

The typical way to use this is to pass the result of Meta.CommandContext as the base context, but that's appropriate only if the interruptible context is being created directly inside the "Run" method of a particular command, to create a context representing the entire remaining runtime of that command:

As usual with cancelable contexts, the caller must always call the given cancel function once all operations are complete in order to make sure that the context resources will still be freed even if there is no interruption.

// This example is only for when using this function very early in
// the "Run" method of a Command implementation. If you already have
// an active context, pass that in as base instead.
ctx, done := c.InterruptibleContext(c.CommandContext())
defer done()

func (*Meta) MaybeGetSchemas

func (m *Meta) MaybeGetSchemas(ctx context.Context, state *states.State, config *configs.Config) (*tofu.Schemas, tfdiags.Diagnostics)

MaybeGetSchemas attempts to load and return the schemas If there is not enough information to return the schemas, it could potentially return nil without errors. It is the responsibility of the caller to handle the lack of schema information accordingly

func (*Meta) NewRuntimeEnabled

func (m *Meta) NewRuntimeEnabled() bool

func (*Meta) Operation

Operation initializes a new backend.Operation struct.

This prepares the operation. After calling this, the caller is expected to modify fields of the operation such as Sequence to specify what will be called.

func (*Meta) PlanFile

func (m *Meta) PlanFile(path string, enc encryption.PlanEncryption) (*planfile.WrappedPlanFile, error)

PlanFile loads the plan file at the given path, which might be either a local or cloud plan.

If the return value and error are both nil, the given path exists but seems to be a configuration directory instead.

Error will be non-nil if path refers to something which looks like a plan file and loading the file fails.

func (*Meta) RunOperation

RunOperation executes the given operation on the given backend, blocking until that operation completes or is interrupted, and then returns the RunningOperation object representing the completed or aborted operation that is, despite the name, no longer running.

An error is returned if the operation either fails to start or is cancelled. If the operation runs to completion then no error is returned even if the operation itself is unsuccessful. Use the "Result" field of the returned operation object to recognize operation-level failure.

func (*Meta) SetWorkspace

func (m *Meta) SetWorkspace(name string) error

SetWorkspace saves the given name as the current workspace in the local filesystem.

func (*Meta) StateOutPath

func (m *Meta) StateOutPath() string

StateOutPath returns the true output path for the state file

func (*Meta) StaticConfigInstance

func (m *Meta) StaticConfigInstance(ctx context.Context, root *configs.Module, modules eval.ExternalModules) (*eval.ConfigInstance, tfdiags.Diagnostics)

func (*Meta) UIInput

func (m *Meta) UIInput() tofu.UIInput

UIInput returns a UIInput object to be used for asking for input.

func (*Meta) Workspace

func (m *Meta) Workspace(ctx context.Context) (string, error)

Workspace returns the name of the currently configured workspace, corresponding to the desired named state.

func (*Meta) WorkspaceOverridden

func (m *Meta) WorkspaceOverridden(_ context.Context) (string, bool)

WorkspaceOverridden returns the name of the currently configured workspace, corresponding to the desired named state, as well as a bool saying whether this was set via the TF_WORKSPACE environment variable.

type MetadataCommand

type MetadataCommand struct {
	Meta
}

MetadataCommand is a Command implementation that just shows help for the subcommands nested below it.

func (*MetadataCommand) Help

func (c *MetadataCommand) Help() string

func (*MetadataCommand) Run

func (c *MetadataCommand) Run(args []string) int

func (*MetadataCommand) Synopsis

func (c *MetadataCommand) Synopsis() string

type MetadataFunctionsCommand

type MetadataFunctionsCommand struct {
	Meta
}

MetadataFunctionsCommand is a Command implementation that prints out information about the available functions in OpenTofu.

func (*MetadataFunctionsCommand) Help

func (c *MetadataFunctionsCommand) Help() string

func (*MetadataFunctionsCommand) Run

func (c *MetadataFunctionsCommand) Run(rawArgs []string) int

func (*MetadataFunctionsCommand) Synopsis

func (c *MetadataFunctionsCommand) Synopsis() string

type OutputCommand

type OutputCommand struct {
	Meta
}

OutputCommand is a Command implementation that reads an output from a OpenTofu state and prints it.

func (OutputCommand) Execute added in v0.21.0

func (c OutputCommand) Execute(args *arguments.Output, view views.Output) int

func (*OutputCommand) Help

func (c *OutputCommand) Help() string

func (*OutputCommand) Outputs

func (*OutputCommand) Run

func (c *OutputCommand) Run(rawArgs []string) int

func (*OutputCommand) Synopsis

func (c *OutputCommand) Synopsis() string

type PlanCommand

type PlanCommand struct {
	Meta
}

PlanCommand is a Command implementation that compares a OpenTofu configuration to an actual infrastructure and shows the differences.

func (PlanCommand) Execute added in v0.21.0

func (c PlanCommand) Execute(args *arguments.Plan, view views.Plan) int

func (*PlanCommand) Help

func (c *PlanCommand) Help() string

func (*PlanCommand) OperationRequest

func (c *PlanCommand) OperationRequest(
	ctx context.Context,
	be backend.Enhanced,
	view views.Plan,
	viewOptions *arguments.View,
	args *arguments.Operation,
	planOutPath string,
	generateConfigOut string,
	enc encryption.Encryption,
) (*backend.Operation, tfdiags.Diagnostics)

func (*PlanCommand) PrepareBackend

func (*PlanCommand) Run

func (c *PlanCommand) Run(rawArgs []string) int

func (*PlanCommand) Synopsis

func (c *PlanCommand) Synopsis() string

type ProvidersCommand

type ProvidersCommand struct {
	Meta
}

ProvidersCommand is a Command implementation that prints out information about the providers used in the current configuration/state.

func (ProvidersCommand) Execute added in v0.21.0

func (c ProvidersCommand) Execute(args *arguments.Providers, view views.Providers) int

func (*ProvidersCommand) Help

func (c *ProvidersCommand) Help() string

func (*ProvidersCommand) Run

func (c *ProvidersCommand) Run(rawArgs []string) int

func (*ProvidersCommand) Synopsis

func (c *ProvidersCommand) Synopsis() string

type ProvidersLockCommand

type ProvidersLockCommand struct {
	Meta
}

ProvidersLockCommand is a Command implementation that implements the "tofu providers lock" command, which creates or updates the current configuration's dependency lock file using information from upstream registries, regardless of the provider installation configuration that is configured for normal provider installation.

func (ProvidersLockCommand) Execute added in v0.21.0

func (*ProvidersLockCommand) Help

func (c *ProvidersLockCommand) Help() string

func (*ProvidersLockCommand) Run

func (c *ProvidersLockCommand) Run(rawArgs []string) int

func (*ProvidersLockCommand) Synopsis

func (c *ProvidersLockCommand) Synopsis() string

type ProvidersMirrorCommand

type ProvidersMirrorCommand struct {
	Meta
}

ProvidersMirrorCommand is a Command implementation that implements the "tofu providers mirror" command, which populates a directory with local copies of provider plugins needed by the current configuration so that the mirror can be used to work offline, or similar.

func (ProvidersMirrorCommand) Execute added in v0.21.0

func (*ProvidersMirrorCommand) Help

func (c *ProvidersMirrorCommand) Help() string

func (*ProvidersMirrorCommand) Run

func (c *ProvidersMirrorCommand) Run(rawArgs []string) int

func (*ProvidersMirrorCommand) Synopsis

func (c *ProvidersMirrorCommand) Synopsis() string

type ProvidersSchemaCommand

type ProvidersSchemaCommand struct {
	Meta
}

ProvidersSchemaCommand is a Command implementation that prints out information about the providers used in the current configuration/state.

func (ProvidersSchemaCommand) Execute added in v0.21.0

func (*ProvidersSchemaCommand) Help

func (c *ProvidersSchemaCommand) Help() string

func (*ProvidersSchemaCommand) Run

func (c *ProvidersSchemaCommand) Run(rawArgs []string) int

func (*ProvidersSchemaCommand) Synopsis

func (c *ProvidersSchemaCommand) Synopsis() string

type PushCommand

type PushCommand struct {
	Meta
}

func (*PushCommand) Help

func (c *PushCommand) Help() string

func (*PushCommand) Run

func (c *PushCommand) Run(rawArgs []string) int

func (*PushCommand) Synopsis

func (c *PushCommand) Synopsis() string

type RefreshCommand

type RefreshCommand struct {
	Meta
}

RefreshCommand is a cli.Command implementation that refreshes the state file.

func (RefreshCommand) Execute added in v0.21.0

func (c RefreshCommand) Execute(args *arguments.Refresh, view views.Refresh) int

func (*RefreshCommand) Help

func (c *RefreshCommand) Help() string

func (*RefreshCommand) OperationRequest

func (*RefreshCommand) PrepareBackend

func (*RefreshCommand) Run

func (c *RefreshCommand) Run(rawArgs []string) int

func (*RefreshCommand) Synopsis

func (c *RefreshCommand) Synopsis() string

type ShowCommand

type ShowCommand struct {
	Meta
	// contains filtered or unexported fields
}

ShowCommand is a Command implementation that reads and outputs the contents of a OpenTofu plan or state file. write about config here

func (ShowCommand) Execute added in v0.21.0

func (c ShowCommand) Execute(args *arguments.Show, view views.Show) int

func (*ShowCommand) Help

func (c *ShowCommand) Help() string

func (*ShowCommand) Run

func (c *ShowCommand) Run(rawArgs []string) int

func (*ShowCommand) Synopsis

func (c *ShowCommand) Synopsis() string

type StateCommand

type StateCommand struct {
	StateMeta
}

StateCommand is a Command implementation that just shows help for the subcommands nested below it.

func (*StateCommand) Help

func (c *StateCommand) Help() string

func (*StateCommand) Run

func (c *StateCommand) Run(_ []string) int

func (*StateCommand) Synopsis

func (c *StateCommand) Synopsis() string

type StateListCommand

type StateListCommand struct {
	StateMeta
}

StateListCommand is a Command implementation that lists the resources within a state file.

func (StateListCommand) Execute added in v0.21.0

func (c StateListCommand) Execute(args *arguments.StateList, view views.State) int

func (*StateListCommand) Help

func (c *StateListCommand) Help() string

func (*StateListCommand) Run

func (c *StateListCommand) Run(rawArgs []string) int

func (*StateListCommand) Synopsis

func (c *StateListCommand) Synopsis() string

type StateMeta

type StateMeta struct {
	Meta
}

StateMeta is the meta struct that should be embedded in state subcommands.

func (*StateMeta) State

State returns the state for this meta. This gets the appropriate state from the backend, but changes the way that backups are done. This configures backups to be timestamped rather than just the original state path plus a backup path.

type StateMvCommand

type StateMvCommand struct {
	StateMeta
}

StateMvCommand is a Command implementation that shows a single resource.

func (StateMvCommand) Execute added in v0.21.0

func (c StateMvCommand) Execute(args *arguments.StateMv, view views.State) int

func (*StateMvCommand) Help

func (c *StateMvCommand) Help() string

func (*StateMvCommand) Run

func (c *StateMvCommand) Run(rawArgs []string) int

func (*StateMvCommand) Synopsis

func (c *StateMvCommand) Synopsis() string

type StatePullCommand

type StatePullCommand struct {
	StateMeta
}

StatePullCommand is a Command implementation that shows a single resource.

func (StatePullCommand) Execute added in v0.21.0

func (c StatePullCommand) Execute(args *arguments.StatePull, view views.State) int

func (*StatePullCommand) Help

func (c *StatePullCommand) Help() string

func (*StatePullCommand) Run

func (c *StatePullCommand) Run(rawArgs []string) int

func (*StatePullCommand) Synopsis

func (c *StatePullCommand) Synopsis() string

type StatePushCommand

type StatePushCommand struct {
	StateMeta
}

StatePushCommand is a Command implementation that shows a single resource.

func (StatePushCommand) Execute added in v0.21.0

func (c StatePushCommand) Execute(args *arguments.StatePush, view views.State) int

func (*StatePushCommand) Help

func (c *StatePushCommand) Help() string

func (*StatePushCommand) Run

func (c *StatePushCommand) Run(rawArgs []string) int

func (*StatePushCommand) Synopsis

func (c *StatePushCommand) Synopsis() string

type StateReplaceProviderCommand

type StateReplaceProviderCommand struct {
	StateMeta
}

StateReplaceProviderCommand is a Command implementation that allows users to change the provider associated with existing resources. This is only likely to be useful if a provider is forked or changes its fully-qualified name.

func (StateReplaceProviderCommand) Execute added in v0.21.0

func (*StateReplaceProviderCommand) Help

func (*StateReplaceProviderCommand) Run

func (c *StateReplaceProviderCommand) Run(rawArgs []string) int

func (*StateReplaceProviderCommand) Synopsis

func (c *StateReplaceProviderCommand) Synopsis() string

type StateRmCommand

type StateRmCommand struct {
	StateMeta
}

StateRmCommand is a Command implementation that shows a single resource.

func (StateRmCommand) Execute added in v0.21.0

func (c StateRmCommand) Execute(args *arguments.StateRm, view views.State) int

func (*StateRmCommand) Help

func (c *StateRmCommand) Help() string

func (*StateRmCommand) Run

func (c *StateRmCommand) Run(rawArgs []string) int

func (*StateRmCommand) Synopsis

func (c *StateRmCommand) Synopsis() string

type StateShowCommand

type StateShowCommand struct {
	StateMeta
}

StateShowCommand is a Command implementation that shows a single resource.

func (StateShowCommand) Execute added in v0.21.0

func (c StateShowCommand) Execute(args *arguments.StateShow, view views.State) int

func (*StateShowCommand) Help

func (c *StateShowCommand) Help() string

func (*StateShowCommand) Run

func (c *StateShowCommand) Run(rawArgs []string) int

func (*StateShowCommand) Synopsis

func (c *StateShowCommand) Synopsis() string

type TaintCommand

type TaintCommand struct {
	Meta
}

TaintCommand is a cli.Command implementation that manually taints a resource, marking it for recreation.

func (TaintCommand) Execute added in v0.21.0

func (c TaintCommand) Execute(args *arguments.Taint, view views.Taint) int

func (*TaintCommand) Help

func (c *TaintCommand) Help() string

func (*TaintCommand) Run

func (c *TaintCommand) Run(rawArgs []string) int

func (*TaintCommand) Synopsis

func (c *TaintCommand) Synopsis() string

type TestCommand

type TestCommand struct {
	Meta
}

func (TestCommand) Execute added in v0.21.0

func (c TestCommand) Execute(args *arguments.Test, view views.Test) int

func (*TestCommand) Help

func (c *TestCommand) Help() string

func (*TestCommand) Run

func (c *TestCommand) Run(rawArgs []string) int

func (*TestCommand) Synopsis

func (c *TestCommand) Synopsis() string

type TestFileRunner

type TestFileRunner struct {
	Suite *TestSuiteRunner

	States map[string]*TestFileState
}

func (*TestFileRunner) Cleanup

func (runner *TestFileRunner) Cleanup(ctx context.Context, file *moduletest.File)

func (*TestFileRunner) ExecuteTestFile

func (runner *TestFileRunner) ExecuteTestFile(ctx context.Context, file *moduletest.File)

func (*TestFileRunner) ExecuteTestRun

func (runner *TestFileRunner) ExecuteTestRun(ctx context.Context, run *moduletest.Run, file *moduletest.File, state *states.State, config *configs.Config) (*states.State, bool)

type TestFileState

type TestFileState struct {
	Run   *moduletest.Run
	State *states.State
}

type TestSuiteRunner

type TestSuiteRunner struct {
	Suite  *moduletest.Suite
	Config *configs.Config

	GlobalVariables map[string]backend.UnparsedVariableValue
	Opts            *tofu.ContextOpts

	View views.Test

	// Stopped and Cancelled track whether the user requested the testing
	// process to be interrupted. Stopped is a nice graceful exit, we'll still
	// tidy up any state that was created and mark the tests with relevant
	// `skipped` status updates. Cancelled is a hard stop right now exit, we
	// won't attempt to clean up any state left hanging, and tests will just
	// be left showing `pending` as the status. We will still print out the
	// destroy summary diagnostics that tell the user what state has been left
	// behind and needs manual clean up.
	Stopped   bool
	Cancelled bool

	// StoppedCtx and CancelledCtx allow in progress OpenTofu operations to
	// respond to external calls from the test command.
	StoppedCtx   context.Context
	CancelledCtx context.Context

	// Verbose tells the runner to print out plan files during each test run.
	Verbose bool
	// contains filtered or unexported fields
}

func (*TestSuiteRunner) Start

func (runner *TestSuiteRunner) Start(ctx context.Context)

type UIInput

type UIInput struct {
	// Colorize will color the output.
	Colorize *colorstring.Colorize

	// Reader and Writer for IO. If these aren't set, they will default to
	// Stdin and Stdout respectively.
	Reader io.Reader
	Writer io.Writer
	// contains filtered or unexported fields
}

UIInput is an implementation of tofu.UIInput that asks the CLI for input stdin.

func (*UIInput) Input

func (i *UIInput) Input(ctx context.Context, opts *tofu.InputOpts) (string, error)

type UnlockCommand

type UnlockCommand struct {
	Meta
}

UnlockCommand is a cli.Command implementation that manually unlocks the state.

func (UnlockCommand) Execute added in v0.21.0

func (c UnlockCommand) Execute(args *arguments.Unlock, view views.Unlock) int

func (*UnlockCommand) Help

func (c *UnlockCommand) Help() string

func (*UnlockCommand) Run

func (c *UnlockCommand) Run(rawArgs []string) int

func (*UnlockCommand) Synopsis

func (c *UnlockCommand) Synopsis() string

type UntaintCommand

type UntaintCommand struct {
	Meta
}

UntaintCommand is a cli.Command implementation that manually untaints a resource, marking it as primary and ready for service.

func (UntaintCommand) Execute added in v0.21.0

func (c UntaintCommand) Execute(args *arguments.Taint, view views.Taint) int

func (*UntaintCommand) Help

func (c *UntaintCommand) Help() string

func (*UntaintCommand) Run

func (c *UntaintCommand) Run(rawArgs []string) int

func (*UntaintCommand) Synopsis

func (c *UntaintCommand) Synopsis() string

type UsageOverride added in v0.21.0

type UsageOverride struct {
	// Weird formatting for the root command
	Usage string
	// Weird formatting for the root command
	SingleSpace bool
}

type ValidateCommand

type ValidateCommand struct {
	Meta
}

ValidateCommand is a Command implementation that validates the tofu files

func (ValidateCommand) Execute added in v0.21.0

func (c ValidateCommand) Execute(args *arguments.Validate, view views.Validate) int

func (*ValidateCommand) Help

func (c *ValidateCommand) Help() string

func (*ValidateCommand) Run

func (c *ValidateCommand) Run(rawArgs []string) int

func (*ValidateCommand) Synopsis

func (c *ValidateCommand) Synopsis() string

type VersionCommand

type VersionCommand struct {
	Meta

	Version           string
	VersionPrerelease string
	Platform          getproviders.Platform
}

VersionCommand is a Command implementation prints the version.

func (VersionCommand) Execute added in v0.21.0

func (c VersionCommand) Execute(view views.Version) int

func (*VersionCommand) Help

func (c *VersionCommand) Help() string

func (*VersionCommand) Run

func (c *VersionCommand) Run(rawArgs []string) int

func (*VersionCommand) Synopsis

func (c *VersionCommand) Synopsis() string

type WorkspaceCommand

type WorkspaceCommand struct {
	Meta
	LegacyName bool
}

WorkspaceCommand is a Command Implementation that manipulates workspaces, which allow multiple distinct states and variables from a single config.

func (*WorkspaceCommand) Help

func (c *WorkspaceCommand) Help() string

func (*WorkspaceCommand) Run

func (c *WorkspaceCommand) Run(rawArgs []string) int

func (*WorkspaceCommand) Synopsis

func (c *WorkspaceCommand) Synopsis() string

type WorkspaceDeleteCommand

type WorkspaceDeleteCommand struct {
	Meta
	LegacyName bool
}

func (*WorkspaceDeleteCommand) AutocompleteArgs

func (c *WorkspaceDeleteCommand) AutocompleteArgs() complete.Predictor

func (*WorkspaceDeleteCommand) AutocompleteFlags

func (c *WorkspaceDeleteCommand) AutocompleteFlags() complete.Flags

func (WorkspaceDeleteCommand) Execute added in v0.21.0

func (*WorkspaceDeleteCommand) Help

func (c *WorkspaceDeleteCommand) Help() string

func (*WorkspaceDeleteCommand) Run

func (c *WorkspaceDeleteCommand) Run(rawArgs []string) int

func (*WorkspaceDeleteCommand) Synopsis

func (c *WorkspaceDeleteCommand) Synopsis() string

type WorkspaceListCommand

type WorkspaceListCommand struct {
	Meta
	LegacyName bool
}

func (*WorkspaceListCommand) AutocompleteArgs

func (c *WorkspaceListCommand) AutocompleteArgs() complete.Predictor

func (*WorkspaceListCommand) AutocompleteFlags

func (c *WorkspaceListCommand) AutocompleteFlags() complete.Flags

func (WorkspaceListCommand) Execute added in v0.21.0

func (*WorkspaceListCommand) Help

func (c *WorkspaceListCommand) Help() string

func (*WorkspaceListCommand) Run

func (c *WorkspaceListCommand) Run(rawArgs []string) int

func (*WorkspaceListCommand) Synopsis

func (c *WorkspaceListCommand) Synopsis() string

type WorkspaceNewCommand

type WorkspaceNewCommand struct {
	Meta
	LegacyName bool
}

func (*WorkspaceNewCommand) AutocompleteArgs

func (c *WorkspaceNewCommand) AutocompleteArgs() complete.Predictor

func (*WorkspaceNewCommand) AutocompleteFlags

func (c *WorkspaceNewCommand) AutocompleteFlags() complete.Flags

func (WorkspaceNewCommand) Execute added in v0.21.0

func (*WorkspaceNewCommand) Help

func (c *WorkspaceNewCommand) Help() string

func (*WorkspaceNewCommand) Run

func (c *WorkspaceNewCommand) Run(rawArgs []string) int

func (*WorkspaceNewCommand) Synopsis

func (c *WorkspaceNewCommand) Synopsis() string

type WorkspaceSelectCommand

type WorkspaceSelectCommand struct {
	Meta
	LegacyName bool
}

func (*WorkspaceSelectCommand) AutocompleteArgs

func (c *WorkspaceSelectCommand) AutocompleteArgs() complete.Predictor

func (*WorkspaceSelectCommand) AutocompleteFlags

func (c *WorkspaceSelectCommand) AutocompleteFlags() complete.Flags

func (WorkspaceSelectCommand) Execute added in v0.21.0

func (*WorkspaceSelectCommand) Help

func (c *WorkspaceSelectCommand) Help() string

func (*WorkspaceSelectCommand) Run

func (c *WorkspaceSelectCommand) Run(rawArgs []string) int

func (*WorkspaceSelectCommand) Synopsis

func (c *WorkspaceSelectCommand) Synopsis() string

type WorkspaceShowCommand

type WorkspaceShowCommand struct {
	Meta
}

func (*WorkspaceShowCommand) AutocompleteArgs

func (c *WorkspaceShowCommand) AutocompleteArgs() complete.Predictor

func (*WorkspaceShowCommand) AutocompleteFlags

func (c *WorkspaceShowCommand) AutocompleteFlags() complete.Flags

func (WorkspaceShowCommand) Execute added in v0.21.0

func (*WorkspaceShowCommand) Help

func (c *WorkspaceShowCommand) Help() string

func (*WorkspaceShowCommand) Run

func (c *WorkspaceShowCommand) Run(rawArgs []string) int

func (*WorkspaceShowCommand) Synopsis

func (c *WorkspaceShowCommand) Synopsis() string

Source Files

Directories

Path Synopsis
Package cliconfig has the types representing and the logic to load CLI-level configuration settings.
Package cliconfig has the types representing and the logic to load CLI-level configuration settings.
ociauthconfig
Package ociauthconfig contains types used for describing OCI authentication settings, and helpers for discovering such settings from container engine configuration files as described in https://github.com/containers/image/blob/main/docs/containers-auth.json.5.md .
Package ociauthconfig contains types used for describing OCI authentication settings, and helpers for discovering such settings from container engine configuration files as described in https://github.com/containers/image/blob/main/docs/containers-auth.json.5.md .
svcauthconfig
Package svcauthconfig contains some helper functions and types to support the cliconfig package's use of github.com/opentofu/svchost/svcauth, which is our mechanism for representing the policy for authenticating to OpenTofu-native services such as implementations OpenTofu's provider registry protocol.
Package svcauthconfig contains some helper functions and types to support the cliconfig package's use of github.com/opentofu/svchost/svcauth, which is our mechanism for representing the policy for authenticating to OpenTofu-native services such as implementations OpenTofu's provider registry protocol.
Package state exposes common helpers for working with state from the CLI.
Package state exposes common helpers for working with state from the CLI.
Package e2etest contains a set of tests that run against a real OpenTofu binary, compiled on the fly at the start of the test run.
Package e2etest contains a set of tests that run against a real OpenTofu binary, compiled on the fly at the start of the test run.
fakeocireg
Package fakeocireg provides a minimal, read-only implementation of the OCI Distribution protocol that interacts with a local filesystem directory.
Package fakeocireg provides a minimal, read-only implementation of the OCI Distribution protocol that interacts with a local filesystem directory.
Package format contains helpers for formatting various OpenTofu structures for human-readable output.
Package format contains helpers for formatting various OpenTofu structures for human-readable output.
Package jsonchecks implements the common JSON representation of check results/statuses that we use across both the JSON plan and JSON state representations.
Package jsonchecks implements the common JSON representation of check results/statuses that we use across both the JSON plan and JSON state representations.
Package jsonconfig implements methods for outputting a configuration snapshot in machine-readable json format
Package jsonconfig implements methods for outputting a configuration snapshot in machine-readable json format
Package jsonentities contains the entities for representing a few common resources used around the json* packages.
Package jsonentities contains the entities for representing a few common resources used around the json* packages.
computed
Package computed contains types that represent the computed diffs for OpenTofu blocks, attributes, and outputs.
Package computed contains types that represent the computed diffs for OpenTofu blocks, attributes, and outputs.
structured
Package structured contains the structured representation of the JSON changes returned by the jsonplan package.
Package structured contains the structured representation of the JSON changes returned by the jsonplan package.
Package jsonplan implements methods for outputting a plan in a machine-readable json format
Package jsonplan implements methods for outputting a plan in a machine-readable json format
Package jsonprovider contains types and functions to marshal OpenTofu provider schemas into a json formatted output.
Package jsonprovider contains types and functions to marshal OpenTofu provider schemas into a json formatted output.
Package jsonstate implements methods for outputting a state in a machine-readable json format
Package jsonstate implements methods for outputting a state in a machine-readable json format
Package workdir models the various local artifacts and state we keep inside a OpenTofu "working directory".
Package workdir models the various local artifacts and state we keep inside a OpenTofu "working directory".

Jump to

Keyboard shortcuts

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