// stubUnsetVariables ensures that all required variables defined in the
// configuration exist in the resulting map, by adding new elements as necessary.
//
// The stubbed value of any additions will be an unknown variable conforming
// to the variable's configured type constraint, meaning that no particular
// value is known and that one must be provided by the user in order to get
// a complete result.
//
// Unset optional attributes (those with default values) will not be populated
// by this function, under the assumption that a later step will handle those.
// In this sense, stubUnsetRequiredVariables is essentially a non-interactive,
// non-error-producing variant of interactiveCollectVariables that creates
// placeholders for values the user would be prompted for interactively on
// other operations.
//
// This function should be used only in situations where variables values
// will not be directly used and the variables map is being constructed only
// to produce a complete Terraform context for some ancillary functionality
// like "terraform console", "terraform state ...", etc.
//
// This function is guaranteed not to modify the given map, but it may return
// the given map unchanged if no additions are required. If additions are
// required then the result will be a new map containing everything in the
// given map plus additional elements.
stubUnsetVariables ensures that all required variables defined in the
configuration exist in the resulting map, by adding new elements as necessary.

The stubbed value of any additions will be an unknown variable conforming
to the variable's configured type constraint, meaning that no particular
value is known and that one must be provided by the user in order to get
a complete result.

Unset optional attributes (those with default values) will not be populated
by this function, under the assumption that a later step will handle those.
In this sense, stubUnsetRequiredVariables is essentially a non-interactive,
non-error-producing variant of interactiveCollectVariables that creates
placeholders for values the user would be prompted for interactively on
other operations.

This function should be used only in situations where variables values
will not be directly used and the variables map is being constructed only
to produce a complete Terraform context for some ancillary functionality
like "terraform console", "terraform state ...", etc.

This function is guaranteed not to modify the given map, but it may return
the given map unchanged if no additions are required. If additions are
required then the result will be a new map containing everything in the
given map plus additional elements.
// stubUnsetVariables ensures that all required variables defined in the // configuration exist in the resulting map by adding new elements as necessary . // // The stubbed value of any additions will be an unknown variable conforming // to the variable ' s configured type constraint meaning that no particular // value is known and that one must be provided by the user in order to get // a complete result . // // Unset optional attributes ( those with default values ) will not be populated // by this function under the assumption that a later step will handle those . // In this sense stubUnsetRequiredVariables is essentially a non - interactive // non - error - producing variant of interactiveCollectVariables that creates // placeholders for values the user would be prompted for interactively on // other operations . // // This function should be used only in situations where variables values // will not be directly used and the variables map is being constructed only // to produce a complete Terraform context for some ancillary functionality // like " terraform console " " terraform state ... " etc . // // This function is guaranteed not to modify the given map but it may return // the given map unchanged if no additions are required . If additions are // required then the result will be a new map containing everything in the // given map plus additional elements .
func (b *Local) stubUnsetRequiredVariables(existing map[string]backend.UnparsedVariableValue, vcs map[string]*configs.Variable) map[string]backend.UnparsedVariableValue {
	var missing bool 
	for name, vc := range vcs {
		if !vc.Required() {
			continue 
		}
		if _, exists := existing[name]; !exists {
			missing = true
		}
	}
	if !missing {
		return existing
	}
	ret := make(map[string]backend.UnparsedVariableValue, len(vcs))
	for k, v := range existing {
		ret[k] = v
	}
	for name, vc := range vcs {
		if !vc.Required() {
			continue
		}
		if _, exists := existing[name]; !exists {
			ret[name] = unparsedUnknownVariableValue{Name: name, WantType: vc.Type}
		}
	}
	return ret
}
func ( b * Local ) stubUnsetRequiredVariables ( existing map [ string ] backend . UnparsedVariableValue , vcs map [ string ] * configs . Variable ) map [ string ] backend . UnparsedVariableValue { var missing bool for name , vc := range vcs { if ! vc . Required ( ) { continue } if _ , exists := existing [ name ] ; ! exists { missing = true } } if ! missing { return existing } ret := make ( map [ string ] backend . UnparsedVariableValue , len ( vcs ) ) for k , v := range existing { ret [ k ] = v } for name , vc := range vcs { if ! vc . Required ( ) { continue } if _ , exists := existing [ name ] ; ! exists { ret [ name ] = unparsedUnknownVariableValue { Name : name , WantType : vc . Type } } } return ret }
stubUnsetVariables ensures that all required variables defined in the
configuration exist in the resulting map, by adding new elements as necessary.
stubUnsetVariables ensures that all required variables defined in the configuration exist in the resulting map by adding new elements as necessary .
// Do we need to add anything? // We only stub required variables // If we get down here then there's at least one variable value to add.