cb9ef298f3
The mapstructure library has a regrettable backward compatibility concern whereby a WeakDecode of []interface{}{} into a target of map[string]interface{} yields an empty map rather than an error. One possibility is to switch to using Decode instead of WeakDecode, but this loses the nice handling of type conversion, requiring a large volume of code to be added to Terraform or HIL in order to retain that behaviour. Instead we add a DecodeHook to our usage of the mapstructure library which checks for decoding []interface{}{} or []string{} into a map and returns an error instead. This has the effect of defeating the code added to retain backwards compatibility in mapstructure, giving us the correct (for our circumstances) behaviour of Decode for empty structures and the type conversion of WeakDecode. The code is identical to that in the HIL library, and packaged into a helper. |
||
---|---|---|
.. | ||
hilmapstructure.go |