mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-21 16:00:41 -04:00
Merge pull request #1590 from hashicorp/b-bad-var-default
terraform: don't panic on input for bad default type [GH-1344]
This commit is contained in:
@@ -175,6 +175,8 @@ func (c *Context) Input(mode InputMode) error {
|
||||
|
||||
v := m[n]
|
||||
switch v.Type() {
|
||||
case config.VariableTypeUnknown:
|
||||
continue
|
||||
case config.VariableTypeMap:
|
||||
continue
|
||||
case config.VariableTypeString:
|
||||
|
||||
@@ -2883,6 +2883,28 @@ func TestContext2Input(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Input_badVarDefault(t *testing.T) {
|
||||
m := testModule(t, "input-bad-var-default")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
})
|
||||
|
||||
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
|
||||
c.Config["foo"] = "bar"
|
||||
return c, nil
|
||||
}
|
||||
|
||||
if err := ctx.Input(InputModeStd); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Input_provider(t *testing.T) {
|
||||
m := testModule(t, "input-provider")
|
||||
p := testProvider("aws")
|
||||
|
||||
5
terraform/test-fixtures/input-bad-var-default/main.tf
Normal file
5
terraform/test-fixtures/input-bad-var-default/main.tf
Normal file
@@ -0,0 +1,5 @@
|
||||
variable "test" {
|
||||
default {
|
||||
l = [1, 2, 3]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user