Removing unnecessary conditionals from identity service
diff --git a/openstack/identity/v2/tenants/results.go b/openstack/identity/v2/tenants/results.go
index e4e3f47..c1220c3 100644
--- a/openstack/identity/v2/tenants/results.go
+++ b/openstack/identity/v2/tenants/results.go
@@ -2,6 +2,7 @@
import (
"github.com/mitchellh/mapstructure"
+ "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
)
@@ -36,12 +37,8 @@
// NextPageURL extracts the "next" link from the tenants_links section of the result.
func (page TenantPage) NextPageURL() (string, error) {
- type link struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- }
type resp struct {
- Links []link `mapstructure:"tenants_links"`
+ Links []gophercloud.Link `mapstructure:"tenants_links"`
}
var r resp
@@ -50,17 +47,7 @@
return "", err
}
- var url string
- for _, l := range r.Links {
- if l.Rel == "next" {
- url = l.Href
- }
- }
- if url == "" {
- return "", nil
- }
-
- return url, nil
+ return gophercloud.ExtractNextURL(r.Links)
}
// ExtractTenants returns a slice of Tenants contained in a single page of results.
diff --git a/openstack/identity/v3/endpoints/results.go b/openstack/identity/v3/endpoints/results.go
index 2dd2357..d1c2472 100644
--- a/openstack/identity/v3/endpoints/results.go
+++ b/openstack/identity/v3/endpoints/results.go
@@ -1,8 +1,6 @@
package endpoints
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -24,11 +22,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Endpoint: %v", err)
- }
- return &res.Endpoint, nil
+ return &res.Endpoint, err
}
// CreateResult is the deferred result of a Create call.
@@ -77,8 +72,6 @@
}
err := mapstructure.Decode(page.(EndpointPage).Body, &response)
- if err != nil {
- return nil, err
- }
- return response.Endpoints, nil
+
+ return response.Endpoints, err
}
diff --git a/openstack/identity/v3/services/results.go b/openstack/identity/v3/services/results.go
index b4e7bd2..e4e068b 100644
--- a/openstack/identity/v3/services/results.go
+++ b/openstack/identity/v3/services/results.go
@@ -1,8 +1,6 @@
package services
import (
- "fmt"
-
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -25,11 +23,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Service: %v", err)
- }
- return &res.Service, nil
+ return &res.Service, err
}
// CreateResult is the deferred result of a Create call.
diff --git a/openstack/identity/v3/tokens/results.go b/openstack/identity/v3/tokens/results.go
index e96da51..1be98cb 100644
--- a/openstack/identity/v3/tokens/results.go
+++ b/openstack/identity/v3/tokens/results.go
@@ -40,11 +40,8 @@
// Attempt to parse the timestamp.
token.ExpiresAt, err = time.Parse(gophercloud.RFC3339Milli, response.Token.ExpiresAt)
- if err != nil {
- return nil, err
- }
- return &token, nil
+ return &token, err
}
// CreateResult is the deferred response from a Create call.