Fixing minor issues such as weakly typed decoding
diff --git a/openstack/db/v1/flavors/fixtures.go b/openstack/db/v1/flavors/fixtures.go
index df70898..f0016bc 100644
--- a/openstack/db/v1/flavors/fixtures.go
+++ b/openstack/db/v1/flavors/fixtures.go
@@ -2,7 +2,6 @@
import (
"fmt"
- "strconv"
"testing"
"github.com/rackspace/gophercloud/testhelper/fixture"
@@ -27,9 +26,9 @@
`
var (
- flavorID = 1
+ flavorID = "{flavorID}"
_baseURL = "/flavors"
- resURL = "/flavors/" + strconv.Itoa(flavorID)
+ resURL = "/flavors/" + flavorID
)
var (
diff --git a/openstack/db/v1/flavors/requests.go b/openstack/db/v1/flavors/requests.go
index beeeddc..fa34446 100644
--- a/openstack/db/v1/flavors/requests.go
+++ b/openstack/db/v1/flavors/requests.go
@@ -17,7 +17,7 @@
}
// Get will retrieve information for a specified hardware flavor.
-func Get(client *gophercloud.ServiceClient, id int) GetResult {
+func Get(client *gophercloud.ServiceClient, id string) GetResult {
var gr GetResult
_, gr.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
diff --git a/openstack/db/v1/flavors/results.go b/openstack/db/v1/flavors/results.go
index 2089f67..2cee010 100644
--- a/openstack/db/v1/flavors/results.go
+++ b/openstack/db/v1/flavors/results.go
@@ -21,7 +21,12 @@
Flavor Flavor `mapstructure:"flavor"`
}
- err := mapstructure.Decode(gr.Body, &result)
+ decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
+ WeaklyTypedInput: true,
+ Result: &result,
+ })
+
+ err = decoder.Decode(gr.Body)
return &result.Flavor, err
}
@@ -76,6 +81,12 @@
Flavors []Flavor `mapstructure:"flavors"`
}
- err := mapstructure.Decode(casted, &container)
+ decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
+ WeaklyTypedInput: true,
+ Result: &container,
+ })
+
+ err = decoder.Decode(casted)
+
return container.Flavors, err
}
diff --git a/openstack/db/v1/flavors/urls.go b/openstack/db/v1/flavors/urls.go
index 3b3e8da..80da11f 100644
--- a/openstack/db/v1/flavors/urls.go
+++ b/openstack/db/v1/flavors/urls.go
@@ -1,13 +1,9 @@
package flavors
-import (
- "strconv"
+import "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud"
-)
-
-func getURL(client *gophercloud.ServiceClient, id int) string {
- return client.ServiceURL("flavors", strconv.Itoa(id))
+func getURL(client *gophercloud.ServiceClient, id string) string {
+ return client.ServiceURL("flavors", id)
}
func listURL(client *gophercloud.ServiceClient) string {