arguments

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultParallelism = 10

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

Variables

This section is empty.

Functions

func FlagIsSet

func FlagIsSet(flags *flag.FlagSet, name string) bool

FlagIsSet returns whether a flag is explicitly set in a set of flags

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

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

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

	// ViewType specifies which output format to use
	ViewType ViewType

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

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

func ParseApply

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

ParseApply processes CLI arguments, returning an Apply value 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, 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 FlagNameValue

type FlagNameValue struct {
	Name  string
	Value string
}

func (FlagNameValue) String

func (f FlagNameValue) String() string

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

	// 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
	// contains filtered or unexported fields
}

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

func (*Operation) Parse

func (o *Operation) Parse() tfdiags.Diagnostics

Parse must be called on Operation after initial flag parse. This processes the raw target flags into addrs.Targetable values, returning diagnostics if invalid.

type Output

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

	// StatePath is an optional path to a state file, from which outputs will
	// be loaded.
	StatePath string

	// ViewType specifies which output format to use: human, JSON, or "raw".
	ViewType ViewType

	Vars *Vars

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

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

func ParseOutput

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

ParseOutput processes CLI arguments, returning an Output value 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

	// InputEnabled is used to disable interactive input for unspecified
	// variable and backend config values. Default is true.
	InputEnabled 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

	// ViewType specifies which output format to use
	ViewType ViewType

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

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

func ParsePlan

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

ParsePlan processes CLI arguments, returning a Plan value and errors. If errors are encountered, a Plan 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

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

	// ViewType specifies which output format to use
	ViewType ViewType
}

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

func ParseRefresh

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

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

type Show

type Show struct {
	// Path is the path to the state file or plan file to be displayed. If
	// unspecified, show will display the latest state snapshot.
	Path string

	// ViewType specifies which output format to use: human, JSON, or "raw".
	ViewType ViewType

	Vars *Vars

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

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

func ParseShow

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

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

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 interpeted as "terraform.tfstate".
	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".
	BackupPath string
}

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

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

	// ViewType specifies which output format to use: human or JSON.
	ViewType ViewType

	// 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 ParseTest

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

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

	// ViewType specifies which output format to use: human, JSON, or "raw".
	ViewType ViewType

	Vars *Vars
}

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

func ParseValidate

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

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

type Vars

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

Vars describes arguments which specify non-default variable values. This interfce 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 (*Vars) All

func (v *Vars) All() []FlagNameValue

func (*Vars) Empty

func (v *Vars) Empty() bool

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

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

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

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

func ParseView

func ParseView(args []string) (*View, []string)

ParseView processes CLI arguments, returning a View value and a possibly-modified slice of arguments. If any of the supported flags are found, they will be removed from the slice.

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

Jump to

Keyboard shortcuts

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