From 50d493163d91f11aec4dfa6822d7514948dd1f55 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 31 Oct 2016 11:31:01 -0700 Subject: [PATCH] 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. --- terraform/variables.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/terraform/variables.go b/terraform/variables.go index 186885222..7fab43370 100644 --- a/terraform/variables.go +++ b/terraform/variables.go @@ -110,14 +110,15 @@ func Variables( case config.VariableTypeMap: varSetMap(result, k, v) 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 - if err := hilmapstructure.WeakDecode(v, &strVal); err != nil { - return nil, fmt.Errorf( - "Error converting %s value to type string: %s", - k, err) + if err := hilmapstructure.WeakDecode(v, &strVal); err == nil { + result[k] = strVal + } else { + result[k] = v } - - result[k] = strVal default: panic(fmt.Sprintf( "Unhandled var type: %T\n\n"+