Skip to content

Commit

Permalink
Follow up on upstream changes regarding evaluation (#1677)
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 authored Feb 12, 2023
1 parent 0de4678 commit 3a3747b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions terraform/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ func (d *evaluationData) GetInputVariable(addr addrs.InputVariable, rng hcl.Rang
val = config.Default
}

// Apply defaults from the variable's type constraint to the value,
// unless the value is null. We do not apply defaults to top-level
// null values, as doing so could prevent assigning null to a nullable
// variable.
if config.TypeDefaults != nil && !val.IsNull() {
val = config.TypeDefaults.Apply(val)
}

var err error
val, err = convert.Convert(val, config.ConstraintType)
if err != nil {
Expand All @@ -208,14 +216,6 @@ func (d *evaluationData) GetInputVariable(addr addrs.InputVariable, rng hcl.Rang
val = cty.UnknownVal(config.Type)
}

// Apply defaults from the variable's type constraint to the value,
// unless the value is null. We do not apply defaults to top-level
// null values, as doing so could prevent assigning null to a nullable
// variable.
if config.TypeDefaults != nil && !val.IsNull() {
val = config.TypeDefaults.Apply(val)
}

// Mark if sensitive
if config.Sensitive {
val = val.Mark(marks.Sensitive)
Expand Down

0 comments on commit 3a3747b

Please sign in to comment.