remove mapstructure from blockstorage,cdn,compute,db pkgs
diff --git a/openstack/blockstorage/v1/apiversions/requests_test.go b/openstack/blockstorage/v1/apiversions/requests_test.go
index 15a7660..3a14c99 100644
--- a/openstack/blockstorage/v1/apiversions/requests_test.go
+++ b/openstack/blockstorage/v1/apiversions/requests_test.go
@@ -54,10 +54,7 @@
List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractAPIVersions(page)
- if err != nil {
- t.Errorf("Failed to extract API versions: %v", err)
- return false, err
- }
+ th.AssertNoErr(t, err)
expected := []APIVersion{
APIVersion{
@@ -77,9 +74,7 @@
return true, nil
})
- if count != 1 {
- t.Errorf("Expected 1 page, got %d", count)
- }
+ th.AssertEquals(t, 1, count)
}
func TestAPIInfo(t *testing.T) {
@@ -129,9 +124,7 @@
})
actual, err := Get(client.ServiceClient(), "v1").Extract()
- if err != nil {
- t.Errorf("Failed to extract version: %v", err)
- }
+ th.AssertNoErr(t, err)
expected := APIVersion{
ID: "v1.0",
diff --git a/openstack/blockstorage/v1/apiversions/results.go b/openstack/blockstorage/v1/apiversions/results.go
index 854f8dd..79a89de 100644
--- a/openstack/blockstorage/v1/apiversions/results.go
+++ b/openstack/blockstorage/v1/apiversions/results.go
@@ -3,15 +3,13 @@
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
-
- "github.com/mitchellh/mapstructure"
)
// APIVersion represents an API version for Cinder.
type APIVersion struct {
- ID string `json:"id" mapstructure:"id"` // unique identifier
- Status string `json:"status" mapstructure:"status"` // current status
- Updated string `json:"updated" mapstructure:"updated"` // date last updated
+ ID string `json:"id"` // unique identifier
+ Status string `json:"status"` // current status
+ Updated string `json:"updated"` // date last updated
}
// APIVersionPage is the page returned by a pager when traversing over a
@@ -23,22 +21,18 @@
// IsEmpty checks whether an APIVersionPage struct is empty.
func (r APIVersionPage) IsEmpty() (bool, error) {
is, err := ExtractAPIVersions(r)
- if err != nil {
- return true, err
- }
- return len(is) == 0, nil
+ return len(is) == 0, err
}
// ExtractAPIVersions takes a collection page, extracts all of the elements,
// and returns them a slice of APIVersion structs. It is effectively a cast.
func ExtractAPIVersions(page pagination.Page) ([]APIVersion, error) {
- var resp struct {
- Versions []APIVersion `mapstructure:"versions"`
+ r := page.(APIVersionPage)
+ var s struct {
+ Versions []APIVersion `json:"versions"`
}
-
- err := mapstructure.Decode(page.(APIVersionPage).Body, &resp)
-
- return resp.Versions, err
+ err := r.ExtractInto(&s)
+ return s.Versions, err
}
// GetResult represents the result of a get operation.
@@ -48,11 +42,9 @@
// Extract is a function that accepts a result and extracts an API version resource.
func (r GetResult) Extract() (*APIVersion, error) {
- var resp struct {
- Version *APIVersion `mapstructure:"version"`
+ var s struct {
+ Version *APIVersion `json:"version"`
}
-
- err := mapstructure.Decode(r.Body, &resp)
-
- return resp.Version, err
+ err := r.ExtractInto(&s)
+ return s.Version, err
}