{"modulePath":"github.com/we-dcode/opentofu","version":"v0.0.0-20250105000325-19243c9e4ceb","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package command\n\n## Constants\n\n```go\nconst (\n\t// DefaultCloudPluginVersion is the implied protocol version, though all\n\t// historical versions are defined explicitly.\n\tDefaultCloudPluginVersion = 1\n\n\t// ExitRPCError is the exit code that is returned if an plugin\n\t// communication error occurred.\n\tExitRPCError = 99\n)\n```\n\n```go\nconst DefaultBackupExtension = \".backup\"\n```\nDefaultBackupExtension is added to the state file to form the path\n\n```go\nconst DefaultDataDir = \".terraform\"\n```\nDefaultDataDir is the default directory for storing local data.\n\n```go\nconst DefaultParallelism = 10\n```\nDefaultParallelism is the limit Terraform places on total parallel operations as it walks the dependency graph.\n\n```go\nconst DefaultPluginVendorDir = \"terraform.d/plugins/\" + pluginMachineName\n```\nDefaultPluginVendorDir 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.\n\n```go\nconst DefaultStateFilename = \"terraform.tfstate\"\n```\nDefaultStateFilename is the default filename used for the state file.\n\n```go\nconst DefaultVarsExtension = \".tfvars\"\n```\nDefaultVarsExtension is the default file extension used for vars\n\n```go\nconst DefaultVarsFilename = \"terraform\" + DefaultVarsExtension\n```\nDefaultVarsFilename is the default filename used for vars\n\n```go\nconst ErrUnsupportedLocalOp = `The configured backend doesn't support this operation.\n\nThe \"backend\" in OpenTofu defines how OpenTofu operates. The default\nbackend performs all operations locally on your machine. Your configuration\nis configured to use a non-local backend. This backend doesn't support this\noperation.\n`\n```\nErrUnsupportedLocalOp is the common error message shown for operations that require a backend.Local.\n\n```go\nconst (\n\t// InputModeEnvVar is the environment variable that, if set to \"false\" or\n\t// \"0\", causes tofu commands to behave as if the `-input=false` flag was\n\t// specified.\n\tInputModeEnvVar = \"TF_INPUT\"\n)\n```\n\n```go\nconst (\n\tMainStateIdentifier = \"\"\n)\n```\n\n```go\nconst PluginPathFile = \"plugin_path\"\n```\nPluginPathFile 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.\n\n```go\nconst VarEnvPrefix = \"TF_VAR_\"\n```\nVarEnvPrefix is the prefix for environment variables that represent values for root module input variables.\n\n```go\nconst WorkspaceNameEnvVar = \"TF_WORKSPACE\"\n```\nWorkspaceNameEnvVar 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\\`.\n\nNote that this environment variable is ignored by \\`tofu workspace new\\` and \\`tofu workspace delete\\`.\n\n## Variables\n\n```go\nvar (\n\t// Handshake is used to verify that the plugin is the appropriate plugin for\n\t// the client. This is not a security verification.\n\tHandshake = plugin.HandshakeConfig{\n\t\tMagicCookieKey:   \"TF_CLOUDPLUGIN_MAGIC_COOKIE\",\n\t\tMagicCookieValue: \"721fca41431b780ff3ad2623838faaa178d74c65e1cfdfe19537c31656496bf9f82d6c6707f71d81c8eed0db9043f79e56ab4582d013bc08ead14f57961461dc\",\n\t\tProtocolVersion:  DefaultCloudPluginVersion,\n\t}\n)\n```\n\n## Types\n\n```go\ntype AliasCommand struct {\n\tcli.Command\n}\n```\nAliasCommand is a Command implementation that wraps another Command for the purpose of aliasing.\n\n```go\nfunc (c *AliasCommand) Help() string\n```\n\n```go\nfunc (c *AliasCommand) Run(args []string) int\n```\n\n```go\nfunc (c *AliasCommand) Synopsis() string\n```\n\n```go\ntype ApplyCommand struct {\n\tMeta\n\n\t// If true, then this apply command will become the \"destroy\"\n\t// command. It is just like apply but only processes a destroy.\n\tDestroy bool\n}\n```\nApplyCommand is a Command implementation that applies a OpenTofu configuration and actually builds or changes infrastructure.\n\n```go\nfunc (c *ApplyCommand) GatherVariables(args *arguments.Vars)\n```\n\n```go\nfunc (c *ApplyCommand) Help() string\n```\n\n```go\nfunc (c *ApplyCommand) LoadPlanFile(path string, enc encryption.Encryption) (*planfile.WrappedPlanFile, tfdiags.Diagnostics)\n```\n\n```go\nfunc (c *ApplyCommand) OperationRequest(\n\tbe backend.Enhanced,\n\tview views.Apply,\n\tviewType arguments.ViewType,\n\tplanFile *planfile.WrappedPlanFile,\n\targs *arguments.Operation,\n\tautoApprove bool,\n\tenc encryption.Encryption,\n) (*backend.Operation, tfdiags.Diagnostics)\n```\n\n```go\nfunc (c *ApplyCommand) PrepareBackend(planFile *planfile.WrappedPlanFile, args *arguments.State, viewType arguments.ViewType, enc encryption.StateEncryption) (backend.Enhanced, tfdiags.Diagnostics)\n```\n\n```go\nfunc (c *ApplyCommand) Run(rawArgs []string) int\n```\n\n```go\nfunc (c *ApplyCommand) Synopsis() string\n```\n\n```go\ntype BackendOpts struct {\n\t// Config is a representation of the backend configuration block given in\n\t// the root module, or nil if no such block is present.\n\tConfig *configs.Backend\n\n\t// ConfigOverride is an hcl.Body that, if non-nil, will be used with\n\t// configs.MergeBodies to override the type-specific backend configuration\n\t// arguments in Config.\n\tConfigOverride hcl.Body\n\n\t// Init should be set to true if initialization is allowed. If this is\n\t// false, then any configuration that requires configuration will show\n\t// an error asking the user to reinitialize.\n\tInit bool\n\n\t// ForceLocal will force a purely local backend, including state.\n\t// You probably don't want to set this.\n\tForceLocal bool\n\n\t// ViewType will set console output format for the\n\t// initialization operation (JSON or human-readable).\n\tViewType arguments.ViewType\n}\n```\nBackendOpts are the options used to initialize a backend.Backend.\n\n```go\ntype BackendWithRemoteTerraformVersion interface {\n\tIgnoreVersionConflict()\n\tVerifyWorkspaceTerraformVersion(workspace string) tfdiags.Diagnostics\n\tIsLocalOperations() bool\n}\n```\nBackendWithRemoteTerraformVersion is a shared interface between the 'remote' and 'cloud' backends for simplified type checking when calling functions common to those particular backends.\n\n```go\ntype CloudCommand struct {\n\tMeta\n}\n```\nCloudCommand is a Command implementation that interacts with Terraform Cloud for operations that are inherently planless. It delegates all execution to an internal plugin.\n\n```go\nfunc (c *CloudCommand) Help() string\n```\nHelp returns help text for the cloud command.\n\n```go\nfunc (c *CloudCommand) Run(args []string) int\n```\nRun runs the cloud command with the given arguments.\n\n```go\nfunc (c *CloudCommand) Synopsis() string\n```\nSynopsis returns a short summary of the cloud command.\n\n```go\ntype ColorizeUi struct {\n\tColorize    *colorstring.Colorize\n\tOutputColor string\n\tInfoColor   string\n\tErrorColor  string\n\tWarnColor   string\n\tUi          cli.Ui\n}\n```\nColorizeUi is a Ui implementation that colors its output according to the given color schemes for the given type of output.\n\n```go\nfunc (u *ColorizeUi) Ask(query string) (string, error)\n```\n\n```go\nfunc (u *ColorizeUi) AskSecret(query string) (string, error)\n```\n\n```go\nfunc (u *ColorizeUi) Error(message string)\n```\n\n```go\nfunc (u *ColorizeUi) Info(message string)\n```\n\n```go\nfunc (u *ColorizeUi) Output(message string)\n```\n\n```go\nfunc (u *ColorizeUi) Warn(message string)\n```\n\n```go\ntype ConsoleCommand struct {\n\tMeta\n}\n```\nConsoleCommand is a Command implementation that starts an interactive console that can be used to try expressions with the current config.\n\n```go\nfunc (c *ConsoleCommand) Help() string\n```\n\n```go\nfunc (c *ConsoleCommand) Run(args []string) int\n```\n\n```go\nfunc (c *ConsoleCommand) Synopsis() string\n```\n\n```go\ntype FlagStringKV map[string]string\n```\nFlagStringKV is a flag.Value implementation for parsing user variables from the command-line in the format of '-var key=value', where value is only ever a primitive.\n\n```go\nfunc (v *FlagStringKV) Set(raw string) error\n```\n\n```go\nfunc (v *FlagStringKV) String() string\n```\n\n```go\ntype FlagStringSlice []string\n```\nFlagStringSlice is a flag.Value implementation for parsing targets from the command line, e.g. -target=aws\\_instance.foo -target=aws\\_vpc.bar\n\n```go\nfunc (v *FlagStringSlice) Set(raw string) error\n```\n\n```go\nfunc (v *FlagStringSlice) String() string\n```\n\n```go\ntype FmtCommand struct {\n\tMeta\n\t// contains filtered or unexported fields\n}\n```\nFmtCommand is a Command implementation that rewrites OpenTofu config files to a canonical format and style.\n\n```go\nfunc (c *FmtCommand) Help() string\n```\n\n```go\nfunc (c *FmtCommand) Run(args []string) int\n```\n\n```go\nfunc (c *FmtCommand) Synopsis() string\n```\n\n```go\ntype GetCommand struct {\n\tMeta\n}\n```\nGetCommand is a Command implementation that takes a OpenTofu configuration and downloads all the modules.\n\n```go\nfunc (c *GetCommand) Help() string\n```\n\n```go\nfunc (c *GetCommand) Run(args []string) int\n```\n\n```go\nfunc (c *GetCommand) Synopsis() string\n```\n\n```go\ntype GraphCommand struct {\n\tMeta\n}\n```\nGraphCommand is a Command implementation that takes a OpenTofu configuration and outputs the dependency tree in graphical form.\n\n```go\nfunc (c *GraphCommand) Help() string\n```\n\n```go\nfunc (c *GraphCommand) Run(args []string) int\n```\n\n```go\nfunc (c *GraphCommand) Synopsis() string\n```\n\n```go\ntype ImportCommand struct {\n\tMeta\n}\n```\nImportCommand is a cli.Command implementation that imports resources into the OpenTofu state.\n\n```go\nfunc (c *ImportCommand) Help() string\n```\n\n```go\nfunc (c *ImportCommand) Run(args []string) int\n```\n\n```go\nfunc (c *ImportCommand) Synopsis() string\n```\n\n```go\ntype InitCommand struct {\n\tMeta\n}\n```\nInitCommand is a Command implementation that takes a Terraform module and clones it to the working directory.\n\n```go\nfunc (c *InitCommand) AutocompleteArgs() complete.Predictor\n```\n\n```go\nfunc (c *InitCommand) AutocompleteFlags() complete.Flags\n```\n\n```go\nfunc (c *InitCommand) Help() string\n```\n\n```go\nfunc (c *InitCommand) Run(args []string) int\n```\n\n```go\nfunc (c *InitCommand) Synopsis() string\n```\n\n```go\ntype LoginCommand struct {\n\tMeta\n}\n```\nLoginCommand 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.\n\n```go\nfunc (c *LoginCommand) Help() string\n```\nHelp implements cli.Command.\n\n```go\nfunc (c *LoginCommand) Run(args []string) int\n```\nRun implements cli.Command.\n\n```go\nfunc (c *LoginCommand) Synopsis() string\n```\nSynopsis implements cli.Command.\n\n```go\ntype LogoutCommand struct {\n\tMeta\n}\n```\nLogoutCommand is a Command implementation which removes stored credentials for a remote service host.\n\n```go\nfunc (c *LogoutCommand) Help() string\n```\nHelp implements cli.Command.\n\n```go\nfunc (c *LogoutCommand) Run(args []string) int\n```\nRun implements cli.Command.\n\n```go\nfunc (c *LogoutCommand) Synopsis() string\n```\nSynopsis implements cli.Command.\n\n```go\ntype Meta struct {\n\n\t// WorkingDir is an object representing the \"working directory\" where we're\n\t// running commands. In the normal case this literally refers to the\n\t// working directory of the OpenTofu process, though this can take on\n\t// a more symbolic meaning when the user has overridden default behavior\n\t// to specify a different working directory or to override the special\n\t// data directory where we'll persist settings that must survive between\n\t// consecutive commands.\n\t//\n\t// We're currently gradually migrating the various bits of state that\n\t// must persist between consecutive commands in a session to be encapsulated\n\t// in here, but we're not there yet and so there are also some methods on\n\t// Meta which directly read and modify paths inside the data directory.\n\tWorkingDir *workdir.Dir\n\n\t// Streams tracks the raw Stdout, Stderr, and Stdin handles along with\n\t// some basic metadata about them, such as whether each is connected to\n\t// a terminal, how wide the possible terminal is, etc.\n\t//\n\t// For historical reasons this might not be set in unit test code, and\n\t// so functions working with this field must check if it's nil and\n\t// do some default behavior instead if so, rather than panicking.\n\tStreams *terminal.Streams\n\n\tView *views.View\n\n\tColor            bool     // True if output should be colored\n\tGlobalPluginDirs []string // Additional paths to search for plugins\n\tUi               cli.Ui   // Ui for output\n\n\t// Services provides access to remote endpoint information for\n\t// 'tofu-native' services running at a specific user-facing hostname.\n\tServices *disco.Disco\n\n\t// RunningInAutomation indicates that commands are being run by an\n\t// automated system rather than directly at a command prompt.\n\t//\n\t// This is a hint to various command routines that it may be confusing\n\t// to print out messages that suggest running specific follow-up\n\t// commands, since the user consuming the output will not be\n\t// in a position to run such commands.\n\t//\n\t// The intended use-case of this flag is when OpenTofu is running in\n\t// some sort of workflow orchestration tool which is abstracting away\n\t// the specific commands being run.\n\tRunningInAutomation bool\n\n\t// CLIConfigDir is the directory from which CLI configuration files were\n\t// read by the caller and the directory where any changes to CLI\n\t// configuration files by commands should be made.\n\t//\n\t// If this is empty then no configuration directory is available and\n\t// commands which require one cannot proceed.\n\tCLIConfigDir string\n\n\t// PluginCacheDir, if non-empty, enables caching of downloaded plugins\n\t// into the given directory.\n\tPluginCacheDir string\n\n\t// PluginCacheMayBreakDependencyLockFile is a temporary CLI configuration-based\n\t// opt out for the behavior of only using the plugin cache dir if its\n\t// contents match checksums recorded in the dependency lock file.\n\t//\n\t// This is an accommodation for those who currently essentially ignore the\n\t// dependency lock file -- treating it only as transient working directory\n\t// state -- and therefore don't care if the plugin cache dir causes the\n\t// checksums inside to only be sufficient for the computer where OpenTofu\n\t// is currently running.\n\t//\n\t// We intend to remove this exception again (making the CLI configuration\n\t// setting a silent no-op) in future once we've improved the dependency\n\t// lock file mechanism so that it's usable for everyone and there are no\n\t// longer any compelling reasons for folks to not lock their dependencies.\n\tPluginCacheMayBreakDependencyLockFile bool\n\n\t// ProviderSource allows determining the available versions of a provider\n\t// and determines where a distribution package for a particular\n\t// provider version can be obtained.\n\tProviderSource getproviders.Source\n\n\t// BrowserLauncher is used by commands that need to open a URL in a\n\t// web browser.\n\tBrowserLauncher webbrowser.Launcher\n\n\t// A context.Context provided by the caller -- typically \"package main\" --\n\t// which might be carrying telemetry-related metadata and so should be\n\t// used when creating downstream traces, etc.\n\t//\n\t// This isn't guaranteed to be set, so use [Meta.CommandContext] to\n\t// safely create a context for the entire execution of a command, which\n\t// will be connected to this parent context if it's present.\n\tCallerContext context.Context\n\n\t// When this channel is closed, the command will be cancelled.\n\tShutdownCh \u003c-chan struct{}\n\n\t// ProviderDevOverrides are providers where we ignore the lock file, the\n\t// configured version constraints, and the local cache directory and just\n\t// always use exactly the path specified. This is intended to allow\n\t// provider developers to easily test local builds without worrying about\n\t// what version number they might eventually be released as, or what\n\t// checksums they have.\n\tProviderDevOverrides map[addrs.Provider]getproviders.PackageLocalDir\n\n\t// UnmanagedProviders are a set of providers that exist as processes\n\t// predating OpenTofu, which OpenTofu should use but not worry about the\n\t// lifecycle of.\n\t//\n\t// This is essentially a more extreme version of ProviderDevOverrides where\n\t// OpenTofu doesn't even worry about how the provider server gets launched,\n\t// just trusting that someone else did it before running OpenTofu.\n\tUnmanagedProviders map[addrs.Provider]*plugin.ReattachConfig\n\n\t// AllowExperimentalFeatures controls whether a command that embeds this\n\t// Meta is permitted to make use of experimental OpenTofu features.\n\t//\n\t// Set this field only during the initial creation of Meta. If you change\n\t// this field after calling methods of type Meta then the resulting\n\t// behavior is undefined.\n\t//\n\t// In normal code this would be set by package main only in builds\n\t// explicitly marked as being alpha releases or development snapshots,\n\t// making experimental features unavailable otherwise. Test code may\n\t// choose to set this if it needs to exercise experimental features.\n\t//\n\t// Some experiments predated the addition of this setting, and may\n\t// therefore still be available even if this flag is false. Our intent\n\t// is that all/most _future_ experiments will be unavailable unless this\n\t// flag is set, to reinforce that experiments are not for production use.\n\tAllowExperimentalFeatures bool\n\t// contains filtered or unexported fields\n}\n```\nMeta are the meta-options that are available on all or most commands.\n\n```go\nfunc (m *Meta) Backend(opts *BackendOpts, enc encryption.StateEncryption) (backend.Enhanced, tfdiags.Diagnostics)\n```\nBackend initializes and returns the backend for this CLI session.\n\nThe 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.\n\nThis will initialize a new backend for each call, which can carry some overhead with it. Please reuse the returned value for optimal behavior.\n\nOnly 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.\n\nA 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.\n\n```go\nfunc (m *Meta) BackendForLocalPlan(settings plans.Backend, enc encryption.StateEncryption) (backend.Enhanced, tfdiags.Diagnostics)\n```\nBackendForLocalPlan is similar to Backend, but uses backend settings that were stored in a plan.\n\nThe 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.\n\n```go\nfunc (m *Meta) Colorize() *colorstring.Colorize\n```\nColorize returns the colorization structure for a command.\n\n```go\nfunc (m *Meta) CommandContext() context.Context\n```\nCommandContext returns the \"root context\" to use in the main Run function of a command.\n\nThis 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.\n\nIf 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.\n\n```go\nfunc (m *Meta) DataDir() string\n```\nDataDir returns the directory where local data will be stored. Defaults to DefaultDataDir in the current working directory.\n\n```go\nfunc (m *Meta) Encryption() (encryption.Encryption, tfdiags.Diagnostics)\n```\n\n```go\nfunc (m *Meta) EncryptionFromModule(module *configs.Module) (encryption.Encryption, tfdiags.Diagnostics)\n```\n\n```go\nfunc (m *Meta) EncryptionFromPath(path string) (encryption.Encryption, tfdiags.Diagnostics)\n```\n\n```go\nfunc (m *Meta) ErrorColumns() int\n```\nErrorColumns returns the number of columns that error UI output should be wrapped to fill.\n\nThis is the column count to use if you'll be printing your message via the Error or Warn methods of m.Ui.\n\n```go\nfunc (m *Meta) Input() bool\n```\nInput returns whether or not input asking is enabled.\n\n```go\nfunc (m *Meta) InputMode() tofu.InputMode\n```\nInputMode returns the type of input we should ask for in the form of tofu.InputMode which is passed directly to Context.Input.\n\n```go\nfunc (m *Meta) InterruptibleContext(base context.Context) (context.Context, context.CancelFunc)\n```\nInterruptibleContext returns a context.Context that will be cancelled if the process is interrupted by a platform-specific interrupt signal.\n\nThe typical way to use this is to pass the result of [Meta.CommandContext](#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:\n\nAs 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.\n\n\t// This example is only for when using this function very early in\n\t// the \"Run\" method of a Command implementation. If you already have\n\t// an active context, pass that in as base instead.\n\tctx, done := c.InterruptibleContext(c.CommandContext())\n\tdefer done()\n\n```go\nfunc (c *Meta) MaybeGetSchemas(state *states.State, config *configs.Config) (*tofu.Schemas, tfdiags.Diagnostics)\n```\nMaybeGetSchemas 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\n\n```go\nfunc (m *Meta) Operation(b backend.Backend, vt arguments.ViewType, enc encryption.Encryption) *backend.Operation\n```\nOperation initializes a new backend.Operation struct.\n\nThis 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.\n\n```go\nfunc (m *Meta) OutputColumns() int\n```\nOutputColumns returns the number of columns that normal (non-error) UI output should be wrapped to fill.\n\nThis is the column count to use if you'll be printing your message via the Output or Info methods of m.Ui.\n\n```go\nfunc (m *Meta) PlanFile(path string, enc encryption.PlanEncryption) (*planfile.WrappedPlanFile, error)\n```\nPlanFile loads the plan file at the given path, which might be either a local or cloud plan.\n\nIf the return value and error are both nil, the given path exists but seems to be a configuration directory instead.\n\nError will be non-nil if path refers to something which looks like a plan file and loading the file fails.\n\n```go\nfunc (m *Meta) RunOperation(ctx context.Context, b backend.Enhanced, opReq *backend.Operation) (*backend.RunningOperation, tfdiags.Diagnostics)\n```\nRunOperation 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.\n\nAn 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.\n\n```go\nfunc (m *Meta) SetWorkspace(name string) error\n```\nSetWorkspace saves the given name as the current workspace in the local filesystem.\n\n```go\nfunc (m *Meta) StateOutPath() string\n```\nStateOutPath returns the true output path for the state file\n\n```go\nfunc (m *Meta) StdinPiped() bool\n```\nStdinPiped returns true if the input is piped.\n\n```go\nfunc (m *Meta) UIInput() tofu.UIInput\n```\nUIInput returns a UIInput object to be used for asking for input.\n\n```go\nfunc (m *Meta) Workspace() (string, error)\n```\nWorkspace returns the name of the currently configured workspace, corresponding to the desired named state.\n\n```go\nfunc (m *Meta) WorkspaceOverridden() (string, bool)\n```\nWorkspaceOverridden 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.\n\n```go\ntype MetadataCommand struct {\n\tMeta\n}\n```\nMetadataCommand is a Command implementation that just shows help for the subcommands nested below it.\n\n```go\nfunc (c *MetadataCommand) Help() string\n```\n\n```go\nfunc (c *MetadataCommand) Run(args []string) int\n```\n\n```go\nfunc (c *MetadataCommand) Synopsis() string\n```\n\n```go\ntype MetadataFunctionsCommand struct {\n\tMeta\n}\n```\nMetadataFunctionsCommand is a Command implementation that prints out information about the available functions in OpenTofu.\n\n```go\nfunc (c *MetadataFunctionsCommand) Help() string\n```\n\n```go\nfunc (c *MetadataFunctionsCommand) Run(args []string) int\n```\n\n```go\nfunc (c *MetadataFunctionsCommand) Synopsis() string\n```\n\n```go\ntype OutputCommand struct {\n\tMeta\n}\n```\nOutputCommand is a Command implementation that reads an output from a OpenTofu state and prints it.\n\n```go\nfunc (c *OutputCommand) GatherVariables(args *arguments.Vars)\n```\n\n```go\nfunc (c *OutputCommand) Help() string\n```\n\n```go\nfunc (c *OutputCommand) Outputs(statePath string, enc encryption.Encryption) (map[string]*states.OutputValue, tfdiags.Diagnostics)\n```\n\n```go\nfunc (c *OutputCommand) Run(rawArgs []string) int\n```\n\n```go\nfunc (c *OutputCommand) Synopsis() string\n```\n\n```go\ntype PlanCommand struct {\n\tMeta\n}\n```\nPlanCommand is a Command implementation that compares a OpenTofu configuration to an actual infrastructure and shows the differences.\n\n```go\nfunc (c *PlanCommand) GatherVariables(args *arguments.Vars)\n```\n\n```go\nfunc (c *PlanCommand) Help() string\n```\n\n```go\nfunc (c *PlanCommand) OperationRequest(\n\tbe backend.Enhanced,\n\tview views.Plan,\n\tviewType arguments.ViewType,\n\targs *arguments.Operation,\n\tplanOutPath string,\n\tgenerateConfigOut string,\n\tenc encryption.Encryption,\n) (*backend.Operation, tfdiags.Diagnostics)\n```\n\n```go\nfunc (c *PlanCommand) PrepareBackend(args *arguments.State, viewType arguments.ViewType, enc encryption.Encryption) (backend.Enhanced, tfdiags.Diagnostics)\n```\n\n```go\nfunc (c *PlanCommand) Run(rawArgs []string) int\n```\n\n```go\nfunc (c *PlanCommand) Synopsis() string\n```\n\n```go\ntype ProvidersCommand struct {\n\tMeta\n}\n```\nProvidersCommand is a Command implementation that prints out information about the providers used in the current configuration/state.\n\n```go\nfunc (c *ProvidersCommand) Help() string\n```\n\n```go\nfunc (c *ProvidersCommand) Run(args []string) int\n```\n\n```go\nfunc (c *ProvidersCommand) Synopsis() string\n```\n\n```go\ntype ProvidersLockCommand struct {\n\tMeta\n}\n```\nProvidersLockCommand 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.\n\n```go\nfunc (c *ProvidersLockCommand) Help() string\n```\n\n```go\nfunc (c *ProvidersLockCommand) Run(args []string) int\n```\n\n```go\nfunc (c *ProvidersLockCommand) Synopsis() string\n```\n\n```go\ntype ProvidersMirrorCommand struct {\n\tMeta\n}\n```\nProvidersMirrorCommand 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.\n\n```go\nfunc (c *ProvidersMirrorCommand) Help() string\n```\n\n```go\nfunc (c *ProvidersMirrorCommand) Run(args []string) int\n```\n\n```go\nfunc (c *ProvidersMirrorCommand) Synopsis() string\n```\n\n```go\ntype ProvidersSchemaCommand struct {\n\tMeta\n}\n```\nProvidersSchemaCommand is a Command implementation that prints out information about the providers used in the current configuration/state.\n\n```go\nfunc (c *ProvidersSchemaCommand) Help() string\n```\n\n```go\nfunc (c *ProvidersSchemaCommand) Run(args []string) int\n```\n\n```go\nfunc (c *ProvidersSchemaCommand) Synopsis() string\n```\n\n```go\ntype PushCommand struct {\n\tMeta\n}\n```\n\n```go\nfunc (c *PushCommand) Help() string\n```\n\n```go\nfunc (c *PushCommand) Run(args []string) int\n```\n\n```go\nfunc (c *PushCommand) Synopsis() string\n```\n\n```go\ntype RefreshCommand struct {\n\tMeta\n}\n```\nRefreshCommand is a cli.Command implementation that refreshes the state file.\n\n```go\nfunc (c *RefreshCommand) GatherVariables(args *arguments.Vars)\n```\n\n```go\nfunc (c *RefreshCommand) Help() string\n```\n\n```go\nfunc (c *RefreshCommand) OperationRequest(be backend.Enhanced, view views.Refresh, viewType arguments.ViewType, args *arguments.Operation, enc encryption.Encryption,\n) (*backend.Operation, tfdiags.Diagnostics)\n```\n\n```go\nfunc (c *RefreshCommand) PrepareBackend(args *arguments.State, viewType arguments.ViewType, enc encryption.Encryption) (backend.Enhanced, tfdiags.Diagnostics)\n```\n\n```go\nfunc (c *RefreshCommand) Run(rawArgs []string) int\n```\n\n```go\nfunc (c *RefreshCommand) Synopsis() string\n```\n\n```go\ntype ShowCommand struct {\n\tMeta\n\t// contains filtered or unexported fields\n}\n```\nShowCommand is a Command implementation that reads and outputs the contents of a OpenTofu plan or state file.\n\n```go\nfunc (c *ShowCommand) GatherVariables(args *arguments.Vars)\n```\n\n```go\nfunc (c *ShowCommand) Help() string\n```\n\n```go\nfunc (c *ShowCommand) Run(rawArgs []string) int\n```\n\n```go\nfunc (c *ShowCommand) Synopsis() string\n```\n\n```go\ntype StateCommand struct {\n\tStateMeta\n}\n```\nStateCommand is a Command implementation that just shows help for the subcommands nested below it.\n\n```go\nfunc (c *StateCommand) Help() string\n```\n\n```go\nfunc (c *StateCommand) Run(args []string) int\n```\n\n```go\nfunc (c *StateCommand) Synopsis() string\n```\n\n```go\ntype StateListCommand struct {\n\tMeta\n\tStateMeta\n}\n```\nStateListCommand is a Command implementation that lists the resources within a state file.\n\n```go\nfunc (c *StateListCommand) Help() string\n```\n\n```go\nfunc (c *StateListCommand) Run(args []string) int\n```\n\n```go\nfunc (c *StateListCommand) Synopsis() string\n```\n\n```go\ntype StateMeta struct {\n\tMeta\n}\n```\nStateMeta is the meta struct that should be embedded in state subcommands.\n\n```go\nfunc (c *StateMeta) State(enc encryption.Encryption) (statemgr.Full, error)\n```\nState 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.\n\n```go\ntype StateMvCommand struct {\n\tStateMeta\n}\n```\nStateMvCommand is a Command implementation that shows a single resource.\n\n```go\nfunc (c *StateMvCommand) Help() string\n```\n\n```go\nfunc (c *StateMvCommand) Run(args []string) int\n```\n\n```go\nfunc (c *StateMvCommand) Synopsis() string\n```\n\n```go\ntype StatePullCommand struct {\n\tMeta\n\tStateMeta\n}\n```\nStatePullCommand is a Command implementation that shows a single resource.\n\n```go\nfunc (c *StatePullCommand) Help() string\n```\n\n```go\nfunc (c *StatePullCommand) Run(args []string) int\n```\n\n```go\nfunc (c *StatePullCommand) Synopsis() string\n```\n\n```go\ntype StatePushCommand struct {\n\tMeta\n\tStateMeta\n}\n```\nStatePushCommand is a Command implementation that shows a single resource.\n\n```go\nfunc (c *StatePushCommand) Help() string\n```\n\n```go\nfunc (c *StatePushCommand) Run(args []string) int\n```\n\n```go\nfunc (c *StatePushCommand) Synopsis() string\n```\n\n```go\ntype StateReplaceProviderCommand struct {\n\tStateMeta\n}\n```\n\n```go\nfunc (c *StateReplaceProviderCommand) Help() string\n```\n\n```go\nfunc (c *StateReplaceProviderCommand) Run(args []string) int\n```\n\n```go\nfunc (c *StateReplaceProviderCommand) Synopsis() string\n```\n\n```go\ntype StateRmCommand struct {\n\tStateMeta\n}\n```\nStateRmCommand is a Command implementation that shows a single resource.\n\n```go\nfunc (c *StateRmCommand) Help() string\n```\n\n```go\nfunc (c *StateRmCommand) Run(args []string) int\n```\n\n```go\nfunc (c *StateRmCommand) Synopsis() string\n```\n\n```go\ntype StateShowCommand struct {\n\tMeta\n\tStateMeta\n}\n```\nStateShowCommand is a Command implementation that shows a single resource.\n\n```go\nfunc (c *StateShowCommand) Help() string\n```\n\n```go\nfunc (c *StateShowCommand) Run(args []string) int\n```\n\n```go\nfunc (c *StateShowCommand) Synopsis() string\n```\n\n```go\ntype TaintCommand struct {\n\tMeta\n}\n```\nTaintCommand is a cli.Command implementation that manually taints a resource, marking it for recreation.\n\n```go\nfunc (c *TaintCommand) Help() string\n```\n\n```go\nfunc (c *TaintCommand) Run(args []string) int\n```\n\n```go\nfunc (c *TaintCommand) Synopsis() string\n```\n\n```go\ntype TestCommand struct {\n\tMeta\n}\n```\n\n```go\nfunc (c *TestCommand) Help() string\n```\n\n```go\nfunc (c *TestCommand) Run(rawArgs []string) int\n```\n\n```go\nfunc (c *TestCommand) Synopsis() string\n```\n\n```go\ntype TestFileRunner struct {\n\tSuite *TestSuiteRunner\n\n\tStates map[string]*TestFileState\n}\n```\n\n```go\nfunc (runner *TestFileRunner) Cleanup(ctx context.Context, file *moduletest.File)\n```\n\n```go\nfunc (runner *TestFileRunner) ExecuteTestFile(ctx context.Context, file *moduletest.File)\n```\n\n```go\nfunc (runner *TestFileRunner) ExecuteTestRun(ctx context.Context, run *moduletest.Run, file *moduletest.File, state *states.State, config *configs.Config) (*states.State, bool)\n```\n\n```go\ntype TestFileState struct {\n\tRun   *moduletest.Run\n\tState *states.State\n}\n```\n\n```go\ntype TestSuiteRunner struct {\n\tSuite  *moduletest.Suite\n\tConfig *configs.Config\n\n\tGlobalVariables map[string]backend.UnparsedVariableValue\n\tOpts            *tofu.ContextOpts\n\n\tView views.Test\n\n\t// Stopped and Cancelled track whether the user requested the testing\n\t// process to be interrupted. Stopped is a nice graceful exit, we'll still\n\t// tidy up any state that was created and mark the tests with relevant\n\t// `skipped` status updates. Cancelled is a hard stop right now exit, we\n\t// won't attempt to clean up any state left hanging, and tests will just\n\t// be left showing `pending` as the status. We will still print out the\n\t// destroy summary diagnostics that tell the user what state has been left\n\t// behind and needs manual clean up.\n\tStopped   bool\n\tCancelled bool\n\n\t// StoppedCtx and CancelledCtx allow in progress OpenTofu operations to\n\t// respond to external calls from the test command.\n\tStoppedCtx   context.Context\n\tCancelledCtx context.Context\n\n\t// Verbose tells the runner to print out plan files during each test run.\n\tVerbose bool\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (runner *TestSuiteRunner) Start(ctx context.Context)\n```\n\n```go\ntype UIInput struct {\n\t// Colorize will color the output.\n\tColorize *colorstring.Colorize\n\n\t// Reader and Writer for IO. If these aren't set, they will default to\n\t// Stdin and Stdout respectively.\n\tReader io.Reader\n\tWriter io.Writer\n\t// contains filtered or unexported fields\n}\n```\nUIInput is an implementation of tofu.UIInput that asks the CLI for input stdin.\n\n```go\nfunc (i *UIInput) Input(ctx context.Context, opts *tofu.InputOpts) (string, error)\n```\n\n```go\ntype UnlockCommand struct {\n\tMeta\n}\n```\nUnlockCommand is a cli.Command implementation that manually unlocks the state.\n\n```go\nfunc (c *UnlockCommand) Help() string\n```\n\n```go\nfunc (c *UnlockCommand) Run(args []string) int\n```\n\n```go\nfunc (c *UnlockCommand) Synopsis() string\n```\n\n```go\ntype UntaintCommand struct {\n\tMeta\n}\n```\nUntaintCommand is a cli.Command implementation that manually untaints a resource, marking it as primary and ready for service.\n\n```go\nfunc (c *UntaintCommand) Help() string\n```\n\n```go\nfunc (c *UntaintCommand) Run(args []string) int\n```\n\n```go\nfunc (c *UntaintCommand) Synopsis() string\n```\n\n```go\ntype ValidateCommand struct {\n\tMeta\n}\n```\nValidateCommand is a Command implementation that validates the tofu files\n\n```go\nfunc (c *ValidateCommand) GatherVariables(args *arguments.Vars)\n```\n\n```go\nfunc (c *ValidateCommand) Help() string\n```\n\n```go\nfunc (c *ValidateCommand) Run(rawArgs []string) int\n```\n\n```go\nfunc (c *ValidateCommand) Synopsis() string\n```\n\n```go\ntype VersionCommand struct {\n\tMeta\n\n\tVersion           string\n\tVersionPrerelease string\n\tPlatform          getproviders.Platform\n}\n```\nVersionCommand is a Command implementation prints the version.\n\n```go\nfunc (c *VersionCommand) Help() string\n```\n\n```go\nfunc (c *VersionCommand) Run(args []string) int\n```\n\n```go\nfunc (c *VersionCommand) Synopsis() string\n```\n\n```go\ntype VersionOutput struct {\n\tVersion            string            `json:\"terraform_version\"`\n\tPlatform           string            `json:\"platform\"`\n\tProviderSelections map[string]string `json:\"provider_selections\"`\n}\n```\n\n```go\ntype WorkspaceCommand struct {\n\tMeta\n\tLegacyName bool\n}\n```\nWorkspaceCommand is a Command Implementation that manipulates workspaces, which allow multiple distinct states and variables from a single config.\n\n```go\nfunc (c *WorkspaceCommand) Help() string\n```\n\n```go\nfunc (c *WorkspaceCommand) Run(args []string) int\n```\n\n```go\nfunc (c *WorkspaceCommand) Synopsis() string\n```\n\n```go\ntype WorkspaceDeleteCommand struct {\n\tMeta\n\tLegacyName bool\n}\n```\n\n```go\nfunc (c *WorkspaceDeleteCommand) AutocompleteArgs() complete.Predictor\n```\n\n```go\nfunc (c *WorkspaceDeleteCommand) AutocompleteFlags() complete.Flags\n```\n\n```go\nfunc (c *WorkspaceDeleteCommand) Help() string\n```\n\n```go\nfunc (c *WorkspaceDeleteCommand) Run(args []string) int\n```\n\n```go\nfunc (c *WorkspaceDeleteCommand) Synopsis() string\n```\n\n```go\ntype WorkspaceListCommand struct {\n\tMeta\n\tLegacyName bool\n}\n```\n\n```go\nfunc (c *WorkspaceListCommand) AutocompleteArgs() complete.Predictor\n```\n\n```go\nfunc (c *WorkspaceListCommand) AutocompleteFlags() complete.Flags\n```\n\n```go\nfunc (c *WorkspaceListCommand) Help() string\n```\n\n```go\nfunc (c *WorkspaceListCommand) Run(args []string) int\n```\n\n```go\nfunc (c *WorkspaceListCommand) Synopsis() string\n```\n\n```go\ntype WorkspaceNewCommand struct {\n\tMeta\n\tLegacyName bool\n}\n```\n\n```go\nfunc (c *WorkspaceNewCommand) AutocompleteArgs() complete.Predictor\n```\n\n```go\nfunc (c *WorkspaceNewCommand) AutocompleteFlags() complete.Flags\n```\n\n```go\nfunc (c *WorkspaceNewCommand) Help() string\n```\n\n```go\nfunc (c *WorkspaceNewCommand) Run(args []string) int\n```\n\n```go\nfunc (c *WorkspaceNewCommand) Synopsis() string\n```\n\n```go\ntype WorkspaceSelectCommand struct {\n\tMeta\n\tLegacyName bool\n}\n```\n\n```go\nfunc (c *WorkspaceSelectCommand) AutocompleteArgs() complete.Predictor\n```\n\n```go\nfunc (c *WorkspaceSelectCommand) AutocompleteFlags() complete.Flags\n```\n\n```go\nfunc (c *WorkspaceSelectCommand) Help() string\n```\n\n```go\nfunc (c *WorkspaceSelectCommand) Run(args []string) int\n```\n\n```go\nfunc (c *WorkspaceSelectCommand) Synopsis() string\n```\n\n```go\ntype WorkspaceShowCommand struct {\n\tMeta\n}\n```\n\n```go\nfunc (c *WorkspaceShowCommand) AutocompleteArgs() complete.Predictor\n```\n\n```go\nfunc (c *WorkspaceShowCommand) AutocompleteFlags() complete.Flags\n```\n\n```go\nfunc (c *WorkspaceShowCommand) Help() string\n```\n\n```go\nfunc (c *WorkspaceShowCommand) Run(args []string) int\n```\n\n```go\nfunc (c *WorkspaceShowCommand) Synopsis() string\n```\n\n```go\ntype WrappedUi struct {\n\t// contains filtered or unexported fields\n}\n```\nWrappedUi is a shim which adds json compatibility to those commands which have not yet been refactored to support output by views.View.\n\nFor those not support json output command, all output is printed by cli.Ui. So we create WrappedUi, contains the old cli.Ui and views.JSONView, implement cli.Ui interface, so that we can make all command support json output in a short time.\n\n```go\nfunc (m *WrappedUi) Ask(s string) (string, error)\n```\n\n```go\nfunc (m *WrappedUi) AskSecret(s string) (string, error)\n```\n\n```go\nfunc (m *WrappedUi) Error(s string)\n```\n\n```go\nfunc (m *WrappedUi) Info(s string)\n```\n\n```go\nfunc (m *WrappedUi) Output(s string)\n```\n\n```go\nfunc (m *WrappedUi) Warn(s string)\n```\n\n","path":"github.com/we-dcode/opentofu/pkg/command","name":"command","synopsis":"","isRedistributable":true}
