use better type assertions
diff --git a/openstack/db/v1/configurations/results.go b/openstack/db/v1/configurations/results.go
index 37a77ad..d0d1d6e 100644
--- a/openstack/db/v1/configurations/results.go
+++ b/openstack/db/v1/configurations/results.go
@@ -1,6 +1,8 @@
package configurations
import (
+ "fmt"
+ "reflect"
"time"
"github.com/mitchellh/mapstructure"
@@ -43,12 +45,18 @@
Configs []Config `mapstructure:"configurations" json:"configurations"`
}
- err := mapstructure.Decode(casted, &resp)
+ if err := mapstructure.Decode(casted, &resp); err != nil {
+ return nil, err
+ }
var vals []interface{}
- switch (casted).(type) {
- case interface{}:
+ switch casted.(type) {
+ case map[string]interface{}:
vals = casted.(map[string]interface{})["configurations"].([]interface{})
+ case map[string][]interface{}:
+ vals = casted.(map[string][]interface{})["configurations"]
+ default:
+ return resp.Configs, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
}
for i, v := range vals {
@@ -71,7 +79,7 @@
}
}
- return resp.Configs, err
+ return resp.Configs, nil
}
type commonResult struct {