From 61938c070f2824ebb9eb65a3ab35da0a42d53f2f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 22 Jul 2014 08:34:24 -0700 Subject: [PATCH] config: validate type of default to string or mapping for var --- config/config.go | 9 +++++++-- config/config_test.go | 4 ---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index 46a2ce431..4ed008ee2 100644 --- a/config/config.go +++ b/config/config.go @@ -108,8 +108,13 @@ func (c *Config) Validate() error { varMap[v.Name] = v } - // TODO(mitchellh): Validate that variable defaults are only a string - // or mapping of strings. + for _, v := range c.Variables { + if v.Type() == VariableTypeUnknown { + errs = append(errs, fmt.Errorf( + "Variable '%s': must be string or mapping", + v.Name)) + } + } // Check for references to user variables that do not actually // exist and record those errors. diff --git a/config/config_test.go b/config/config_test.go index a060798ee..9b141fa8f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -73,10 +73,6 @@ func TestConfigValidate_varDefault(t *testing.T) { } func TestConfigValidate_varDefaultBadType(t *testing.T) { - t.Skip() - - // TODO(mitchellh): FIX - c := testConfig(t, "validate-var-default-bad-type") if err := c.Validate(); err == nil { t.Fatal("should not be valid")