mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Signed-off-by: ollevche <ollevche@gmail.com>
This commit is contained in:
parent
e1daace5ea
commit
39a15ab499
@ -5,6 +5,7 @@ BUG FIXES:
|
|||||||
* Changes to encryption configuration now auto-apply the migration ([#2232](https://github.com/opentofu/opentofu/pull/2232))
|
* Changes to encryption configuration now auto-apply the migration ([#2232](https://github.com/opentofu/opentofu/pull/2232))
|
||||||
* Updated github.com/golang-jwt/jwt/v4 from 4.4.2 to 4.5.1 to make security scanners happy (no vulnerability, see [#2179](https://github.com/opentofu/opentofu/pull/2179))
|
* Updated github.com/golang-jwt/jwt/v4 from 4.4.2 to 4.5.1 to make security scanners happy (no vulnerability, see [#2179](https://github.com/opentofu/opentofu/pull/2179))
|
||||||
* `tofu test` is now setting `null`s for dynamic type when generating mock values. ([#2245](https://github.com/opentofu/opentofu/pull/2245))
|
* `tofu test` is now setting `null`s for dynamic type when generating mock values. ([#2245](https://github.com/opentofu/opentofu/pull/2245))
|
||||||
|
* Variables declared in test files are now taking into account type default values. ([#2244](https://github.com/opentofu/opentofu/pull/2244))
|
||||||
|
|
||||||
## 1.8.6
|
## 1.8.6
|
||||||
|
|
||||||
|
@ -1130,6 +1130,13 @@ func parseAndApplyDefaultValues(unparsedVariables map[string]backend.UnparsedVar
|
|||||||
for name, variable := range unparsedVariables {
|
for name, variable := range unparsedVariables {
|
||||||
value, valueDiags := variable.ParseVariableValue(configs.VariableParseLiteral)
|
value, valueDiags := variable.ParseVariableValue(configs.VariableParseLiteral)
|
||||||
diags = diags.Append(valueDiags)
|
diags = diags.Append(valueDiags)
|
||||||
|
|
||||||
|
// Even so the variable is declared, some of the fields could
|
||||||
|
// be empty and filled in via type default values.
|
||||||
|
if confVariable, ok := configVariables[name]; ok && confVariable.TypeDefaults != nil {
|
||||||
|
value.Value = confVariable.TypeDefaults.Apply(value.Value)
|
||||||
|
}
|
||||||
|
|
||||||
inputs[name] = value
|
inputs[name] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,3 +3,10 @@ variable "input" {
|
|||||||
type = string
|
type = string
|
||||||
default = "Hello, world!"
|
default = "Hello, world!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "another_input" {
|
||||||
|
type = object({
|
||||||
|
optional_string = optional(string, "type_default")
|
||||||
|
optional_number = optional(number, 42)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -4,4 +4,20 @@ run "applies_defaults" {
|
|||||||
condition = var.input == "Hello, world!"
|
condition = var.input == "Hello, world!"
|
||||||
error_message = "should have applied default value"
|
error_message = "should have applied default value"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variables {
|
||||||
|
another_input = {
|
||||||
|
optional_string = "Hello, world!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert {
|
||||||
|
condition = var.another_input.optional_string == "Hello, world!"
|
||||||
|
error_message = "should have used custom value from test file"
|
||||||
|
}
|
||||||
|
|
||||||
|
assert {
|
||||||
|
condition = var.another_input.optional_number == 42
|
||||||
|
error_message = "should have used default type value"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user