remove mapstructure from blockstorage,cdn,compute,db pkgs
diff --git a/openstack/compute/v2/extensions/diskconfig/requests_test.go b/openstack/compute/v2/extensions/diskconfig/requests_test.go
index 61057d4..2e3ae18 100644
--- a/openstack/compute/v2/extensions/diskconfig/requests_test.go
+++ b/openstack/compute/v2/extensions/diskconfig/requests_test.go
@@ -25,8 +25,6 @@
"name": "createdserver",
"imageRef": "asdfasdfasdf",
"flavorRef": "performance1-1",
- "flavorName": "",
- "imageName": "",
"OS-DCF:diskConfig": "MANUAL"
}
}
diff --git a/openstack/compute/v2/extensions/diskconfig/results.go b/openstack/compute/v2/extensions/diskconfig/results.go
index b05c5b5..1957e12 100644
--- a/openstack/compute/v2/extensions/diskconfig/results.go
+++ b/openstack/compute/v2/extensions/diskconfig/results.go
@@ -1,60 +1,8 @@
package diskconfig
-import (
- "github.com/mitchellh/mapstructure"
- "github.com/gophercloud/gophercloud"
- "github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
- "github.com/gophercloud/gophercloud/pagination"
-)
+import "github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
-func commonExtract(result gophercloud.Result) (*DiskConfig, error) {
- var resp struct {
- Server struct {
- DiskConfig string `mapstructure:"OS-DCF:diskConfig"`
- } `mapstructure:"server"`
- }
-
- err := mapstructure.Decode(result.Body, &resp)
- if err != nil {
- return nil, err
- }
-
- config := DiskConfig(resp.Server.DiskConfig)
- return &config, nil
-}
-
-// ExtractGet returns the disk configuration from a servers.Get call.
-func ExtractGet(result servers.GetResult) (*DiskConfig, error) {
- return commonExtract(result.Result)
-}
-
-// ExtractUpdate returns the disk configuration from a servers.Update call.
-func ExtractUpdate(result servers.UpdateResult) (*DiskConfig, error) {
- return commonExtract(result.Result)
-}
-
-// ExtractRebuild returns the disk configuration from a servers.Rebuild call.
-func ExtractRebuild(result servers.RebuildResult) (*DiskConfig, error) {
- return commonExtract(result.Result)
-}
-
-// ExtractDiskConfig returns the DiskConfig setting for a specific server acquired from an
-// servers.ExtractServers call, while iterating through a Pager.
-func ExtractDiskConfig(page pagination.Page, index int) (*DiskConfig, error) {
- casted := page.(servers.ServerPage).Body
-
- type server struct {
- DiskConfig string `mapstructure:"OS-DCF:diskConfig"`
- }
- var response struct {
- Servers []server `mapstructure:"servers"`
- }
-
- err := mapstructure.Decode(casted, &response)
- if err != nil {
- return nil, err
- }
-
- config := DiskConfig(response.Servers[index].DiskConfig)
- return &config, nil
+type ServerWithDiskConfig struct {
+ servers.Server
+ DiskConfig DiskConfig `json:"OS-DCF:diskConfig"`
}
diff --git a/openstack/compute/v2/extensions/diskconfig/results_test.go b/openstack/compute/v2/extensions/diskconfig/results_test.go
deleted file mode 100644
index 7c5b6c9..0000000
--- a/openstack/compute/v2/extensions/diskconfig/results_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package diskconfig
-
-import (
- "testing"
-
- "github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
- "github.com/gophercloud/gophercloud/pagination"
- th "github.com/gophercloud/gophercloud/testhelper"
- "github.com/gophercloud/gophercloud/testhelper/client"
-)
-
-func TestExtractGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- servers.HandleServerGetSuccessfully(t)
-
- config, err := ExtractGet(servers.Get(client.ServiceClient(), "1234asdf"))
- th.AssertNoErr(t, err)
- th.CheckEquals(t, Manual, *config)
-}
-
-func TestExtractUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- servers.HandleServerUpdateSuccessfully(t)
-
- r := servers.Update(client.ServiceClient(), "1234asdf", servers.UpdateOpts{
- Name: "new-name",
- })
- config, err := ExtractUpdate(r)
- th.AssertNoErr(t, err)
- th.CheckEquals(t, Manual, *config)
-}
-
-func TestExtractRebuild(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- servers.HandleRebuildSuccessfully(t, servers.SingleServerBody)
-
- r := servers.Rebuild(client.ServiceClient(), "1234asdf", servers.RebuildOpts{
- Name: "new-name",
- AdminPass: "swordfish",
- ImageID: "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/images/f90f6034-2570-4974-8351-6b49732ef2eb",
- AccessIPv4: "1.2.3.4",
- })
- config, err := ExtractRebuild(r)
- th.AssertNoErr(t, err)
- th.CheckEquals(t, Manual, *config)
-}
-
-func TestExtractList(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- servers.HandleServerListSuccessfully(t)
-
- pages := 0
- err := servers.List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
- pages++
-
- config, err := ExtractDiskConfig(page, 0)
- th.AssertNoErr(t, err)
- th.CheckEquals(t, Manual, *config)
-
- return true, nil
- })
- th.AssertNoErr(t, err)
- th.CheckEquals(t, pages, 1)
-}