arguments

package
v1.2.0-alpha-20220328 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultParallelism = 10

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

Variables

This section is empty.

Functions

func FlagIsSet added in v1.1.0

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
}

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 "terraform destroy" command, which is effectively an alias for "terraform 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 Terraform 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 Terraform 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 Terraform 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
}

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

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

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 added in v1.2.0

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
}

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

func ParseShow added in v1.2.0

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 Terraform interacts with state.

type Test

type Test struct {
	Output TestOutput
}

Test represents the command line arguments for the "terraform test" command.

func ParseTest

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

ParseTest interprets a slice of raw command line arguments into a Test value.

type TestOutput

type TestOutput struct {
	// If not an empty string, JUnitXMLFile gives a filename where JUnit-style
	// XML test result output should be written, in addition to the normal
	// output printed to the standard output and error streams.
	// (The typical usage pattern for tools that can consume this file format
	// is to configure them to look for a separate test result file on disk
	// after running the tests.)
	JUnitXMLFile string
}

TestOutput represents a subset of the arguments for "terraform test" related to how it presents its results. That is, it's the arguments that are relevant to the command's view rather than its controller.

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

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

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
}

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