arguments

package
v0.21.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ReportUnowned   = "unowned"
	ReportAdoptable = "adoptable"
	ReportForeign   = "foreign"
)

The report categories -filter selects among (GitHub issue #1197). The words are the ones the code and live-plan's -json document already use for the same three sets - LivePlanDocument's "unowned", "adoptable" and "foreign" fields - so a filter word and a document key never name different things.

The 2026-09-26 ruling on #1197 fixed this vocabulary and deferred the other selectors the issue was filed with: "drifted" and "owned-by" are not computed as per-resource sets today, and "unclaimed" and "untagged" would be second names for foreign and unowned.

View Source
const DefaultParallelism = 10

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

View Source
const DefaultStateFilename = "terraform.tfstate"

DefaultStateFilename is the default filename used for the state file.

Variables

ReportFilterWords is every word -filter accepts, in the order the report prints the categories. The usage error for any other word lists exactly these.

Functions

func ParseLintingRules added in v0.21.0

func ParseLintingRules(rules []string) (collections.Set[linting.RuleAddr], collections.Set[linting.RuleAddr])

ParseLintingRules is a utility function that coordinates the parsing of a raw string into structured linting rules.

The lintingRulesRaw string argument is expected to contain a string separated list of linting rules to be executed or skipped.

Format: rule1,rule2,!rule3,!rule4

which will translate to "include rule1 and rule2" and "exclude rule3 and rule4".

Any parsing failure will be only logged. Due to the nature of the linting feature, we want to be permissive in this layer since migrating from one OpenTofu version to another some rules might be changed or removed which should not break the existing operators configuration.

This function allows for the same rule to be included and excluded but will warn about it. Due to the filtering rules in the internal/tfdiags/lint.go, in situations where the same rule is included and excluded, the inclusion will take precedence.

Types

type Apply

type Apply struct {
	// State, Operation, and Vars are the common extended flags
	State     *State
	Operation *Operation
	Vars      *Vars

	// AutoApprove skips the manual verification step for the apply operation.
	AutoApprove bool

	// PlanPath contains an optional path to a stored plan file
	PlanPath string

	// View represents the global view options
	View *View

	// SuppressForgetErrorsDuringDestroy suppresses the error that occurs when a
	// destroy operation completes successfully but leaves forgotten instances behind.
	SuppressForgetErrorsDuringDestroy bool

	// Verbose asks a command to print detail it would otherwise summarize.
	// See [Plan.Verbose] for what it is for and why it lives on Apply
	// directly rather than behind a shared, every-command flag: "-verbose"
	// already names an unrelated flag on "choudoufu test" and "choudoufu
	// graph" parsed ahead of a shared flag set's own turn.
	Verbose bool
}

Apply represents the command-line arguments for the apply command.

func BindApply added in v0.21.0

func BindApply(cli *CommandLine) *Apply

BindApply registers CLI arguments, returning a Apply value and it's corresponding hooks.

func BindApplyDestroy added in v0.21.0

func BindApplyDestroy(cli *CommandLine) *Apply

BindApplyDestroy registers CLI arguments, returning a Apply value and it's corresponding hooks.

func ParseApply

func ParseApply(args []string) (*Apply, func(), tfdiags.Diagnostics)

ParseApply processes CLI arguments, returning an Apply value, a closer function, and errors. If errors are encountered, an Apply value is still returned representing the best effort interpretation of the arguments.

func ParseApplyDestroy

func ParseApplyDestroy(args []string) (*Apply, func(), tfdiags.Diagnostics)

ParseApplyDestroy is a special case of ParseApply that deals with the "tofu destroy" command, which is effectively an alias for "tofu apply -destroy".

type Argument added in v0.21.0

type Argument struct {
	Name     string
	Optional bool
	Variadic bool
	// Process takes the current remaining os.Args entries and returns
	// the remainder after the given argument has been processed.
	Process func([]string) ([]string, error)
	Cli     cli.Argument
}

Argument represents a positional argument.

type Backend

type Backend struct {
	// IgnoreRemoteVersion is used with commands which write state to allow users to write remote
	// state even if the remote and local OpenTofu versions don't match.
	IgnoreRemoteVersion bool
	// ForceInitCopy suppresses confirmation for copying state data during init.
	ForceInitCopy bool
	// Reconfigure forces init to ignore any stored configuration.
	Reconfigure bool
	// MigrateState confirms the user wishes to migrate from the prior backend configuration to a new configuration.
	MigrateState bool
}

func BindBackend added in v0.21.0

func BindBackend(cli *CommandLine) *Backend

func BindBackendWithMigration added in v0.21.0

func BindBackendWithMigration(cli *CommandLine) *Backend

type CommandLine added in v0.21.0

type CommandLine struct {
	// Flags represents all flags available to the command line.
	Flags map[string]*Flag
	// FlagGroups defines the group headers for the Flags. These are
	// only used in a few specific commands for now and are typically
	// left empty.
	FlagGroups []FlagGroup

	// Args contains the positional arguments defined for a given command.
	// These are only allowed after all of the flag parsing is complete.
	Args []Argument
	// ArgsHelp is a field used to customize the argument error help text.
	// This is a legacy option and should not be used for any new commands.
	ArgHelp string

	// PreHooks contain the logic that should be run between os.Args
	// handling and the actual command logic.
	PreHooks Hooks
	// PostHooks contain the logic that should be run after the command
	// has completed and before os.Exit is called.
	// This is typically only used for the --json-into special case.
	PostHooks Hooks

	// This is a bit of a hack so we can correctly report diagnostics before actually executing the command
	View *View

	// These are hacks for the meta struct that should be removed as the meta struct is broken up and removed
	Backend   *Backend
	Operation *Operation
	State     *State
	Vars      *Vars
}

CommandLine represents the information need to represent the cli options available to a given OpenTofu command. It is used for both argument handling and help text construction.

func (*CommandLine) BoolVar added in v0.21.0

func (c *CommandLine) BoolVar(p *bool, name string, value bool, usage string) *Flag

BoolVar attaches a bool flag to the CommandLine.

func (*CommandLine) CliArguments added in v0.21.0

func (c *CommandLine) CliArguments() []cli.Argument

CliArguments builds the set of positional arguments to be attached to a command

func (*CommandLine) CliFlags added in v0.21.0

func (c *CommandLine) CliFlags() []cli.Flag

CliFlags builds the set of flags to be attached to a command

func (*CommandLine) DurationVar added in v0.21.0

func (c *CommandLine) DurationVar(p *time.Duration, name string, value time.Duration, usage string) *Flag

DurationVar attaches a time.Duration flag to the CommandLine.

func (*CommandLine) Flag added in v0.21.0

func (c *CommandLine) Flag(flag *Flag) *Flag

Flag registers the given flag to the CommandLine.

func (*CommandLine) IntVar added in v0.21.0

func (c *CommandLine) IntVar(p *int, name string, value int, usage string) *Flag

IntVar attaches a int flag to the CommandLine.

func (*CommandLine) ParseDirect added in v0.21.0

func (c *CommandLine) ParseDirect(ctx context.Context, args []string) tfdiags.Diagnostics

ParseDirect is only used for testing when we need to simuate processing the args. This is primarilly used in the command package.

func (*CommandLine) ParseLegacy added in v0.21.0

func (c *CommandLine) ParseLegacy(args []string) tfdiags.Diagnostics

ParseLegacy uses the old command line stdargs processing method. This currently exists as a fallback and is primarily used for testing. Once we have completely switched to a new CLI library, the tests can be updated and this function removed.

func (*CommandLine) PositionalArg added in v0.21.0

func (c *CommandLine) PositionalArg(p *string, name string, optional bool)

PositionalArg registers a positional argument.

func (*CommandLine) PositionalArgs added in v0.21.0

func (c *CommandLine) PositionalArgs(remaining []string) tfdiags.Diagnostics

PositionalArgs processes the input as a set of positional arguments. This should be the entries remaining after Flag parsing.

func (*CommandLine) PositionalError added in v0.21.0

func (c *CommandLine) PositionalError(remaining []string, argsErrored bool) tfdiags.Diagnostics

PositionalError is the common error handling of remaining positional arguments

func (*CommandLine) PostHook added in v0.21.0

func (c *CommandLine) PostHook(h func() tfdiags.Diagnostics)

PostHook is a helper function to add a hook to the command line processing.

func (*CommandLine) PreHook added in v0.21.0

func (c *CommandLine) PreHook(h func() tfdiags.Diagnostics)

PreHook is a helper function to add a hook to the command line processing.

func (*CommandLine) RawFlags added in v0.21.0

func (c *CommandLine) RawFlags(p flags.RawFlags, name string, usage string) *Flag

RawFlags attaches a flags.RawFlags to the CommandLine. This is a deprecated function and should be removed once var and var-file processing is improved. This will correspond with the removal of the flags package.

func (*CommandLine) RemainCheck added in v0.21.0

func (c *CommandLine) RemainCheck(remaining []string) tfdiags.Diagnostics

RemainCheck handles positional arguments and produces a corresponding error if nessesary.

func (*CommandLine) StringArrayVar added in v0.21.0

func (c *CommandLine) StringArrayVar(p *[]string, name string, value []string, usage string) *Flag

StringArrayVar attaches a StringArray flag to the CommandLine. This treats every instance of -name is a new entry and does not perform any ',' splitting.

func (*CommandLine) StringVar added in v0.21.0

func (c *CommandLine) StringVar(p *string, name string, value string, usage string) *Flag

StringVar attaches a string flag to the CommandLine.

func (*CommandLine) VariadicArg added in v0.21.0

func (c *CommandLine) VariadicArg(p *[]string, name string)

VariadicArg registers a variadic argument.

type Console

type Console struct {
	// View represents the global view options
	View *View
	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars
	// State is used for the state related flags
	State *State
}

Console represents the command-line arguments for the console command.

func BindConsole added in v0.21.0

func BindConsole(cli *CommandLine) *Console

BindConsole registers CLI arguments, returning a Console value and it's corresponding hooks.

func ParseConsole

func ParseConsole(args []string) (*Console, func(), tfdiags.Diagnostics)

ParseConsole processes CLI arguments, returning a Console value, a closer function, and errors. If errors are encountered, a Console value is still returned representing the best effort interpretation of the arguments.

type DeprecationWarningLevel

type DeprecationWarningLevel uint8

DeprecationWarningLevel defines different levels of deprecation warnings that can be used by the user to control what type of warnings it wants to see

const (
	// DeprecationWarningLevelAll shows all deprecation warnings for outputs and variables, where no filtering is applied.
	DeprecationWarningLevelAll DeprecationWarningLevel = iota
	// DeprecationWarningLevelLocal shows only the deprecation warnings for the outputs and variables that are coming from
	// modules that are referenced with a relative path (aka local module).
	DeprecationWarningLevelLocal
	// DeprecationWarningLevelNone disables any deprecation warnings, filtering out any diagnostic that was generated about
	// this.
	DeprecationWarningLevelNone
)

func ParseDeprecatedWarningLevel

func ParseDeprecatedWarningLevel(s string) DeprecationWarningLevel

ParseDeprecatedWarningLevel gets in a string and returns a DeprecationWarningLevel. Since these warnings are not critical to the system, this method is returning no error when the warn level identifier is missing a mapping. Instead, it falls back on returning the level that will write all the deprecation warnings.

func (DeprecationWarningLevel) String

func (i DeprecationWarningLevel) String() string

type Flag added in v0.21.0

type Flag struct {
	// Name is the name of the flag.
	Name string
	// Usage is the usage text that will be formatted.  It may include
	// newlines, but it is discouraged.
	Usage string
	// GroupID is the group that this flag is nested under. This is
	// for formatting in the help/usage text.
	GroupID string
	// Display is a suffix for the Name during help text formatting. For example:
	// Display: "=value", would render as
	//   --flag-name=value
	Display string
	// Hidden determines if this flag be visible in help text.
	Hidden bool
	// Global determines if this flag is allowed to intermix with positional
	// arguments. This is a view holdover and should be considered for removal
	// at some future date.
	Global bool

	// Stdlib implementation of this flag. Will be removed once the new
	// CLI adoption is complete.
	Stdlib func(*flag.FlagSet)
	// Cli implementation of this flag (urfave/cli)
	Cli func() cli.Flag

	// IsSet is a workaround for -backend and -cloud. TODO consider
	// proper argument aliases as supported by the cli implementation.
	IsSet func() bool
}

Flag is our representation of a command line flag and the implementation details of interfacing it with a given command line library.

func (*Flag) SetDisplay added in v0.21.0

func (f *Flag) SetDisplay(display string) *Flag

func (*Flag) SetGlobal added in v0.21.0

func (f *Flag) SetGlobal(mixed bool) *Flag

func (*Flag) SetGroup added in v0.21.0

func (f *Flag) SetGroup(id string) *Flag

func (*Flag) SetHidden added in v0.21.0

func (f *Flag) SetHidden(hidden bool) *Flag

type FlagGroup added in v0.21.0

type FlagGroup struct {
	// ID corresponds to flag's GroupID
	ID string
	// Title of the group
	Title string
	// Description present below the title
	Description string
	// Suffix text for after the group flags have
	// been rendered
	Suffix string
}

FlagGroup is the information needed to define a flag grouping for help text display.

type Fmt

type Fmt struct {
	// Paths contains the file paths that the formatter will handle.
	// When no arguments given to the command, it will use the current directory.
	// If the first argument is -, it will read the content to format from [os.Stdin].
	Paths []string

	// List controls the output of the formatted list. If disabled, it will not print the
	// names of the formatted files.
	List bool
	// Write controls if the formatter should write the content back to the check file or not.
	Write bool
	// Diff tells to the formatter to print the diff between the before and after formatting
	// process.
	Diff bool
	// Check can be used to instruct the command to return a non-zero error code if it finds
	// any file that is not properly formatted.
	Check bool
	// Recursive indicates that the formatting should be done recursive through all the
	// subdirectories.
	Recursive bool

	// View represents the global view options
	View *View
}

Fmt represents the command-line arguments for the fmt command.

func BindFmt added in v0.21.0

func BindFmt(cli *CommandLine) *Fmt

BindFmt registers CLI arguments, returning a Fmt value and it's corresponding hooks.

func ParseFmt

func ParseFmt(args []string) (*Fmt, func(), tfdiags.Diagnostics)

ParseFmt processes CLI arguments, returning a Fmt value, a closer function, and errors. If errors are encountered, a Fmt value is still returned representing the best effort interpretation of the arguments.

type Get

type Get struct {
	// Update is the flag that can be used to upgrade the version of the modules.
	Update bool
	// TestsDirectory indicates the path where the tests are stored
	TestsDirectory string

	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars
	// View represents the global view options
	View *View
}

Get represents the command-line arguments for the get command.

func BindGet added in v0.21.0

func BindGet(cli *CommandLine) *Get

BindGet registers CLI arguments, returning a Get value and it's corresponding hooks.

func ParseGet

func ParseGet(args []string) (*Get, func(), tfdiags.Diagnostics)

ParseGet processes CLI arguments, returning a Get value, a closer function, and errors. If errors are encountered, a Get value is still returned representing the best effort interpretation of the arguments.

type Graph

type Graph struct {
	// DrawCycles highlights any cycles in the graph with colored edges.
	DrawCycles bool
	// GraphType specifies the type of graph to output (plan, plan-refresh-only, plan-destroy, or apply).
	GraphType string
	// ModuleDepth specifies the depth of modules to show in the output.
	ModuleDepth int
	// Verbose enables verbose output.
	Verbose bool
	// PlanPath specifies the path to a plan file to render the graph from.
	PlanPath string

	// View represents the global view options
	View *View

	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars
}

Graph represents the command-line arguments for the graph command.

func BindGraph added in v0.21.0

func BindGraph(cli *CommandLine) *Graph

BindGraph registers CLI arguments, returning a Graph value and it's corresponding hooks.

func ParseGraph

func ParseGraph(args []string) (*Graph, func(), tfdiags.Diagnostics)

ParseGraph processes CLI arguments, returning a Graph value, a closer function, and errors. If errors are encountered, a Graph value is still returned representing the best effort interpretation of the arguments.

type Hook added in v0.21.0

type Hook func() tfdiags.Diagnostics

Hook is a function that will be executed pre or post command execution

type Hooks added in v0.21.0

type Hooks []Hook

Hooks is a list of hooks with a helper method

func (Hooks) Run added in v0.21.0

func (h Hooks) Run() tfdiags.Diagnostics

Run executes all hooks sequentially and returns any diagnostics encountered.

type Import

type Import struct {
	// ResourceAddress is the absolute resource address that the user is required to provide to indicate
	// on which configuration resource the state of the resource needs to be imported.
	ResourceAddress string
	// ResourceID is the platform provided ID of the resource to be imported.
	ResourceID string
	// ConfigPath is the path to the directory where the configuration containing the ResourceAddress is
	// accessible.
	ConfigPath string
	// Parallelism is the limit of concurrent operation as OpenTofu walks the graph
	Parallelism int

	// View represents the global view options
	View *View
	// State, Backend and Vars are the common extended flags
	State   *State
	Backend *Backend
	Vars    *Vars
}

Import represents the command-line arguments for the import command.

func BindImport added in v0.21.0

func BindImport(cli *CommandLine) *Import

BindImport registers CLI arguments, returning a Import value and it's corresponding hooks.

func ParseImport

func ParseImport(args []string) (*Import, func(), tfdiags.Diagnostics)

ParseImport processes CLI arguments, returning an Import value, a closer function, and errors. If errors are encountered, an Import value is still returned representing the best effort interpretation of the arguments.

type Init

type Init struct {
	// Copy the contents of the given module into the target directory before initialisation
	FlagFromModule string
	// Lockfile operation mode. Currently only "readonly" is valid.
	FlagLockfile string
	// Set the OpenTofu test directory. When set, the
	// test command will search for test files in the current directory and
	// in the one specified by the flag.
	TestsDirectory string
	// When set to false, disables modules downloading for the current configuration
	FlagGet bool
	// Install the latest module and provider versions allowed within configured constraints, overriding the
	// default behavior of selecting exactly the version recorded in the dependency lockfile.
	FlagUpgrade bool
	// Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the
	// automatic installation of plugins. This flag can be used multiple times.
	FlagPluginPath []string
	// Configuration to be merged with what is in the configuration file's 'backend' block. This can be
	// either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a
	// 'key=value' format, and can be specified multiple times. The backend type must be in the configuration itself.
	FlagConfigExtra flagspkg.RawFlags
	// Disable backend or cloud backend initialization for this configuration and use what was previously
	// initialized instead. This and the FlagCloud cannot be toggled in the same time.
	FlagBackend bool
	FlagCloud   bool

	// Bools indicating that the FlagBackend and FlagCloud have been found into the arguments list of the
	// process.
	BackendFlagSet bool
	CloudFlagSet   bool

	// View represents the global view options
	View *View

	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars
	// Backend holds and providers information for the flags related to the backend operations, like locking
	// locking timeout, force migration, etc.
	Backend *Backend
	// State is used for the state related flags
	State *State
}

Init represents the command-line arguments for the init command.

func BindInit added in v0.21.0

func BindInit(cli *CommandLine) *Init

BindInit registers CLI arguments, returning a Init value and it's corresponding hooks.

func ParseInit

func ParseInit(args []string) (*Init, func(), tfdiags.Diagnostics)

ParseInit processes CLI arguments, returning an Init value, a closer function, and errors. If errors are encountered, an Init value is still returned representing the best effort interpretation of the arguments.

type LiveBucket added in v0.18.0

type LiveBucket struct {
	// Bucket names the bucket to report on. Empty means "the one this
	// directory's live block declares", which is how an operator checks the
	// bucket an estate actually uses; set, no configuration is read at all,
	// which is how the runnable bucket project checks the bucket it just
	// made before any estate exists.
	Bucket string

	// Region is where the bucket is. Empty defers to the record_store
	// block's own region, then to the AWS SDK's default resolution.
	Region string

	// BucketOwner is the AWS account that must own the bucket, as twelve
	// digits. Empty defers to the record_store block's own bucket_owner,
	// then to no check at all. Set, the three reads carry it as
	// ExpectedBucketOwner and a bucket of this name in another account is
	// refused rather than reported on (GitHub issue #1381).
	BucketOwner string

	// Estate scopes the lifecycle assertion to one estate's namespaces. Only
	// meaningful with Bucket; with a configuration the live block's own
	// estate is used.
	Estate string

	// JSON asks for one JSON document on stdout instead of the table.
	JSON bool
}

LiveBucket is the parsed command line of "choudoufu live-bucket".

func BindLiveBucket added in v0.21.0

func BindLiveBucket(cli *CommandLine) *LiveBucket

BindLiveBucket registers live-bucket's options on cli. The view options are the ones every command shares (-no-color and the warning controls); -json is this command's own, because what it prints is one document of its own rather than the UI-message stream BindView's -json selects.

func ParseLiveBucket added in v0.18.0

func ParseLiveBucket(args []string) (*LiveBucket, tfdiags.Diagnostics)

ParseLiveBucket processes CLI arguments through BindLiveBucket, the way the new CLI does, for callers that hold a raw argument list.

type LiveCheck added in v0.21.0

type LiveCheck struct {
	// Dir is the configuration directory to check. "." when none was given.
	Dir string

	// JSON asks for GitHub issue #790's declared roster instead of the prose
	// report.
	JSON bool
}

LiveCheck is the parsed command line of "choudoufu live-check".

func BindLiveCheck added in v0.21.0

func BindLiveCheck(cli *CommandLine) *LiveCheck

BindLiveCheck registers live-check's options on cli: the shared view options, -json, and at most one directory. GitHub issue #114's rule is that live-check accepts no options of its own; #790 widened that by -json alone, and any other flag is a usage error.

func ParseLiveCheck added in v0.21.0

func ParseLiveCheck(args []string) (*LiveCheck, tfdiags.Diagnostics)

ParseLiveCheck processes CLI arguments through BindLiveCheck.

type LiveCluster added in v0.19.0

type LiveCluster struct {
	// Namespace names the records namespace to report on. Empty means "the
	// one this directory's configuration resolves to", which is how an
	// operator checks the namespace an estate actually uses.
	//
	// Set, it overrides the namespace and nothing else (GitHub issue
	// #1448). A record_store "kubernetes" block in this directory still
	// says which cluster is reached, because a report about some other
	// cluster's namespace of the same name is a report about nothing.
	// Outside a configuration directory there is no such block and the
	// ambient kubeconfig is reached, which is how a cluster admin checks a
	// namespace before any estate exists.
	Namespace string

	// Estate is the estate whose records live there. With -namespace it is
	// only reported; without one it is what the default namespace name is
	// derived from.
	Estate string

	// PlanIdentity asks the question a CI plan job's identity would ask:
	// does it have what a PLAN needs, which is get and list and not the
	// three write verbs. Without it the question is what an apply needs.
	PlanIdentity bool

	// JSON asks for one JSON document on stdout instead of the table.
	JSON bool
}

LiveCluster is the parsed command line of "choudoufu live-cluster".

func BindLiveCluster added in v0.21.0

func BindLiveCluster(cli *CommandLine) *LiveCluster

BindLiveCluster registers live-cluster's options on cli. See BindLiveBucket for why -json is the command's own.

func ParseLiveCluster added in v0.19.0

func ParseLiveCluster(args []string) (*LiveCluster, tfdiags.Diagnostics)

ParseLiveCluster processes CLI arguments through BindLiveCluster.

type LiveImport added in v0.3.0

type LiveImport struct {
	// StatePath is the tfstate file to read, once, read-only. Required:
	// there is no default the way -state defaults to terraform.tfstate for
	// state-backed commands, because reading one by accident is exactly what
	// this command's whole design refuses to do.
	StatePath string

	// Estate names the estate this run would stamp. Required: unlike
	// live-plan and live-mv, there is no configuration for this command to
	// derive it from - the state file being imported may belong to a
	// configuration that has never heard of markers at all.
	Estate string

	// Approve turns the run from a read-only ratification into one that also
	// stamps: without it, the report prints and nothing is written; with it,
	// every VERIFIED or DRIFTED resource from that same report is stamped.
	Approve bool

	// Parallelism is how many resources -approve may stamp at once, spelled
	// and defaulted exactly as stock's apply spells and defaults it, because
	// it is the same budget over the same kind of work: one provider
	// plan+apply round trip per instance. It has no effect without -approve,
	// since a ratification only reads.
	//
	// GitHub issue #583. Stamping was sequential, and #566 measured it as the
	// dominant cost of migrating a terralith: 33.1s for 26 resources, 127.6s
	// for 89.
	Parallelism int
}

LiveImport represents the command-line arguments for the live-import command.

func BindLiveImport added in v0.21.0

func BindLiveImport(cli *CommandLine) *LiveImport

BindLiveImport registers live-import's options on cli.

func ParseLiveImport added in v0.3.0

func ParseLiveImport(args []string) (*LiveImport, tfdiags.Diagnostics)

ParseLiveImport processes CLI arguments through BindLiveImport, returning a LiveImport value and errors. If errors are encountered, a LiveImport value is still returned representing the best effort interpretation of the arguments.

type LiveLs added in v0.12.0

type LiveLs struct {
	// Estate is the tofu-estate value to list. Required: unlike live-plan,
	// there is no configuration this command must be run against at all, so
	// there is nothing to derive the name from the way live-mv falls back to
	// a live block's own estate setting.
	Estate string

	// Region narrows where the Tagging API and IAM calls go. Empty defers to
	// the AWS SDK's own default region resolution (AWS_REGION, the shared
	// config file, or an endpoint override's own region), the same as every
	// other AWS client this fork builds.
	Region string

	// Consistent asks the listing to re-read itself until two consecutive
	// reads agree, rather than returning the first read as-is. See
	// [command.pollConsistent] for why this exists at all: the Resource
	// Groups Tagging API's index lags a tag write by about a minute
	// (live-mv's own tag rewrite included), so a listing taken right after a
	// move can show a resource under both its old and new estate, or under
	// neither, and every caller of this command would otherwise reinvent the
	// same wait by hand.
	Consistent bool

	// ConfigDir is the configuration directory to cross-reference the
	// listing against, naming which declared instances the listing's own
	// mechanism structurally cannot see - the record rung and the
	// declaration-carried rung, see live/MARKERS.md's tier definitions
	// (#417) - so that a reader can tell a rung from a genuine absence.
	// Empty means no directory was given, and the listing prints with no
	// such cross-reference at all: this command's core promise (list what
	// the account holds under an estate) needs no configuration to keep.
	ConfigDir string

	// View carries -json. -json-into is deliberately NOT offered here - see
	// BindLiveLs's own comment.
	View *View
}

LiveLs represents the command-line arguments for the live-ls command.

func BindLiveLs added in v0.21.0

func BindLiveLs(cli *CommandLine) *LiveLs

BindLiveLs registers live-ls's options and its optional directory on cli.

func ParseLiveLs added in v0.12.0

func ParseLiveLs(args []string) (*LiveLs, func(), tfdiags.Diagnostics)

ParseLiveLs processes CLI arguments through BindLiveLs, returning a LiveLs value, a closer and errors. If errors are encountered, a LiveLs value is still returned representing the best effort interpretation of the arguments.

type LiveMv

type LiveMv struct {
	// RawOldAddr is the address the live resource carries now, and
	// RawNewAddr is the one this run writes onto it. Both are unparsed here;
	// the command parses them as resource instance addresses, which is where
	// the diagnostic about a malformed one belongs.
	RawOldAddr string
	RawNewAddr string

	// Estate names the estate that owns the resource. Empty means the flag
	// was absent, and the name is derived from the configuration instead -
	// from a live block, or from the tofu-estate tags the configuration
	// itself stamps. Unlike live-plan, this command cannot run without one.
	Estate string

	// FromEstate, when set, makes the rename a cross-estate move: the live
	// resource is found under this estate's tag and rewritten to carry the
	// configuration's own. Empty is an ordinary rename within one estate.
	FromEstate string

	// DryRun makes every check and reports what would be rewritten, without
	// writing.
	DryRun bool

	// AllowMissingConfig permits a destination address the configuration does
	// not declare, for a rename whose configuration edit has not happened yet.
	AllowMissingConfig bool

	// JSON asks for the move as one document rather than the labelled-rows
	// report - GitHub issue #791. Everything the human report already says
	// is in it, plus what only this flag exposes: the followers that move
	// with no write of their own, a refusal's stable code alongside its
	// text, and (on a real write) whatever the provider handed back for a
	// receipt to match against. See internal/command/views/live_mv.go's
	// StatelessMvJSONReport.
	JSON bool
}

LiveMv represents the command-line arguments for the live-mv command.

func BindLiveMv added in v0.21.0

func BindLiveMv(cli *CommandLine) *LiveMv

BindLiveMv registers live-mv's options and its two addresses on cli.

Options may sit before or after the two addresses under the new CLI; the legacy CLI's stdlib parser still stops at the first address. The addresses are left unparsed here; the command parses them as resource instance addresses, which is where the diagnostic about a malformed one belongs. See BindLiveBucket for why -json is the command's own.

func ParseLiveMv

func ParseLiveMv(args []string) (*LiveMv, tfdiags.Diagnostics)

ParseLiveMv processes CLI arguments through BindLiveMv, returning a LiveMv value and errors. If errors are encountered, a LiveMv value is still returned representing the best effort interpretation of the arguments.

type LivePlan

type LivePlan struct {
	// Plan is the stock plan argument set, embedded so that -target, -var,
	// -var-file, -refresh and the rest parse and behave identically. Anything
	// live-plan cannot honor is rejected by the command after parsing, rather
	// than removed from the flag set here, so that an operator who passes one
	// is told so instead of being ignored.
	*Plan

	// Estate names the estate whose ownership markers this run looks for. An
	// empty value means the flag was absent, which is not an error: the name
	// is then derived from the configuration, and a run that cannot derive it
	// degrades rather than fails. It is an error only when the configuration
	// has a live block, since the block names the estate itself; the command
	// makes that check, because it needs a loaded configuration to make it.
	Estate string
}

LivePlan represents the command-line arguments for the live-plan command, which is the plan command's whole option set plus -estate.

func BindLivePlan added in v0.21.0

func BindLivePlan(cli *CommandLine) *LivePlan

BindLivePlan registers the live-plan command's options on cli: the plan command's whole option set, from BindPlan, plus -estate.

-estate is registered here rather than added to Plan, which would make it an option of "choudoufu plan" as well: a flag naming a stateless concept on the command that has state files. Registering it on live-plan's own CommandLine keeps the stock plan surface exactly as it was, and still gets -estate the parsing every other option has - end-of-flags handling, the -estate=NAME and -estate NAME forms, and a real error for a flag that is not one.

func ParseLivePlan

func ParseLivePlan(args []string) (*LivePlan, func(), tfdiags.Diagnostics)

ParseLivePlan processes CLI arguments, returning a LivePlan value, a closer function, and errors. If errors are encountered, a LivePlan value is still returned representing the best effort interpretation of the arguments.

type Login

type Login struct {
	// Host represents the host that OpenTofu will try to login to
	Host string

	// View represents the global view options
	View *View
	// Vars and State are the common extended flags
	Vars  *Vars
	State *State
}

Login represents the command-line arguments for the login command.

func BindLogin added in v0.21.0

func BindLogin(cli *CommandLine) *Login

BindLogin registers CLI arguments, returning a Login value and it's corresponding hooks.

func ParseLogin

func ParseLogin(args []string) (*Login, func(), tfdiags.Diagnostics)

ParseLogin processes CLI arguments, returning a Login value, a closer function, and errors. If errors are encountered, a Login value is still returned representing the best effort interpretation of the arguments.

type Logout

type Logout struct {
	// Host represents the host that OpenTofu will try to log out of
	Host string

	// View represents the global view options
	View *View
}

Logout represents the command-line arguments for the logout command.

func BindLogout added in v0.21.0

func BindLogout(cli *CommandLine) *Logout

BindLogout registers CLI arguments, returning a Logout value and it's corresponding hooks.

func ParseLogout

func ParseLogout(args []string) (*Logout, func(), tfdiags.Diagnostics)

ParseLogout processes CLI arguments, returning a Logout value, a closer function, and errors. If errors are encountered, a Logout value is still returned representing the best effort interpretation of the arguments.

type MetadataFunctions

type MetadataFunctions struct {
	// View represents the global view options
	View *View
}

MetadataFunctions represents the command-line arguments for the "metadata functions" command.

func BindMetadataFunctions added in v0.21.0

func BindMetadataFunctions(cli *CommandLine) *MetadataFunctions

BindMetadataFunctions registers CLI arguments, returning a MetadataFunctions value and it's corresponding hooks.

func ParseMetadataFunctions

func ParseMetadataFunctions(args []string) (*MetadataFunctions, func(), tfdiags.Diagnostics)

ParseMetadataFunctions processes CLI arguments, returning a MetadataFunctions value, a closer function, and errors. If errors are encountered, a MetadataFunctions value is still returned representing the best effort interpretation of the arguments.

type Operation

type Operation struct {
	// PlanMode selects one of the mutually-exclusive planning modes that
	// decides the overall goal of a plan operation. This field is relevant
	// only for an operation that produces a plan.
	PlanMode plans.Mode

	// Parallelism is the limit OpenTofu places on total parallel operations
	// as it walks the dependency graph.
	Parallelism int

	// Refresh controls whether or not the operation should refresh existing
	// state before proceeding. Default is true.
	Refresh bool

	// Targets allow limiting an operation to a set of resource addresses and
	// their dependencies.
	Targets []addrs.Targetable

	// Excludes allow limiting an operation to execute on all resources other
	// than a set of excluded resource addresses and resources dependent on them.
	Excludes []addrs.Targetable

	// ForceReplace addresses cause OpenTofu to force a particular set of
	// resource instances to generate "replace" actions in any plan where they
	// would normally have generated "no-op" or "update" actions.
	//
	// This is currently limited to specific instances because typical uses
	// of replace are associated with only specific remote objects that the
	// user has somehow learned to be malfunctioning, in which case it
	// would be unusual and potentially dangerous to replace everything under
	// a module all at once. We could potentially loosen this later if we
	// learn a use-case for broader matching.
	ForceReplace []addrs.AbsResourceInstance
}

Operation describes arguments which are used to configure how a OpenTofu operation such as a plan or apply executes.

func BindOperation added in v0.21.0

func BindOperation(cli *CommandLine) *Operation

bind registers all Operation flags

type Output

type Output struct {
	// Name identifies which root module output to show.  If empty, show all
	// outputs.
	Name string

	// View represents the global view options
	View *View
	// Vars and State are the common extended flags
	Vars  *Vars
	State *State
}

Output represents the command-line arguments for the output command.

func BindOutput added in v0.21.0

func BindOutput(cli *CommandLine) *Output

BindOutput registers CLI arguments, returning a Output value and it's corresponding hooks.

func ParseOutput

func ParseOutput(args []string) (*Output, func(), tfdiags.Diagnostics)

ParseOutput processes CLI arguments, returning an Output value, a closer function, and errors. If errors are encountered, an Output value is still returned representing the best effort interpretation of the arguments.

type Plan

type Plan struct {
	// State, Operation, and Vars are the common extended flags
	State     *State
	Operation *Operation
	Vars      *Vars

	// DetailedExitCode enables different exit codes for error, success with
	// changes, and success with no changes.
	DetailedExitCode bool

	// OutPath contains an optional path to store the plan file
	OutPath string

	// GenerateConfigPath tells OpenTofu that config should be generated for
	// unmatched import target paths and which path the generated file should
	// be written to.
	GenerateConfigPath string

	// View represents the global view options
	View *View

	// Verbose asks a command to print detail it would otherwise summarize.
	// Live resource markers is the first consumer: the "Not swept for
	// removal" section's full type-by-type breakdown, collapsed to a
	// one-line count by default (GitHub issue #78, "First plan drowns a
	// small estate in the not-swept type list"). It lives on Plan itself,
	// not added by [BindLivePlan] the way -estate is (see that
	// function's own comment), because -verbose does nothing to a stock
	// plan rather than naming a stateless-only concept, and because it also
	// needs to reach "choudoufu apply" against a live block
	// (arguments.Apply.Verbose), where -estate has no equivalent need
	// (arguments.Apply has none either).
	Verbose bool

	// AdoptionOnly asks for GitHub issue #587's adoption-only view: the plan
	// runs exactly as it would otherwise, and what it PRINTS is the adoption
	// ledger alone - what can be adopted, what cannot, and why - with the
	// resource diff and the other live-markers sections suppressed.
	//
	// It sits on Plan for -verbose's reason and not for -estate's. It has to
	// reach plain "choudoufu plan", because under a live block that is the
	// live-markers pipeline (LivePlanCommand.Execute delegates to PlanCommand),
	// and only [ParsePlan] parses that command's flags; -estate needs the
	// opposite, since a live block naming the estate is precisely when -estate
	// must be refused. Unlike -verbose it does name a stateless-only concept,
	// so a stock, state-backed plan refuses it outright rather than ignoring
	// it - see planRejectAdoptionOnly in the command package. Registering it
	// here and refusing it there is what makes "choudoufu plan
	// -adoption-only" against a state file say so, instead of "flag provided
	// but not defined".
	AdoptionOnly bool

	// Filter narrows the live-markers report to the named categories
	// (GitHub issue #1197): see [ReportFilter]. It sits on Plan for
	// -adoption-only's reason - under a live block plain "choudoufu plan" is
	// the live-markers pipeline, and only [ParsePlan] parses that command's
	// flags - and a stock, state-backed plan refuses it the same way
	// (planRejectReportFilter in the command package).
	Filter ReportFilter
}

Plan represents the command-line arguments for the plan command.

func BindPlan added in v0.21.0

func BindPlan(cli *CommandLine) *Plan

BindPlan registers CLI arguments, returning a Plan value and it's corresponding hooks.

func ParsePlan

func ParsePlan(args []string) (*Plan, func(), tfdiags.Diagnostics)

ParsePlan processes CLI arguments, returning a Plan value, a closer function, and errors. If errors are encountered, a Plan value is still returned representing the best effort interpretation of the arguments.

type Providers

type Providers struct {
	// TestsDirectory indicates the path where the tests are stored
	TestsDirectory string

	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars
	// View represents the global view options
	View *View
}

Providers represents the command-line arguments for the providers command.

func BindProviders added in v0.21.0

func BindProviders(cli *CommandLine) *Providers

BindProviders registers CLI arguments, returning a Providers value and it's corresponding hooks.

func ParseProviders

func ParseProviders(args []string) (*Providers, func(), tfdiags.Diagnostics)

ParseProviders processes CLI arguments, returning a Providers value, a closer function, and errors. If errors are encountered, a Providers value is still returned representing the best effort interpretation of the arguments.

type ProvidersLock

type ProvidersLock struct {
	// Providers are the source addresses of the providers that are requested to be updated
	Providers []string
	// OptPlatforms contains the platforms that the user requested for the locks to be updated for.
	// Having this empty, only the checksum for the host platform will be updated, but the user
	// can use this to update the hashes for other platforms too.
	OptPlatforms []string
	// FsMirrorDir represents a path from where OpenTofu should check for providers instead to reach
	// out for the registry.
	FsMirrorDir string
	// NetMirrorURL represents a URL to a mirrored registry from where OpenTofu should check for
	// providers instead to reach out for the registry.
	NetMirrorURL string
	// OciMirrorTemplate represents a URI-style template string that evaluates to an OCI repository address
	// to use for the providers.
	OciMirrorTemplate string

	// View represents the global view options
	View *View
	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars
}

ProvidersLock represents the command-line arguments for the 'providers lock' command.

func BindProvidersLock added in v0.21.0

func BindProvidersLock(cli *CommandLine) *ProvidersLock

BindProvidersLock registers CLI arguments, returning a ProvidersLock value and it's corresponding hooks.

func ParseProvidersLock

func ParseProvidersLock(args []string) (*ProvidersLock, func(), tfdiags.Diagnostics)

ParseProvidersLock processes CLI arguments, returning a ProvidersLock value, a closer function, and errors. If errors are encountered, a ProvidersLock value is still returned representing the best effort interpretation of the arguments.

type ProvidersMirror

type ProvidersMirror struct {
	// Directory is the directory where the copies of the providers will be stored
	Directory string
	// OptPlatforms contains the platforms that the user requested to have the providers
	// copy for
	OptPlatforms []string

	// View represents the global view options
	View *View
	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars
}

ProvidersMirror represents the command-line arguments for the 'providers lock' command.

func BindProvidersMirror added in v0.21.0

func BindProvidersMirror(cli *CommandLine) *ProvidersMirror

BindProvidersMirror registers CLI arguments, returning a ProvidersMirror value and it's corresponding hooks.

func ParseProvidersMirror

func ParseProvidersMirror(args []string) (*ProvidersMirror, func(), tfdiags.Diagnostics)

ParseProvidersMirror processes CLI arguments, returning a ProvidersMirror value, a closer function, and errors. If errors are encountered, a ProvidersMirror value is still returned representing the best effort interpretation of the arguments.

type ProvidersSchema

type ProvidersSchema struct {
	// View represents the global view options
	View *View

	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars
}

ProvidersSchema represents the command-line arguments for the 'providers schema' command.

func BindProvidersSchema added in v0.21.0

func BindProvidersSchema(cli *CommandLine) *ProvidersSchema

BindProvidersSchema registers CLI arguments, returning a ProvidersSchema value and it's corresponding hooks.

func ParseProvidersSchema

func ParseProvidersSchema(args []string) (*ProvidersSchema, func(), tfdiags.Diagnostics)

ParseProvidersSchema processes CLI arguments, returning a ProvidersSchema value, a closer function, and errors. If errors are encountered, a ProvidersSchema value is still returned representing the best effort interpretation of the arguments.

type Refresh

type Refresh struct {
	// State, Operation, and Vars are the common extended flags
	State     *State
	Operation *Operation
	Vars      *Vars

	// View represents the global view options
	View *View
}

Refresh represents the command-line arguments for the apply command.

func BindRefresh added in v0.21.0

func BindRefresh(cli *CommandLine) *Refresh

BindRefresh registers CLI arguments, returning a Refresh value and it's corresponding hooks.

func ParseRefresh

func ParseRefresh(args []string) (*Refresh, func(), tfdiags.Diagnostics)

ParseRefresh processes CLI arguments, returning a Refresh value, a closer function, and errors. If errors are encountered, a Refresh value is still returned representing the best effort interpretation of the arguments.

type ReportFilter added in v0.20.0

type ReportFilter []string

ReportFilter is the set of report categories a run asked to see. Empty means no filter: every category renders, as it always has.

A filter narrows the REPORT, never the plan. The 2026-09-26 ruling on #1197 is explicit that a filtered apply would be a partial apply and is not built: the planned changes, the resource diff and the exit code's meaning are the same with or without it. Only the three category sections named above, and the matching fields of the -json document, are narrowed.

Repeated -filter flags union: "-filter unowned -filter foreign" shows both. The value is kept in ReportFilterWords order and without duplicates, so the document's "filter" field reads the same however the flags were ordered.

func (ReportFilter) Active added in v0.20.0

func (f ReportFilter) Active() bool

Active reports whether any filter was given.

func (ReportFilter) Shows added in v0.20.0

func (f ReportFilter) Shows(category string) bool

Shows reports whether category renders under this filter. Every category renders when no filter was given.

type Show

type Show struct {
	// TargetType and TargetArg together describe the object that was
	// requested to be shown.
	//
	// The meaning of TargetArg varies depending on TargetType. Refer to
	// the documentation for each [ShowTargetType] constant for details.
	TargetType ShowTargetType
	TargetArg  string

	// View represents the global view options
	View *View

	Vars *Vars
}

Show represents the command-line arguments for the show command.

func BindShow added in v0.21.0

func BindShow(cli *CommandLine) *Show

BindShow registers CLI arguments, returning a Show value and it's corresponding hooks.

func ParseShow

func ParseShow(args []string) (*Show, func(), tfdiags.Diagnostics)

ParseShow processes CLI arguments, returning a Show value, a closer function, and errors. If errors are encountered, a Show value is still returned representing the best effort interpretation of the arguments.

type ShowTargetType

type ShowTargetType int

ShowTargetType represents the type of object that is requested to be shown by the "tofu show" command.

const (
	// ShowUnknownType is the zero value of [ShowTargetType], and represents
	// that the target type is ambiguous and so must be inferred by the
	// caller based on the [Show.TargetArg] value.
	ShowUnknownType ShowTargetType = iota

	// ShowState represents a request to show the latest state snapshot.
	//
	// This target type does not use [Show.TargetArg].
	ShowState

	// ShowPlan represents a request to show a plan loaded from a saved
	// plan file.
	//
	// For this target type, [Show.TargetArg] is the plan file to load.
	ShowPlan

	// ShowConfig represents a request to show the current configuration.
	//
	// This target type does not use [Show.TargetArg].
	ShowConfig

	// ShowModule represents a request to show just one module in isolation,
	// without requiring any of its dependencies to be installed.
	//
	// For this target type, [Show.TargetArg] is a path to the directory
	// containing the module.
	ShowModule
)

func (ShowTargetType) String

func (i ShowTargetType) String() string

type State

type State struct {
	// Lock controls whether or not the state manager is used to lock state
	// during operations.
	Lock bool

	// LockTimeout allows setting a time limit on acquiring the state lock.
	// The default is 0, meaning no limit.
	LockTimeout time.Duration

	// StatePath specifies a non-default location for the state file. The
	// default value is blank, which is interpreted as "terraform.tfstate".
	// Represents the local path where state is read from.
	StatePath string

	// StateOutPath specifies a different path to write the final state file.
	// The default value is blank, which results in state being written back to
	// StatePath.
	StateOutPath string

	// BackupPath specifies the path where a backup copy of the state file will
	// be stored before the new state is written. The default value is blank,
	// which is interpreted as StateOutPath + ".backup" or, in some cases, the backup
	// is skipped altogether.
	BackupPath string
}

State describes arguments which are used to define how OpenTofu interacts with state.

func BindState added in v0.21.0

func BindState(cli *CommandLine, mask stateFlag) *State

bind is the sole logic of registering the state related flags in OpenTofu.

type StateList

type StateList struct {
	// LookupId restricts output to paths with a resource having the specified ID.
	LookupId string
	// InstancesRawAddr is a list of raw addresses of the resources that are requested
	// to be listed.
	InstancesRawAddr []string

	// View represents the global view options
	View *View

	// Vars and State are the common extended flags
	Vars  *Vars
	State *State
}

StateList represents the command-line arguments for the 'state list' command.

func BindStateList added in v0.21.0

func BindStateList(cli *CommandLine) *StateList

BindStateList registers CLI arguments, returning a StateList value and it's corresponding hooks.

func ParseStateList

func ParseStateList(args []string) (*StateList, func(), tfdiags.Diagnostics)

ParseStateList processes CLI arguments, returning a StateList value, a closer function, and errors. If errors are encountered, a StateList value is still returned representing the best effort interpretation of the arguments.

type StateMv

type StateMv struct {
	// RawSrcAddr represents a resources address that is requested by the user to be moved
	RawSrcAddr string
	// RawDestAddr represents a resources address that is requested by the user to be used to move the
	// resource into
	RawDestAddr string
	// DryRun just validates that the arguments provided are valid and will output the possible outcome.
	// When running in this mode, the state will suffer no change.
	DryRun bool
	// BackupPathOut can be used by the user to configure where to save the backup file of the state file.
	BackupPathOut string

	// View represents the global view options
	View *View

	// Vars, Backend and State are the common extended flags
	Vars    *Vars
	Backend *Backend
	State   *State
}

StateMv represents the command-line arguments for the 'state mv' command.

func BindStateMv added in v0.21.0

func BindStateMv(cli *CommandLine) *StateMv

BindStateMv registers CLI arguments, returning a StateMv value and it's corresponding hooks.

func ParseStateMv

func ParseStateMv(args []string) (*StateMv, func(), tfdiags.Diagnostics)

ParseStateMv processes CLI arguments, returning a StateMv value, a closer function, and errors. If errors are encountered, a StateMv value is still returned representing the best effort interpretation of the arguments.

type StatePull

type StatePull struct {
	// View represents the global view options
	View *View

	// Vars are the common extended flags
	Vars *Vars
}

StatePull represents the command-line arguments for the 'state pull' command.

func BindStatePull added in v0.21.0

func BindStatePull(cli *CommandLine) *StatePull

BindStatePull registers CLI arguments, returning a StatePull value and it's corresponding hooks.

func ParseStatePull

func ParseStatePull(args []string) (*StatePull, func(), tfdiags.Diagnostics)

ParseStatePull processes CLI arguments, returning a StatePull value, a closer function, and errors. If errors are encountered, a StatePull value is still returned representing the best effort interpretation of the arguments.

type StatePush

type StatePush struct {
	// StateSrc represents the source of the state that wants to be pushed.
	// This can be a file name/file path, or it can be "-" when the state should be read from [os.Stdin].
	StateSrc string
	// Force will try to forcefully push the state remotely. This will happen only if the backend supports it.
	Force bool
	// View represents the global view options
	View *View

	// Vars, Backend and State are the common extended flags
	Vars    *Vars
	Backend *Backend
	State   *State
}

StatePush represents the command-line arguments for the 'state push' command.

func BindStatePush added in v0.21.0

func BindStatePush(cli *CommandLine) *StatePush

BindStatePush registers CLI arguments, returning a StatePush value and it's corresponding hooks.

func ParseStatePush

func ParseStatePush(args []string) (*StatePush, func(), tfdiags.Diagnostics)

ParseStatePush processes CLI arguments, returning a StatePush value, a closer function, and errors. If errors are encountered, a StatePush value is still returned representing the best effort interpretation of the arguments.

type StateReplaceProvider

type StateReplaceProvider struct {
	// RawSrcAddr represents a provider address that is requested by the user to be moved
	RawSrcAddr string
	// RawDestAddr represents a provider address that is requested by the user to be used to move the
	// provider into
	RawDestAddr string
	// AutoApprove is an option that the user can configure to skip the confirmation step of the replacement
	// process.
	AutoApprove bool

	// View represents the global view options
	View *View

	// Vars, Backend and State are the common extended flags
	Vars    *Vars
	Backend *Backend
	State   *State
}

StateReplaceProvider represents the command-line arguments for the 'state replace-provider' command.

func BindStateReplaceProvider added in v0.21.0

func BindStateReplaceProvider(cli *CommandLine) *StateReplaceProvider

BindStateReplaceProvider registers CLI arguments, returning a StateReplaceProvider value and it's corresponding hooks.

func ParseReplaceProvider

func ParseReplaceProvider(args []string) (*StateReplaceProvider, func(), tfdiags.Diagnostics)

ParseReplaceProvider processes CLI arguments, returning a StateReplaceProvider value, a closer function, and errors. If errors are encountered, a StateReplaceProvider value is still returned representing the best effort interpretation of the arguments.

type StateRm

type StateRm struct {
	// TargetAddrs represents the raw resource addresses to be removed from the state
	TargetAddrs []string
	// DryRun just validates that the arguments provided are valid and will output the possible outcome.
	// When running in this mode, the state will suffer no change.
	DryRun bool

	// View represents the global view options
	View *View

	// Vars, Backend and State are the common extended flags
	Vars    *Vars
	Backend *Backend
	State   *State
}

StateRm represents the command-line arguments for the 'state rm' command.

func BindStateRm added in v0.21.0

func BindStateRm(cli *CommandLine) *StateRm

BindStateRm registers CLI arguments, returning a StateRm value and it's corresponding hooks.

func ParseStateRm

func ParseStateRm(args []string) (*StateRm, func(), tfdiags.Diagnostics)

ParseStateRm processes CLI arguments, returning a StateRm value, a closer function, and errors. If errors are encountered, a StateRm value is still returned representing the best effort interpretation of the arguments.

type StateShow

type StateShow struct {
	// TargetRawAddr represents the raw resource address of the resource requested to have the state shown for.
	TargetRawAddr string

	// View represents the global view options
	View *View

	// Vars and State are the common extended flags
	Vars  *Vars
	State *State
}

StateShow represents the command-line arguments for the 'state show' command.

func BindStateShow added in v0.21.0

func BindStateShow(cli *CommandLine) *StateShow

BindStateShow registers CLI arguments, returning a StateShow value and it's corresponding hooks.

func ParseStateShow

func ParseStateShow(args []string) (*StateShow, func(), tfdiags.Diagnostics)

ParseStateShow processes CLI arguments, returning a StateShow value, a closer function, and errors. If errors are encountered, a StateShow value is still returned representing the best effort interpretation of the arguments.

type Taint

type Taint struct {
	// TargetAddress is the resource address that is requested to be marked as tainted.
	TargetAddress addrs.AbsResourceInstance
	// AllowMissing can be set to "true" to write a warning instead of an error and to return exit code 0
	// when the TargetAddress points to a missing resource.
	AllowMissing bool

	// View represents the global view options
	View *View

	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars

	// State is used for the state related flags
	State *State
	// Backend is used strictly for the ignore remote version flag
	Backend *Backend
}

Taint represents the command-line arguments for the taint and untaint commands.

func BindTaint added in v0.21.0

func BindTaint(cli *CommandLine, isTaint bool) *Taint

BindTaint registers CLI arguments, returning a Taint value and it's corresponding hooks.

func ParseTaint

func ParseTaint(isTaint bool, args []string) (*Taint, func(), tfdiags.Diagnostics)

ParseTaint processes CLI arguments, returning a Taint value, a closer function, and errors. If errors are encountered, a Taint value is still returned representing the best effort interpretation of the arguments.

type Test

type Test struct {
	// Filter contains a list of test files to execute. If empty, all test files
	// will be executed.
	Filter []string

	// TestDirectory allows the user to override the directory that the test
	// command will use to discover test files, defaults to "tests". Regardless
	// of the value here, test files within the configuration directory will
	// always be discovered.
	TestDirectory string

	// View represents the global view options
	View *View

	// You can specify common variables for all tests from the command line.
	Vars *Vars

	// Verbose tells the test command to print out the plan either in
	// human-readable format or JSON for each run step depending on the
	// ViewType.
	Verbose bool
}

Test represents the command-line arguments for the test command.

func BindTest added in v0.21.0

func BindTest(cli *CommandLine) *Test

BindTest registers CLI arguments, returning a Test value and it's corresponding hooks.

func ParseTest

func ParseTest(args []string) (*Test, func(), tfdiags.Diagnostics)

type Unlock

type Unlock struct {
	// LockID is the ID of the lock that the user has to provide.
	LockID string
	// Force disables the confirmation prompt
	Force bool

	// Vars holds and provides information for the flags related to variables that a user can give into the process
	Vars *Vars
	// View represents the global view options
	View *View
}

Unlock represents the command-line arguments for the unlock command.

func BindUnlock added in v0.21.0

func BindUnlock(cli *CommandLine) *Unlock

BindUnlock registers CLI arguments, returning a Unlock value and it's corresponding hooks.

func ParseUnlock

func ParseUnlock(args []string) (*Unlock, func(), tfdiags.Diagnostics)

ParseUnlock processes CLI arguments, returning a Unlock value, a closer function, and errors. If errors are encountered, a Unlock value is still returned representing the best effort interpretation of the arguments.

type Validate

type Validate struct {
	// Path is the directory containing the configuration to be validated. If
	// unspecified, validate will use the current directory.
	Path string

	// TestDirectory is the directory containing any test files that should be
	// validated alongside the main configuration. Should be relative to the
	// Path.
	TestDirectory string

	// NoTests indicates that OpenTofu should not validate any test files
	// included with the module.
	NoTests bool

	// View represents the global view options
	View *View

	Vars *Vars
}

Validate represents the command-line arguments for the validate command.

func BindValidate added in v0.21.0

func BindValidate(cli *CommandLine) *Validate

BindValidate registers CLI arguments, returning a Validate value and it's corresponding hooks.

func ParseValidate

func ParseValidate(args []string) (*Validate, func(), tfdiags.Diagnostics)

ParseValidate processes CLI arguments, returning a Validate value, a closer function, and errors. If errors are encountered, a Validate value is still returned representing the best effort interpretation of the arguments.

type Vars

type Vars []flags.RawFlag

Vars describes arguments which specify non-default variable values. This interface is unfortunately obscure, because the order of the CLI arguments determines the final value of the gathered variables. In future it might be desirable for the arguments package to handle the gathering of variables directly, returning a map of variable values.

func BindVars added in v0.21.0

func BindVars(cli *CommandLine) *Vars

bind registers all Vars flags

func (Vars) All

func (v Vars) All() Vars

func (Vars) Empty

func (v Vars) Empty() bool

type Version

type Version struct {
	// View represents the global view options
	View *View
}

Version represents the command-line arguments for the version command.

func BindVersion added in v0.21.0

func BindVersion(cli *CommandLine) *Version

BindVersion registers CLI arguments, returning a Version value and it's corresponding hooks.

func ParseVersion

func ParseVersion(args []string) (*Version, func(), tfdiags.Diagnostics)

ParseVersion processes CLI arguments, returning a Version value, a closer function, and errors. If errors are encountered, a Version value is still returned representing the best effort interpretation of the arguments.

type View

type View struct {
	// NoColor is used to disable the use of terminal color codes in all
	// output.
	NoColor bool

	// CompactWarnings is used to coalesce duplicate warnings, to reduce the
	// level of noise when multiple instances of the same warning are raised
	// for a configuration.
	CompactWarnings     bool
	ConsolidateWarnings bool
	ConsolidateErrors   bool

	// LintInclude and LintExclude contains the linting rules that are used later
	// to determine if a specific diagnostic should be shown or not based on the
	// linting rule IDs (or/and groupIDs) that diagnostic is configured with.
	LintInclude, LintExclude collections.Set[linting.RuleAddr]

	// Concise is used to reduce the level of noise in the output and display
	// only the important details.
	Concise bool

	// ModuleDeprecationWarnLvl is used to filter out deprecation warnings for outputs and variables as requested by the user.
	ModuleDeprecationWarnLvl DeprecationWarningLevel

	// ShowSensitive is used to display the value of variables marked as sensitive.
	ShowSensitive bool

	// ViewType specifies which output format to use
	ViewType ViewType

	// InputEnabled is used to disable interactive input for unspecified
	// variable and backend config values. Default is true.
	InputEnabled bool

	// Optional stream to write json data to
	JSONInto *os.File
}

View represents the global command-line arguments which configure the view.

func BindView added in v0.21.0

func BindView(cli *CommandLine, mask viewFlag) *View

type ViewType

type ViewType rune

ViewType represents which view layer to use for a given command. Not all commands will support all view types, and validation that the type is supported should happen in the view constructor.

const (
	ViewNone  ViewType = 0
	ViewHuman ViewType = 'H'
	ViewJSON  ViewType = 'J'
	ViewRaw   ViewType = 'R'
)

func (ViewType) String

func (vt ViewType) String() string

type Workspace

type Workspace struct {
	// View represents the global view options
	View *View
}

func BindWorkspace added in v0.21.0

func BindWorkspace(cli *CommandLine) *Workspace

BindWorkspace registers CLI arguments, returning a Workspace value and it's corresponding hooks.

func ParseWorkspace

func ParseWorkspace(args []string) (*Workspace, func(), tfdiags.Diagnostics)

type WorkspaceDelete

type WorkspaceDelete struct {
	// WorkspaceName represents the name of the workspace that the user wants to be selected.
	WorkspaceName string

	// Force allows the user to forcefully delete a workspace removing the still existing resources
	// from the OpenTofu's management.
	Force bool

	// View represents the global view options
	View *View

	// Vars and State are the common extended flags
	Vars  *Vars
	State *State
}

func BindWorkspaceDelete added in v0.21.0

func BindWorkspaceDelete(cli *CommandLine) *WorkspaceDelete

BindWorkspaceDelete registers CLI arguments, returning a WorkspaceDelete value and it's corresponding hooks.

func ParseWorkspaceDelete

func ParseWorkspaceDelete(args []string) (*WorkspaceDelete, func(), tfdiags.Diagnostics)

type WorkspaceList

type WorkspaceList struct {
	// View represents the global view options
	View *View

	// Vars holds the information that might be needed to be given through `-var`/`-var-file`.
	Vars *Vars
}

func BindWorkspaceList added in v0.21.0

func BindWorkspaceList(cli *CommandLine) *WorkspaceList

BindWorkspaceList registers CLI arguments, returning a WorkspaceList value and it's corresponding hooks.

func ParseWorkspaceList

func ParseWorkspaceList(args []string) (*WorkspaceList, func(), tfdiags.Diagnostics)

type WorkspaceNew

type WorkspaceNew struct {
	// Workspace represents the name of the workspace that the user wants to be selected.
	WorkspaceName string

	// View represents the global view options
	View *View

	// Vars and State are the common extended flags
	Vars  *Vars
	State *State
}

func BindWorkspaceNew added in v0.21.0

func BindWorkspaceNew(cli *CommandLine) *WorkspaceNew

BindWorkspaceNew registers CLI arguments, returning a WorkspaceNew value and it's corresponding hooks.

func ParseWorkspaceNew

func ParseWorkspaceNew(args []string) (*WorkspaceNew, func(), tfdiags.Diagnostics)

type WorkspaceSelect

type WorkspaceSelect struct {
	// Workspace represents the name of the workspace that the user wants to be selected.
	WorkspaceName string
	// CreateIfMissing is a flag that the user can set to "true" to force the creation of the workspace
	// in case it's missing from the current list of workspaces.
	CreateIfMissing bool

	// View represents the global view options
	View *View

	// Vars holds the information that might be needed to be given through `-var`/`-var-file`.
	Vars *Vars
}

func BindWorkspaceSelect added in v0.21.0

func BindWorkspaceSelect(cli *CommandLine) *WorkspaceSelect

BindWorkspaceSelect registers CLI arguments, returning a WorkspaceSelect value and it's corresponding hooks.

func ParseWorkspaceSelect

func ParseWorkspaceSelect(args []string) (*WorkspaceSelect, func(), tfdiags.Diagnostics)

type WorkspaceShow

type WorkspaceShow struct {
	// View represents the global view options
	View *View

	// Vars holds the information that might be needed to be given through `-var`/`-var-file`.
	Vars *Vars
}

func BindWorkspaceShow added in v0.21.0

func BindWorkspaceShow(cli *CommandLine) *WorkspaceShow

BindWorkspaceShow registers CLI arguments, returning a WorkspaceShow value and it's corresponding hooks.

func ParseWorkspaceShow

func ParseWorkspaceShow(args []string) (*WorkspaceShow, func(), tfdiags.Diagnostics)

Jump to

Keyboard shortcuts

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