inputvars

package
v0.20.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckInputVariables

func CheckInputVariables(vcs map[string]*modconfig.Variable, vs InputValues) tfdiags.Diagnostics

CheckInputVariables ensures that variable values supplied at the UI conform to their corresponding declarations in configuration.

The set of values is considered valid only if the returned diagnostics does not contain errors. A valid set of values may still produce warnings, which should be returned to the user.

func CollectVariableValues

func CollectVariableValues(workspacePath string, variableFileArgs []string, variablesArgs []string) (map[string]UnparsedVariableValue, error)

CollectVariableValues inspects the various places that configuration input variable values can come from and constructs a map ready to be passed to the backend as part of a Operation.

This method returns diagnostics relating to the collection of the values, but the values themselves may produce additional diagnostics when finally parsed.

Types

type InputValue

type InputValue struct {
	Value      cty.Value
	SourceType ValueSourceType

	// SourceRange provides source location information for values whose
	// SourceType is either ValueFromConfig or ValueFromFile. It is not
	// populated for other source types, and so should not be used.
	SourceRange tfdiags.SourceRange
}

InputValue represents a value for a variable in the configuration, provided as part of the definition of an operation.

func (*InputValue) GoString

func (v *InputValue) GoString() string

func (*InputValue) SourceTypeString

func (v *InputValue) SourceTypeString() string

type InputValues

type InputValues map[string]*InputValue

InputValues is a map of InputValue instances.

func CollectVariableValuesFromModRequire

func CollectVariableValuesFromModRequire(mod *modconfig.Mod, parseCtx *parse.ModParseContext) (InputValues, error)

func ParseVariableValues

func ParseVariableValues(inputValuesUnparsed map[string]UnparsedVariableValue, variablesMap map[string]*modconfig.Variable, depModVarValues InputValues, validate bool) (InputValues, tfdiags.Diagnostics)

ParseVariableValues processes a map of unparsed variable values by correlating each one with the given variable declarations which should be from a configuration.

The map of unparsed variable values should include variables from all possible configuration declarations sources such that it is as complete as it can possibly be for the current operation. If any declared variables are not included in the map, ParseVariableValues will either substitute a configured default value or produce an error.

If this function returns without any errors in the diagnostics, the resulting input values map is guaranteed to be valid and ready to pass to terraform.NewContext. If the diagnostics contains errors, the returned InputValues may be incomplete but will include the subset of variables that were successfully processed, allowing for careful analysis of the partial result.

func (InputValues) DefaultTo

func (vv InputValues) DefaultTo(other InputValues)

func (InputValues) HasValues

func (vv InputValues) HasValues(vals map[string]cty.Value) bool

HasValues returns true if the reciever has the same values as in the given map, disregarding the source types and source ranges.

Values are compared using the cty "RawEquals" method, which means that unknown values can be considered equal to one another if they are of the same type.

func (InputValues) Identical

func (vv InputValues) Identical(other InputValues) bool

Identical returns true if the given InputValues has the same values, source types, and source ranges as the receiver.

Values are compared using the cty "RawEquals" method, which means that unknown values can be considered equal to one another if they are of the same type.

This method is primarily for testing. For most practical purposes, it's better to use SameValues or HasValues.

func (InputValues) JustValues

func (vv InputValues) JustValues() map[string]cty.Value

JustValues returns a map that just includes the values, discarding the source information.

func (InputValues) Override

func (vv InputValues) Override(others ...InputValues) InputValues

Override merges the given value maps with the receiver, overriding any conflicting keys so that the latest definition wins.

func (InputValues) SameValues

func (vv InputValues) SameValues(other InputValues) bool

SameValues returns true if the given InputValues has the same values as the receiever, disregarding the source types and source ranges.

Values are compared using the cty "RawEquals" method, which means that unknown values can be considered equal to one another if they are of the same type.

type UIInput

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

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

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

func (*UIInput) Input

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

type UnparsedInteractiveVariableValue

type UnparsedInteractiveVariableValue struct {
	Name, RawValue string
}

func (UnparsedInteractiveVariableValue) ParseVariableValue

type UnparsedVariableValue

type UnparsedVariableValue interface {
	// ParseVariableValue information in the provided variable configuration
	// to parse (if necessary) and return the variable value encapsulated in
	// the receiver.
	//
	// If error diagnostics are returned, the resulting value may be invalid
	// or incomplete.
	ParseVariableValue(mode var_config.VariableParsingMode) (*InputValue, tfdiags.Diagnostics)
}

UnparsedVariableValue represents a variable value provided by the caller whose parsing must be deferred until configuration is available.

This exists to allow processing of variable-setting arguments (e.g. in the command package) to be separated from parsing (in the backend package).

type ValueSourceType

type ValueSourceType rune

ValueSourceType describes what broad category of source location provided a particular value.

const (
	// ValueFromUnknown is the zero value of ValueSourceType and is not valid.
	ValueFromUnknown ValueSourceType = 0

	// ValueFromConfig indicates that a value came from a .tf or .tf.json file,
	// e.g. the default value defined for a variable.
	ValueFromConfig ValueSourceType = 'C'

	// ValueFromAutoFile indicates that a value came from a "values file", like
	// a .tfvars file, that was implicitly loaded by naming convention.
	ValueFromAutoFile ValueSourceType = 'F'

	// ValueFromNamedFile indicates that a value came from a named "values file",
	// like a .tfvars file, that was passed explicitly on the command line (e.g.
	// -var-file=foo.tfvars).
	ValueFromNamedFile ValueSourceType = 'N'

	// ValueFromCLIArg indicates that the value was provided directly in
	// a CLI argument. The name of this argument is not recorded and so it must
	// be inferred from context.
	ValueFromCLIArg ValueSourceType = 'A'

	// ValueFromEnvVar indicates that the value was provided via an environment
	// variable. The name of the variable is not recorded and so it must be
	// inferred from context.
	ValueFromEnvVar ValueSourceType = 'E'

	// ValueFromInput indicates that the value was provided at an interactive
	// input prompt.
	ValueFromInput ValueSourceType = 'I'

	// ValueFromModFile indicates that the value was provided in the 'Require' section of a mod file
	ValueFromModFile ValueSourceType = 'M'
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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