config: DefaultsMap should return nil if nil
This commit is contained in:
parent
c9a20c3c58
commit
fe2285898a
|
@ -283,8 +283,11 @@ func (r *Resource) mergerMerge(m merger) merger {
|
|||
|
||||
// DefaultsMap returns a map of default values for this variable.
|
||||
func (v *Variable) DefaultsMap() map[string]string {
|
||||
n := fmt.Sprintf("var.%s", v.Name)
|
||||
if v.Default == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
n := fmt.Sprintf("var.%s", v.Name)
|
||||
switch v.Type() {
|
||||
case VariableTypeString:
|
||||
return map[string]string{n: v.Default.(string)}
|
||||
|
|
|
@ -102,6 +102,11 @@ func TestVariableDefaultsMap(t *testing.T) {
|
|||
Default interface{}
|
||||
Output map[string]string
|
||||
}{
|
||||
{
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
|
||||
{
|
||||
"foo",
|
||||
map[string]string{"var.foo": "foo"},
|
||||
|
|
Loading…
Reference in New Issue