From 7b3a462ad135daed9094e51985c346944fc7cf7a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 22 Jul 2014 08:51:50 -0700 Subject: [PATCH] config: remove UserMapVariable --- config/interpolate.go | 50 ++++++++------------------------------ config/interpolate_test.go | 4 --- 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/config/interpolate.go b/config/interpolate.go index 0b0bfc460..59f14a83b 100644 --- a/config/interpolate.go +++ b/config/interpolate.go @@ -69,14 +69,6 @@ type ResourceVariable struct { // "${var.foo}" type UserVariable struct { Name string - - key string -} - -// A UserMapVariable is a variable that is referencing a user -// variable that is a map. This looks like "${var.amis.us-east-1}" -type UserMapVariable struct { - Name string Elem string key string @@ -142,12 +134,7 @@ func NewInterpolatedVariable(v string) (InterpolatedVariable, error) { return NewResourceVariable(v) } - varKey := v[len("var."):] - if strings.Index(varKey, ".") == -1 { - return NewUserVariable(v) - } else { - return NewUserMapVariable(v) - } + return NewUserVariable(v) } func (i *FunctionInterpolation) FullString() string { @@ -257,9 +244,17 @@ func (v *ResourceVariable) FullKey() string { func NewUserVariable(key string) (*UserVariable, error) { name := key[len("var."):] + elem := "" + if idx := strings.Index(name, "."); idx > -1 { + elem = name[idx+1:] + name = name[:idx] + } + return &UserVariable{ - key: key, + key: key, + Name: name, + Elem: elem, }, nil } @@ -270,28 +265,3 @@ func (v *UserVariable) FullKey() string { func (v *UserVariable) GoString() string { return fmt.Sprintf("*%#v", *v) } - -func NewUserMapVariable(key string) (*UserMapVariable, error) { - name := key[len("var."):] - idx := strings.Index(name, ".") - if idx == -1 { - return nil, fmt.Errorf("not a user map variable: %s", key) - } - - elem := name[idx+1:] - name = name[:idx] - return &UserMapVariable{ - Name: name, - Elem: elem, - - key: key, - }, nil -} - -func (v *UserMapVariable) FullKey() string { - return v.key -} - -func (v *UserMapVariable) GoString() string { - return fmt.Sprintf("%#v", *v) -} diff --git a/config/interpolate_test.go b/config/interpolate_test.go index f9ccb619f..32d1f9869 100644 --- a/config/interpolate_test.go +++ b/config/interpolate_test.go @@ -238,10 +238,6 @@ func TestUserVariable_impl(t *testing.T) { var _ InterpolatedVariable = new(UserVariable) } -func TestUserMapVariable_impl(t *testing.T) { - var _ InterpolatedVariable = new(UserMapVariable) -} - func TestVariableInterpolation_impl(t *testing.T) { var _ Interpolation = new(VariableInterpolation) }