remove mapstructure from blockstorage,cdn,compute,db pkgs
diff --git a/openstack/db/v1/flavors/requests_test.go b/openstack/db/v1/flavors/requests_test.go
index 387b076..ce01759 100644
--- a/openstack/db/v1/flavors/requests_test.go
+++ b/openstack/db/v1/flavors/requests_test.go
@@ -25,7 +25,7 @@
expected := []Flavor{
Flavor{
- ID: "1",
+ ID: 1,
Name: "m1.tiny",
RAM: 512,
Links: []gophercloud.Link{
@@ -34,7 +34,7 @@
},
},
Flavor{
- ID: "2",
+ ID: 2,
Name: "m1.small",
RAM: 1024,
Links: []gophercloud.Link{
@@ -43,7 +43,7 @@
},
},
Flavor{
- ID: "3",
+ ID: 3,
Name: "m1.medium",
RAM: 2048,
Links: []gophercloud.Link{
@@ -52,7 +52,7 @@
},
},
Flavor{
- ID: "4",
+ ID: 4,
Name: "m1.large",
RAM: 4096,
Links: []gophercloud.Link{
@@ -79,7 +79,7 @@
th.AssertNoErr(t, err)
expected := &Flavor{
- ID: "1",
+ ID: 1,
Name: "m1.tiny",
RAM: 512,
Links: []gophercloud.Link{
diff --git a/openstack/db/v1/flavors/results.go b/openstack/db/v1/flavors/results.go
index 508f5a4..d2a5cba 100644
--- a/openstack/db/v1/flavors/results.go
+++ b/openstack/db/v1/flavors/results.go
@@ -1,7 +1,6 @@
package flavors
import (
- "github.com/mitchellh/mapstructure"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
@@ -12,34 +11,24 @@
}
// Extract provides access to the individual Flavor returned by the Get function.
-func (gr GetResult) Extract() (*Flavor, error) {
- if gr.Err != nil {
- return nil, gr.Err
+func (r GetResult) Extract() (*Flavor, error) {
+ var s struct {
+ Flavor *Flavor `json:"flavor"`
}
-
- var result struct {
- Flavor Flavor `mapstructure:"flavor"`
- }
-
- decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
- WeaklyTypedInput: true,
- Result: &result,
- })
-
- err = decoder.Decode(gr.Body)
- return &result.Flavor, err
+ err := r.ExtractInto(&s)
+ return s.Flavor, err
}
// Flavor records represent (virtual) hardware configurations for server resources in a region.
type Flavor struct {
// The flavor's unique identifier.
- ID string `mapstructure:"id"`
+ ID int `json:"id"`
// The RAM capacity for the flavor.
- RAM int `mapstructure:"ram"`
+ RAM int `json:"ram"`
// The Name field provides a human-readable moniker for the flavor.
- Name string `mapstructure:"name"`
+ Name string `json:"name"`
// Links to access the flavor.
Links []gophercloud.Link
@@ -51,42 +40,29 @@
}
// IsEmpty determines if a page contains any results.
-func (p FlavorPage) IsEmpty() (bool, error) {
- flavors, err := ExtractFlavors(p)
- if err != nil {
- return true, err
- }
- return len(flavors) == 0, nil
+func (page FlavorPage) IsEmpty() (bool, error) {
+ flavors, err := ExtractFlavors(page)
+ return len(flavors) == 0, err
}
// NextPageURL uses the response's embedded link reference to navigate to the next page of results.
-func (p FlavorPage) NextPageURL() (string, error) {
- type resp struct {
- Links []gophercloud.Link `mapstructure:"flavors_links"`
+func (page FlavorPage) NextPageURL() (string, error) {
+ var s struct {
+ Links []gophercloud.Link `json:"flavors_links"`
}
-
- var r resp
- err := mapstructure.Decode(p.Body, &r)
+ err := page.ExtractInto(&s)
if err != nil {
return "", err
}
-
- return gophercloud.ExtractNextURL(r.Links)
+ return gophercloud.ExtractNextURL(s.Links)
}
// ExtractFlavors provides access to the list of flavors in a page acquired from the List operation.
func ExtractFlavors(page pagination.Page) ([]Flavor, error) {
- casted := page.(FlavorPage).Body
- var container struct {
- Flavors []Flavor `mapstructure:"flavors"`
+ r := page.(FlavorPage)
+ var s struct {
+ Flavors []Flavor `json:"flavors"`
}
-
- decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
- WeaklyTypedInput: true,
- Result: &container,
- })
-
- err = decoder.Decode(casted)
-
- return container.Flavors, err
+ err := r.ExtractInto(&s)
+ return s.Flavors, err
}