terraform/internal/backend
Martin Atkins 36c4d4c241 core and backend: remove redundant handling of default variable values
Previously we had three different layers all thinking they were
responsible for substituting a default value for an unset root module
variable:
 - the local backend, via logic in backend.ParseVariableValues
 - the context.Plan function (and other similar functions) trying to
   preprocess the input variables using
   terraform.mergeDefaultInputVariableValues .
 - the newer prepareFinalInputVariableValue, which aims to centralize all
   of the variable preparation logic so it can be common to both root and
   child module variables.

The second of these was also trying to handle type constraint checking,
which is also the responsibility of the central function and not something
we need to handle so early.

Only the last of these consistently handles both root and child module
variables, and so is the one we ought to keep. The others are now
redundant and are causing prepareFinalInputVariableValue to get a slightly
corrupted view of the caller's chosen variable values.

To rectify that, here we remove the two redundant layers altogether and
have unset root variables pass through as cty.NilVal all the way to the
central prepareFinalInputVariableValue function, which will then handle
them in a suitable way which properly respects the "nullable" setting.

This commit includes some test changes in the terraform package to make
those tests no longer rely on the mergeDefaultInputVariableValues logic
we've removed, and to instead explicitly set cty.NilVal for all unset
variables to comply with our intended contract for PlanOpts.SetVariables,
and similar. (This is so that we can more easily catch bugs in callers
where they _don't_ correctly handle input variables; it allows us to
distinguish between the caller explicitly marking a variable as unset vs.
not describing it at all, where the latter is a bug in the caller.)
2022-01-10 12:26:54 -08:00
..
init Initial commit of 'cloud' package 2021-10-28 19:29:09 -05:00
local command/show: Disable plan state lineage checks 2021-12-17 17:46:42 -05:00
remote cloud: Add streamlined 'remote' backend state migration path 2021-11-03 15:07:33 -05:00
remote-state pass hclog logger to retryable client 2021-11-30 00:09:01 +00:00
backend.go command/show: Disable plan state lineage checks 2021-12-17 17:46:42 -05:00
backend_test.go Move backend/ to internal/backend/ 2021-05-17 14:09:07 -07:00
cli.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
operation_type.go Move backend/ to internal/backend/ 2021-05-17 14:09:07 -07:00
operationtype_string.go Move backend/ to internal/backend/ 2021-05-17 14:09:07 -07:00
testing.go command/workspace_delete: Allow deleting a workspace with empty husks 2021-10-13 13:54:11 -07:00
unparsed_value.go core and backend: remove redundant handling of default variable values 2022-01-10 12:26:54 -08:00
unparsed_value_test.go core and backend: remove redundant handling of default variable values 2022-01-10 12:26:54 -08:00