mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 17:01:04 -06:00
move nullable check to variable input evaluation
This commit is contained in:
parent
7b7972ac95
commit
b71b393cf6
@ -277,18 +277,6 @@ func (d *evaluationStateData) GetInputVariable(addr addrs.InputVariable, rng tfd
|
||||
case val.IsNull() && !config.Nullable && config.Default != cty.NilVal:
|
||||
// If nullable=false a null value will use the configured default.
|
||||
val = config.Default
|
||||
|
||||
case val.IsNull() && !config.Nullable:
|
||||
// The value cannot be null, and there is no configured default.
|
||||
diags = diags.Append(&hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: `Invalid variable value`,
|
||||
Detail: fmt.Sprintf(`The resolved value of variable %q cannot be null.`, addr.Name),
|
||||
Subject: &config.DeclRange,
|
||||
})
|
||||
// Stub out our return value so that the semantic checker doesn't
|
||||
// produce redundant downstream errors.
|
||||
val = cty.UnknownVal(config.Type)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
@ -253,7 +253,23 @@ func (n *nodeModuleVariable) evalModuleCallArgument(ctx EvalContext, validateOnl
|
||||
val = cty.UnknownVal(n.Config.Type)
|
||||
}
|
||||
|
||||
// If there is no default, we have to ensure that a null value is allowed
|
||||
// for this variable.
|
||||
if n.Config.Default == cty.NilVal && !n.Config.Nullable && val.IsNull() {
|
||||
// The value cannot be null, and there is no configured default.
|
||||
diags = diags.Append(&hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: `Invalid variable value`,
|
||||
Detail: fmt.Sprintf(`The resolved value of variable %q cannot be null.`, n.Addr),
|
||||
Subject: &n.Config.DeclRange,
|
||||
})
|
||||
// Stub out our return value so that the semantic checker doesn't
|
||||
// produce redundant downstream errors.
|
||||
val = cty.UnknownVal(n.Config.Type)
|
||||
}
|
||||
|
||||
vals := make(map[string]cty.Value)
|
||||
vals[name] = val
|
||||
|
||||
return vals, diags.ErrWithWarnings()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user