Removing dead code
diff --git a/openstack/networking/v2/apiversions/results.go b/openstack/networking/v2/apiversions/results.go
index e13998d..9715934 100644
--- a/openstack/networking/v2/apiversions/results.go
+++ b/openstack/networking/v2/apiversions/results.go
@@ -35,11 +35,8 @@
}
err := mapstructure.Decode(page.(APIVersionPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.Versions, nil
+ return resp.Versions, err
}
// APIVersionResource represents a generic API resource. It contains the name
@@ -75,9 +72,6 @@
}
err := mapstructure.Decode(page.(APIVersionResourcePage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.APIVersionResources, nil
+ return resp.APIVersionResources, err
}
diff --git a/openstack/networking/v2/extensions/external/results.go b/openstack/networking/v2/extensions/external/results.go
index aafc703..47f7258 100644
--- a/openstack/networking/v2/extensions/external/results.go
+++ b/openstack/networking/v2/extensions/external/results.go
@@ -1,8 +1,6 @@
package external
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud/openstack/networking/v2/networks"
"github.com/rackspace/gophercloud/pagination"
@@ -47,11 +45,8 @@
}
err := mapstructure.Decode(response, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron network: %v", err)
- }
- return res.Network, nil
+ return res.Network, err
}
// ExtractGet decorates a GetResult struct returned from a networks.Get()
@@ -81,9 +76,6 @@
}
err := mapstructure.Decode(page.(networks.NetworkPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.Networks, nil
+ return resp.Networks, err
}
diff --git a/openstack/networking/v2/extensions/layer3/floatingips/results.go b/openstack/networking/v2/extensions/layer3/floatingips/results.go
index f642834..43892f0 100644
--- a/openstack/networking/v2/extensions/layer3/floatingips/results.go
+++ b/openstack/networking/v2/extensions/layer3/floatingips/results.go
@@ -120,9 +120,6 @@
}
err := mapstructure.Decode(page.(FloatingIPPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.FloatingIPs, nil
+ return resp.FloatingIPs, err
}
diff --git a/openstack/networking/v2/extensions/layer3/routers/results.go b/openstack/networking/v2/extensions/layer3/routers/results.go
index 2fc27fe..eae647f 100755
--- a/openstack/networking/v2/extensions/layer3/routers/results.go
+++ b/openstack/networking/v2/extensions/layer3/routers/results.go
@@ -1,8 +1,6 @@
package routers
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -84,11 +82,8 @@
}
err := mapstructure.Decode(page.(RouterPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.Routers, nil
+ return resp.Routers, err
}
type commonResult struct {
@@ -106,11 +101,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron router: %v", err)
- }
- return res.Router, nil
+ return res.Router, err
}
// CreateResult represents the result of a create operation.
@@ -162,9 +154,6 @@
var res *InterfaceInfo
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron router interface: %v", err)
- }
- return res, nil
+ return res, err
}
diff --git a/openstack/networking/v2/extensions/lbaas/members/results.go b/openstack/networking/v2/extensions/lbaas/members/results.go
index 9466fee..b006551 100644
--- a/openstack/networking/v2/extensions/lbaas/members/results.go
+++ b/openstack/networking/v2/extensions/lbaas/members/results.go
@@ -1,8 +1,6 @@
package members
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -46,12 +44,8 @@
// the end of a page and the pager seeks to traverse over a new one. In order
// to do this, it needs to construct the next page's URL.
func (p MemberPage) NextPageURL() (string, error) {
- type link struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- }
type resp struct {
- Links []link `mapstructure:"members_links"`
+ Links []gophercloud.Link `mapstructure:"members_links"`
}
var r resp
@@ -60,17 +54,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)
}
// IsEmpty checks whether a MemberPage struct is empty.
@@ -113,11 +97,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron member: %v", err)
- }
- return res.Member, nil
+ return res.Member, err
}
// CreateResult represents the result of a create operation.
diff --git a/openstack/networking/v2/extensions/lbaas/monitors/results.go b/openstack/networking/v2/extensions/lbaas/monitors/results.go
index a41f20e..656ab1d 100644
--- a/openstack/networking/v2/extensions/lbaas/monitors/results.go
+++ b/openstack/networking/v2/extensions/lbaas/monitors/results.go
@@ -1,8 +1,6 @@
package monitors
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -74,12 +72,8 @@
// the end of a page and the pager seeks to traverse over a new one. In order
// to do this, it needs to construct the next page's URL.
func (p MonitorPage) NextPageURL() (string, error) {
- type link struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- }
type resp struct {
- Links []link `mapstructure:"health_monitors_links"`
+ Links []gophercloud.Link `mapstructure:"health_monitors_links"`
}
var r resp
@@ -88,17 +82,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)
}
// IsEmpty checks whether a PoolPage struct is empty.
@@ -119,11 +103,8 @@
}
err := mapstructure.Decode(page.(MonitorPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.Monitors, nil
+ return resp.Monitors, err
}
type commonResult struct {
@@ -141,11 +122,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron monitor: %v", err)
- }
- return res.Monitor, nil
+ return res.Monitor, err
}
// CreateResult represents the result of a create operation.
diff --git a/openstack/networking/v2/extensions/lbaas/pools/results.go b/openstack/networking/v2/extensions/lbaas/pools/results.go
index 5b2adde..4233176 100644
--- a/openstack/networking/v2/extensions/lbaas/pools/results.go
+++ b/openstack/networking/v2/extensions/lbaas/pools/results.go
@@ -1,8 +1,6 @@
package pools
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -68,12 +66,8 @@
// the end of a page and the pager seeks to traverse over a new one. In order
// to do this, it needs to construct the next page's URL.
func (p PoolPage) NextPageURL() (string, error) {
- type link struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- }
type resp struct {
- Links []link `mapstructure:"pools_links"`
+ Links []gophercloud.Link `mapstructure:"pools_links"`
}
var r resp
@@ -82,17 +76,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)
}
// IsEmpty checks whether a PoolPage struct is empty.
@@ -113,11 +97,8 @@
}
err := mapstructure.Decode(page.(PoolPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.Pools, nil
+ return resp.Pools, err
}
type commonResult struct {
@@ -135,11 +116,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron pool: %v", err)
- }
- return res.Pool, nil
+ return res.Pool, err
}
// CreateResult represents the result of a create operation.
diff --git a/openstack/networking/v2/extensions/lbaas/vips/results.go b/openstack/networking/v2/extensions/lbaas/vips/results.go
index 62efe09..b1a09e9 100644
--- a/openstack/networking/v2/extensions/lbaas/vips/results.go
+++ b/openstack/networking/v2/extensions/lbaas/vips/results.go
@@ -1,8 +1,6 @@
package vips
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -93,12 +91,8 @@
// the end of a page and the pager seeks to traverse over a new one. In order
// to do this, it needs to construct the next page's URL.
func (p VIPPage) NextPageURL() (string, error) {
- type link struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- }
type resp struct {
- Links []link `mapstructure:"vips_links"`
+ Links []gophercloud.Link `mapstructure:"vips_links"`
}
var r resp
@@ -107,17 +101,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)
}
// IsEmpty checks whether a RouterPage struct is empty.
@@ -138,11 +122,8 @@
}
err := mapstructure.Decode(page.(VIPPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.VIPs, nil
+ return resp.VIPs, err
}
type commonResult struct {
@@ -160,11 +141,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron Virtual IP: %v", err)
- }
- return res.VirtualIP, nil
+ return res.VirtualIP, err
}
// CreateResult represents the result of a create operation.
diff --git a/openstack/networking/v2/extensions/provider/results.go b/openstack/networking/v2/extensions/provider/results.go
index a20b259..8fc21b4 100755
--- a/openstack/networking/v2/extensions/provider/results.go
+++ b/openstack/networking/v2/extensions/provider/results.go
@@ -1,8 +1,6 @@
package provider
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud/openstack/networking/v2/networks"
"github.com/rackspace/gophercloud/pagination"
@@ -70,14 +68,14 @@
if r.Err != nil {
return nil, r.Err
}
+
var res struct {
Network *NetworkExtAttrs `json:"network"`
}
+
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron network: %v", err)
- }
- return res.Network, nil
+
+ return res.Network, err
}
// ExtractCreate decorates a CreateResult struct returned from a networks.Create()
@@ -86,14 +84,14 @@
if r.Err != nil {
return nil, r.Err
}
+
var res struct {
Network *NetworkExtAttrs `json:"network"`
}
+
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron network: %v", err)
- }
- return res.Network, nil
+
+ return res.Network, err
}
// ExtractUpdate decorates a UpdateResult struct returned from a
@@ -102,14 +100,14 @@
if r.Err != nil {
return nil, r.Err
}
+
var res struct {
Network *NetworkExtAttrs `json:"network"`
}
+
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron network: %v", err)
- }
- return res.Network, nil
+
+ return res.Network, err
}
// ExtractList accepts a Page struct, specifically a NetworkPage struct, and
@@ -121,9 +119,6 @@
}
err := mapstructure.Decode(page.(networks.NetworkPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.Networks, nil
+ return resp.Networks, err
}
diff --git a/openstack/networking/v2/extensions/security/groups/results.go b/openstack/networking/v2/extensions/security/groups/results.go
index 6db613e..617d690 100644
--- a/openstack/networking/v2/extensions/security/groups/results.go
+++ b/openstack/networking/v2/extensions/security/groups/results.go
@@ -1,8 +1,6 @@
package groups
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules"
@@ -40,12 +38,8 @@
// reached the end of a page and the pager seeks to traverse over a new one. In
// order to do this, it needs to construct the next page's URL.
func (p SecGroupPage) NextPageURL() (string, error) {
- type link struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- }
type resp struct {
- Links []link `mapstructure:"security_groups_links"`
+ Links []gophercloud.Link `mapstructure:"security_groups_links"`
}
var r resp
@@ -54,17 +48,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)
}
// IsEmpty checks whether a SecGroupPage struct is empty.
@@ -85,11 +69,8 @@
}
err := mapstructure.Decode(page.(SecGroupPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.SecGroups, nil
+ return resp.SecGroups, err
}
type commonResult struct {
@@ -107,11 +88,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron secgroup: %v", err)
- }
- return res.SecGroup, nil
+ return res.SecGroup, err
}
// CreateResult represents the result of a create operation.
diff --git a/openstack/networking/v2/extensions/security/rules/results.go b/openstack/networking/v2/extensions/security/rules/results.go
index 13d5c7d..ca8435e 100644
--- a/openstack/networking/v2/extensions/security/rules/results.go
+++ b/openstack/networking/v2/extensions/security/rules/results.go
@@ -1,8 +1,6 @@
package rules
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -65,12 +63,8 @@
// reached the end of a page and the pager seeks to traverse over a new one. In
// order to do this, it needs to construct the next page's URL.
func (p SecGroupRulePage) NextPageURL() (string, error) {
- type link struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- }
type resp struct {
- Links []link `mapstructure:"security_group_rules_links"`
+ Links []gophercloud.Link `mapstructure:"security_group_rules_links"`
}
var r resp
@@ -79,17 +73,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)
}
// IsEmpty checks whether a SecGroupRulePage struct is empty.
@@ -110,11 +94,8 @@
}
err := mapstructure.Decode(page.(SecGroupRulePage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.SecGroupRules, nil
+ return resp.SecGroupRules, err
}
type commonResult struct {
@@ -132,11 +113,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron SecGroupRule: %v", err)
- }
- return res.SecGroupRule, nil
+ return res.SecGroupRule, err
}
// CreateResult represents the result of a create operation.
diff --git a/openstack/networking/v2/networks/results.go b/openstack/networking/v2/networks/results.go
index 2dbd55f..e605fcf 100644
--- a/openstack/networking/v2/networks/results.go
+++ b/openstack/networking/v2/networks/results.go
@@ -1,8 +1,6 @@
package networks
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -23,11 +21,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron network: %v", err)
- }
- return res.Network, nil
+ return res.Network, err
}
// CreateResult represents the result of a create operation.
@@ -83,12 +78,8 @@
// the end of a page and the pager seeks to traverse over a new one. In order
// to do this, it needs to construct the next page's URL.
func (p NetworkPage) NextPageURL() (string, error) {
- type link struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- }
type resp struct {
- Links []link `mapstructure:"networks_links"`
+ Links []gophercloud.Link `mapstructure:"networks_links"`
}
var r resp
@@ -97,17 +88,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)
}
// IsEmpty checks whether a NetworkPage struct is empty.
@@ -128,9 +109,6 @@
}
err := mapstructure.Decode(page.(NetworkPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.Networks, nil
+ return resp.Networks, err
}
diff --git a/openstack/networking/v2/ports/results.go b/openstack/networking/v2/ports/results.go
index 91118a4..cedd658 100644
--- a/openstack/networking/v2/ports/results.go
+++ b/openstack/networking/v2/ports/results.go
@@ -1,8 +1,6 @@
package ports
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -23,11 +21,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron port: %v", err)
- }
- return res.Port, nil
+ return res.Port, err
}
// CreateResult represents the result of a create operation.
@@ -94,10 +89,7 @@
// to do this, it needs to construct the next page's URL.
func (p PortPage) NextPageURL() (string, error) {
type resp struct {
- Links []struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- } `mapstructure:"ports_links"`
+ Links []gophercloud.Link `mapstructure:"ports_links"`
}
var r resp
@@ -106,17 +98,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)
}
// IsEmpty checks whether a PortPage struct is empty.
@@ -137,9 +119,6 @@
}
err := mapstructure.Decode(page.(PortPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.Ports, nil
+ return resp.Ports, err
}
diff --git a/openstack/networking/v2/subnets/results.go b/openstack/networking/v2/subnets/results.go
index 5c5744c..3c9ef71 100644
--- a/openstack/networking/v2/subnets/results.go
+++ b/openstack/networking/v2/subnets/results.go
@@ -1,8 +1,6 @@
package subnets
import (
- "fmt"
-
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
@@ -23,11 +21,8 @@
}
err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Neutron subnet: %v", err)
- }
- return res.Subnet, nil
+ return res.Subnet, err
}
// CreateResult represents the result of a create operation.
@@ -99,12 +94,8 @@
// the end of a page and the pager seeks to traverse over a new one. In order
// to do this, it needs to construct the next page's URL.
func (p SubnetPage) NextPageURL() (string, error) {
- type link struct {
- Href string `mapstructure:"href"`
- Rel string `mapstructure:"rel"`
- }
type resp struct {
- Links []link `mapstructure:"subnets_links"`
+ Links []gophercloud.Link `mapstructure:"subnets_links"`
}
var r resp
@@ -113,17 +104,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)
}
// IsEmpty checks whether a SubnetPage struct is empty.
@@ -144,9 +125,6 @@
}
err := mapstructure.Decode(page.(SubnetPage).Body, &resp)
- if err != nil {
- return nil, err
- }
- return resp.Subnets, nil
+ return resp.Subnets, err
}