terraform: fall through on type conversion failure
This fixes a test but also loosens the requirements of Variables() so that the Validate() call on Terraform can actually catch those errors.
This commit is contained in:
parent
bac66430cb
commit
50d493163d
|
@ -110,14 +110,15 @@ func Variables(
|
||||||
case config.VariableTypeMap:
|
case config.VariableTypeMap:
|
||||||
varSetMap(result, k, v)
|
varSetMap(result, k, v)
|
||||||
case config.VariableTypeString:
|
case config.VariableTypeString:
|
||||||
|
// Convert to a string and set. We don't catch any errors
|
||||||
|
// here because the validation step later should catch
|
||||||
|
// any type errors.
|
||||||
var strVal string
|
var strVal string
|
||||||
if err := hilmapstructure.WeakDecode(v, &strVal); err != nil {
|
if err := hilmapstructure.WeakDecode(v, &strVal); err == nil {
|
||||||
return nil, fmt.Errorf(
|
|
||||||
"Error converting %s value to type string: %s",
|
|
||||||
k, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
result[k] = strVal
|
result[k] = strVal
|
||||||
|
} else {
|
||||||
|
result[k] = v
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf(
|
panic(fmt.Sprintf(
|
||||||
"Unhandled var type: %T\n\n"+
|
"Unhandled var type: %T\n\n"+
|
||||||
|
|
Loading…
Reference in New Issue