Provisioning: Handle empty nested keys on YAML provisioning datasources (#19547)

* Fix: Handle empty nested keys on YAML provisioning datasources

As we provision a datasource via a YAML file, we attempt to transform the
file into sensible Go types that the provisioning code can use.

While this happens, there is a chance some of the keys nested within
the YAML array are empty.

This fix allows the YAML parser to handle empty keys by null checking
the return of `reflect.TypeOf` which according to the documentation:

> TypeOf returns the reflection Type that represents the dynamic type of i. If i is a nil interface value, TypeOf returns nil.

Can return nil.

* Add tests
This commit is contained in:
gotjosh
2019-10-02 08:48:19 +02:00
committed by Torkel Ödegaard
parent ac11352e3e
commit 8e508e5ce4
2 changed files with 25 additions and 3 deletions
+7 -1
View File
@@ -155,7 +155,13 @@ func (val *StringMapValue) Value() map[string]string {
// slices and the actual interpolation is done on all simple string values in the structure. It returns a copy of any
// map or slice value instead of modifying them in place.
func tranformInterface(i interface{}) interface{} {
switch reflect.TypeOf(i).Kind() {
typeOf := reflect.TypeOf(i)
if typeOf == nil {
return nil
}
switch typeOf.Kind() {
case reflect.Slice:
return transformSlice(i.([]interface{}))
case reflect.Map: