Use gophercloud.Result in objectstorage.
diff --git a/openstack/objectstorage/v1/accounts/requests.go b/openstack/objectstorage/v1/accounts/requests.go
index 55fcb05..2706197 100644
--- a/openstack/objectstorage/v1/accounts/requests.go
+++ b/openstack/objectstorage/v1/accounts/requests.go
@@ -46,7 +46,7 @@
MoreHeaders: h,
OkCodes: []int{204},
})
- res.Resp = &resp.HttpResponse
+ res.Headers = resp.HttpResponse.Header
res.Err = err
return res
}
@@ -80,8 +80,7 @@
}
// Update is a function that creates, updates, or deletes an account's metadata.
-// To extract the headers returned, call the ExtractHeaders method on the
-// UpdateResult.
+// To extract the headers returned, call the Extract method on the UpdateResult.
func Update(c *gophercloud.ServiceClient, opts UpdateOptsBuilder) UpdateResult {
var res UpdateResult
h := c.Provider.AuthenticatedHeaders()
@@ -101,7 +100,7 @@
MoreHeaders: h,
OkCodes: []int{204},
})
- res.Resp = &resp.HttpResponse
+ res.Headers = resp.HttpResponse.Header
res.Err = err
return res
}
diff --git a/openstack/objectstorage/v1/accounts/requests_test.go b/openstack/objectstorage/v1/accounts/requests_test.go
index 0090eea..d109214 100644
--- a/openstack/objectstorage/v1/accounts/requests_test.go
+++ b/openstack/objectstorage/v1/accounts/requests_test.go
@@ -27,10 +27,8 @@
})
options := &UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}}
- _, err := Update(fake.ServiceClient(), options).ExtractHeaders()
- if err != nil {
- t.Fatalf("Unable to update account: %v", err)
- }
+ _, err := Update(fake.ServiceClient(), options).Extract()
+ th.AssertNoErr(t, err)
}
func TestGetAccount(t *testing.T) {
diff --git a/openstack/objectstorage/v1/accounts/results.go b/openstack/objectstorage/v1/accounts/results.go
index 8ff8183..964a604 100644
--- a/openstack/objectstorage/v1/accounts/results.go
+++ b/openstack/objectstorage/v1/accounts/results.go
@@ -1,14 +1,15 @@
package accounts
import (
+ "net/http"
"strings"
- objectstorage "github.com/rackspace/gophercloud/openstack/objectstorage/v1"
+ "github.com/rackspace/gophercloud"
)
-// GetResult is returned from a call to the Get function. See v1.CommonResult.
+// GetResult is returned from a call to the Get function.
type GetResult struct {
- objectstorage.CommonResult
+ gophercloud.Result
}
// ExtractMetadata is a function that takes a GetResult (of type *http.Response)
@@ -19,7 +20,7 @@
}
metadata := make(map[string]string)
- for k, v := range gr.Resp.Header {
+ for k, v := range gr.Headers {
if strings.HasPrefix(k, "X-Account-Meta-") {
key := strings.TrimPrefix(k, "X-Account-Meta-")
metadata[key] = v[0]
@@ -28,7 +29,13 @@
return metadata, nil
}
-// UpdateResult is returned from a call to the Update function. See v1.CommonResult.
+// UpdateResult is returned from a call to the Update function.
type UpdateResult struct {
- objectstorage.CommonResult
+ gophercloud.Result
+}
+
+// Extract returns the unmodified HTTP headers and any error conditions encountered during the
+// metadata update.
+func (ur UpdateResult) Extract() (http.Header, error) {
+ return ur.Headers, ur.Err
}