remove mapstructure from blockstorage,cdn,compute,db pkgs
diff --git a/openstack/db/v1/datastores/results.go b/openstack/db/v1/datastores/results.go
index a0b3ee8..e893884 100644
--- a/openstack/db/v1/datastores/results.go
+++ b/openstack/db/v1/datastores/results.go
@@ -1,7 +1,6 @@
package datastores
import (
- "github.com/mitchellh/mapstructure"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
@@ -15,7 +14,7 @@
// Datastore represents a Datastore API resource.
type Datastore struct {
- DefaultVersion string `json:"default_version" mapstructure:"default_version"`
+ DefaultVersion string `json:"default_version"`
ID string
Links []gophercloud.Link
Name string
@@ -28,7 +27,7 @@
type DatastorePartial struct {
Version string
Type string
- VersionID string `json:"version_id" mapstructure:"version_id"`
+ VersionID string `json:"version_id"`
}
// GetResult represents the result of a Get operation.
@@ -49,40 +48,30 @@
// IsEmpty indicates whether a Datastore collection is empty.
func (r DatastorePage) IsEmpty() (bool, error) {
is, err := ExtractDatastores(r)
- if err != nil {
- return true, err
- }
- return len(is) == 0, nil
+ return len(is) == 0, err
}
// ExtractDatastores retrieves a slice of datastore structs from a paginated
// collection.
func ExtractDatastores(page pagination.Page) ([]Datastore, error) {
- casted := page.(DatastorePage).Body
-
- var resp struct {
- Datastores []Datastore `mapstructure:"datastores" json:"datastores"`
+ r := page.(DatastorePage)
+ var s struct {
+ Datastores []Datastore `json:"datastores"`
}
-
- err := mapstructure.Decode(casted, &resp)
- return resp.Datastores, err
+ err := r.ExtractInto(&s)
+ return s.Datastores, err
}
// Extract retrieves a single Datastore struct from an operation result.
func (r GetResult) Extract() (*Datastore, error) {
- if r.Err != nil {
- return nil, r.Err
+ var s struct {
+ Datastore *Datastore `json:"datastore"`
}
-
- var response struct {
- Datastore Datastore `mapstructure:"datastore"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
- return &response.Datastore, err
+ err := r.ExtractInto(&s)
+ return s.Datastore, err
}
-// DatastorePage represents a page of version resources.
+// VersionPage represents a page of version resources.
type VersionPage struct {
pagination.SinglePageBase
}
@@ -90,34 +79,24 @@
// IsEmpty indicates whether a collection of version resources is empty.
func (r VersionPage) IsEmpty() (bool, error) {
is, err := ExtractVersions(r)
- if err != nil {
- return true, err
- }
- return len(is) == 0, nil
+ return len(is) == 0, err
}
// ExtractVersions retrieves a slice of versions from a paginated collection.
func ExtractVersions(page pagination.Page) ([]Version, error) {
- casted := page.(VersionPage).Body
-
- var resp struct {
- Versions []Version `mapstructure:"versions" json:"versions"`
+ r := page.(VersionPage)
+ var s struct {
+ Versions []Version `json:"versions"`
}
-
- err := mapstructure.Decode(casted, &resp)
- return resp.Versions, err
+ err := r.ExtractInto(&s)
+ return s.Versions, err
}
// Extract retrieves a single Version struct from an operation result.
func (r GetVersionResult) Extract() (*Version, error) {
- if r.Err != nil {
- return nil, r.Err
+ var s struct {
+ Version *Version `json:"version"`
}
-
- var response struct {
- Version Version `mapstructure:"version"`
- }
-
- err := mapstructure.Decode(r.Body, &response)
- return &response.Version, err
+ err := r.ExtractInto(&s)
+ return s.Version, err
}