check for http response error in ExtractInto*Ptr methods
rename tenantattr pkg to volumetenants
diff --git a/openstack/blockstorage/extensions/tenantattr/results.go b/openstack/blockstorage/extensions/tenants/results.go
similarity index 90%
rename from openstack/blockstorage/extensions/tenantattr/results.go
rename to openstack/blockstorage/extensions/tenants/results.go
index 6e1cd15..fe5b0ab 100644
--- a/openstack/blockstorage/extensions/tenantattr/results.go
+++ b/openstack/blockstorage/extensions/tenants/results.go
@@ -1,4 +1,4 @@
-package tenantattr
+package tenants
// An extension to the base Volume object
type VolumeExt struct {
diff --git a/openstack/blockstorage/v2/volumes/testing/requests_test.go b/openstack/blockstorage/v2/volumes/testing/requests_test.go
index 05fd686..dff7292 100644
--- a/openstack/blockstorage/v2/volumes/testing/requests_test.go
+++ b/openstack/blockstorage/v2/volumes/testing/requests_test.go
@@ -5,7 +5,7 @@
"time"
"github.com/gophercloud/gophercloud"
- "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/tenantattr"
+ "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/tenants"
"github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes"
"github.com/gophercloud/gophercloud/pagination"
th "github.com/gophercloud/gophercloud/testhelper"
@@ -103,7 +103,7 @@
type VolumeWithExt struct {
volumes.Volume
- tenantattr.VolumeExt
+ tenants.VolumeExt
}
allPages, err := volumes.List(client.ServiceClient(), &volumes.ListOpts{}).AllPages()
@@ -245,7 +245,7 @@
var s struct {
volumes.Volume
- tenantattr.VolumeExt
+ tenants.VolumeExt
}
err := volumes.Get(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22").ExtractInto(&s)
th.AssertNoErr(t, err)
diff --git a/results.go b/results.go
index 899f2a4..76c16ef 100644
--- a/results.go
+++ b/results.go
@@ -63,10 +63,6 @@
}
func (r Result) extractIntoPtr(to interface{}, label string) error {
- if r.Err != nil {
- return r.Err
- }
-
if label == "" {
return r.ExtractInto(&to)
}
@@ -96,6 +92,10 @@
// If provided, `label` will be filtered out of the response
// body prior to `r` being unmarshalled into `to`.
func (r Result) ExtractIntoStructPtr(to interface{}, label string) error {
+ if r.Err != nil {
+ return r.Err
+ }
+
t := reflect.TypeOf(to)
if k := t.Kind(); k != reflect.Ptr {
return fmt.Errorf("Expected pointer, got %v", k)
@@ -118,6 +118,10 @@
// If provided, `label` will be filtered out of the response
// body prior to `r` being unmarshalled into `to`.
func (r Result) ExtractIntoSlicePtr(to interface{}, label string) error {
+ if r.Err != nil {
+ return r.Err
+ }
+
t := reflect.TypeOf(to)
if k := t.Kind(); k != reflect.Ptr {
return fmt.Errorf("Expected pointer, got %v", k)