helper/schema: default the new value to zero only for the decode

This commit is contained in:
Mitchell Hashimoto 2015-02-17 13:16:59 -08:00
parent ad6be99f5b
commit bcdec738d4
1 changed files with 4 additions and 3 deletions

View File

@ -810,13 +810,14 @@ func (m schemaMap) diffString(
originalN = n originalN = n
n = schema.StateFunc(n) n = schema.StateFunc(n)
} }
if n == nil { nraw := n
n = schema.Type.Zero() if nraw == nil {
nraw = schema.Type.Zero()
} }
if err := mapstructure.WeakDecode(o, &os); err != nil { if err := mapstructure.WeakDecode(o, &os); err != nil {
return fmt.Errorf("%s: %s", k, err) return fmt.Errorf("%s: %s", k, err)
} }
if err := mapstructure.WeakDecode(n, &ns); err != nil { if err := mapstructure.WeakDecode(nraw, &ns); err != nil {
return fmt.Errorf("%s: %s", k, err) return fmt.Errorf("%s: %s", k, err)
} }