Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Terraform
Commits
b71b393c
Commit
b71b393c
authored
3 years ago
by
James Bardin
Browse files
Options
Download
Email Patches
Plain Diff
move nullable check to variable input evaluation
parent
7b7972ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/terraform/evaluate.go
+0
-12
internal/terraform/evaluate.go
internal/terraform/node_module_variable.go
+16
-0
internal/terraform/node_module_variable.go
with
16 additions
and
12 deletions
+16
-12
internal/terraform/evaluate.go
+
0
-
12
View file @
b71b393c
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
internal/terraform/node_module_variable.go
+
16
-
0
View file @
b71b393c
...
...
@@ -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
()
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help