remove mapstructure from blockstorage,cdn,compute,db pkgs
diff --git a/openstack/compute/v2/extensions/networks/fixtures.go b/openstack/compute/v2/extensions/networks/fixtures.go
index f94f331..ffa4282 100644
--- a/openstack/compute/v2/extensions/networks/fixtures.go
+++ b/openstack/compute/v2/extensions/networks/fixtures.go
@@ -8,6 +8,7 @@
"testing"
"time"
+ "github.com/gophercloud/gophercloud"
th "github.com/gophercloud/gophercloud/testhelper"
"github.com/gophercloud/gophercloud/testhelper/client"
)
@@ -22,9 +23,8 @@
"broadcast": "10.0.0.7",
"cidr": "10.0.0.0/29",
"cidr_v6": null,
- "created_at": "2011-08-15 06:19:19.387525",
+ "created_at": "2011-08-15T06:19:19.387525",
"deleted": false,
- "deleted_at": null,
"dhcp_start": "10.0.0.3",
"dns1": null,
"dns2": null,
@@ -40,7 +40,7 @@
"priority": null,
"project_id": "1234",
"rxtx_base": null,
- "updated_at": "2011-08-16 09:26:13.048257",
+ "updated_at": "2011-08-16T09:26:13.048257",
"vlan": 100,
"vpn_private_address": "10.0.0.2",
"vpn_public_address": "127.0.0.1",
@@ -52,9 +52,8 @@
"broadcast": "10.0.0.15",
"cidr": "10.0.0.10/29",
"cidr_v6": null,
- "created_at": "2011-08-15 06:19:19.885495",
+ "created_at": "2011-08-15T06:19:19.387525",
"deleted": false,
- "deleted_at": null,
"dhcp_start": "10.0.0.11",
"dns1": null,
"dns2": null,
@@ -70,7 +69,6 @@
"priority": null,
"project_id": null,
"rxtx_base": null,
- "updated_at": null,
"vlan": 101,
"vpn_private_address": "10.0.0.10",
"vpn_public_address": null,
@@ -89,9 +87,8 @@
"broadcast": "10.0.0.15",
"cidr": "10.0.0.10/29",
"cidr_v6": null,
- "created_at": "2011-08-15 06:19:19.885495",
+ "created_at": "2011-08-15T06:19:19.387525",
"deleted": false,
- "deleted_at": null,
"dhcp_start": "10.0.0.11",
"dns1": null,
"dns2": null,
@@ -107,7 +104,6 @@
"priority": null,
"project_id": null,
"rxtx_base": null,
- "updated_at": null,
"vlan": 101,
"vpn_private_address": "10.0.0.10",
"vpn_public_address": null,
@@ -124,9 +120,9 @@
Broadcast: "10.0.0.7",
CIDR: "10.0.0.0/29",
CIDRv6: "",
- CreatedAt: time.Date(2011, 8, 15, 6, 19, 19, 387525000, time.UTC),
+ CreatedAt: gophercloud.JSONRFC3339MilliNoZ(time.Date(2011, 8, 15, 6, 19, 19, 387525000, time.UTC)),
Deleted: false,
- DeletedAt: nilTime,
+ DeletedAt: gophercloud.JSONRFC3339MilliNoZ(nilTime),
DHCPStart: "10.0.0.3",
DNS1: "",
DNS2: "",
@@ -142,7 +138,7 @@
Priority: 0,
ProjectID: "1234",
RXTXBase: 0,
- UpdatedAt: time.Date(2011, 8, 16, 9, 26, 13, 48257000, time.UTC),
+ UpdatedAt: gophercloud.JSONRFC3339MilliNoZ(time.Date(2011, 8, 16, 9, 26, 13, 48257000, time.UTC)),
VLAN: 100,
VPNPrivateAddress: "10.0.0.2",
VPNPublicAddress: "127.0.0.1",
@@ -156,9 +152,9 @@
Broadcast: "10.0.0.15",
CIDR: "10.0.0.10/29",
CIDRv6: "",
- CreatedAt: time.Date(2011, 8, 15, 6, 19, 19, 885495000, time.UTC),
+ CreatedAt: gophercloud.JSONRFC3339MilliNoZ(time.Date(2011, 8, 15, 6, 19, 19, 387525000, time.UTC)),
Deleted: false,
- DeletedAt: nilTime,
+ DeletedAt: gophercloud.JSONRFC3339MilliNoZ(nilTime),
DHCPStart: "10.0.0.11",
DNS1: "",
DNS2: "",
@@ -174,7 +170,7 @@
Priority: 0,
ProjectID: "",
RXTXBase: 0,
- UpdatedAt: nilTime,
+ UpdatedAt: gophercloud.JSONRFC3339MilliNoZ(nilTime),
VLAN: 101,
VPNPrivateAddress: "10.0.0.10",
VPNPublicAddress: "",
diff --git a/openstack/compute/v2/extensions/networks/results.go b/openstack/compute/v2/extensions/networks/results.go
index 3ed7c68..d9b746e 100644
--- a/openstack/compute/v2/extensions/networks/results.go
+++ b/openstack/compute/v2/extensions/networks/results.go
@@ -1,10 +1,6 @@
package networks
import (
- "fmt"
- "time"
-
- "github.com/mitchellh/mapstructure"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
@@ -12,88 +8,88 @@
// A Network represents a nova-network that an instance communicates on
type Network struct {
// The Bridge that VIFs on this network are connected to
- Bridge string `mapstructure:"bridge"`
+ Bridge string `json:"bridge"`
// BridgeInterface is what interface is connected to the Bridge
- BridgeInterface string `mapstructure:"bridge_interface"`
+ BridgeInterface string `json:"bridge_interface"`
// The Broadcast address of the network.
- Broadcast string `mapstructure:"broadcast"`
+ Broadcast string `json:"broadcast"`
// CIDR is the IPv4 subnet.
- CIDR string `mapstructure:"cidr"`
+ CIDR string `json:"cidr"`
// CIDRv6 is the IPv6 subnet.
- CIDRv6 string `mapstructure:"cidr_v6"`
+ CIDRv6 string `json:"cidr_v6"`
// CreatedAt is when the network was created..
- CreatedAt time.Time `mapstructure:"-"`
+ CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at,omitempty"`
// Deleted shows if the network has been deleted.
- Deleted bool `mapstructure:"deleted"`
+ Deleted bool `json:"deleted"`
// DeletedAt is the time when the network was deleted.
- DeletedAt time.Time `mapstructure:"-"`
+ DeletedAt gophercloud.JSONRFC3339MilliNoZ `json:"deleted_at,omitempty"`
// DHCPStart is the start of the DHCP address range.
- DHCPStart string `mapstructure:"dhcp_start"`
+ DHCPStart string `json:"dhcp_start"`
// DNS1 is the first DNS server to use through DHCP.
- DNS1 string `mapstructure:"dns_1"`
+ DNS1 string `json:"dns_1"`
// DNS2 is the first DNS server to use through DHCP.
- DNS2 string `mapstructure:"dns_2"`
+ DNS2 string `json:"dns_2"`
// Gateway is the network gateway.
- Gateway string `mapstructure:"gateway"`
+ Gateway string `json:"gateway"`
// Gatewayv6 is the IPv6 network gateway.
- Gatewayv6 string `mapstructure:"gateway_v6"`
+ Gatewayv6 string `json:"gateway_v6"`
// Host is the host that the network service is running on.
- Host string `mapstructure:"host"`
+ Host string `json:"host"`
// ID is the UUID of the network.
- ID string `mapstructure:"id"`
+ ID string `json:"id"`
// Injected determines if network information is injected into the host.
- Injected bool `mapstructure:"injected"`
+ Injected bool `json:"injected"`
// Label is the common name that the network has..
- Label string `mapstructure:"label"`
+ Label string `json:"label"`
// MultiHost is if multi-host networking is enablec..
- MultiHost bool `mapstructure:"multi_host"`
+ MultiHost bool `json:"multi_host"`
// Netmask is the network netmask.
- Netmask string `mapstructure:"netmask"`
+ Netmask string `json:"netmask"`
// Netmaskv6 is the IPv6 netmask.
- Netmaskv6 string `mapstructure:"netmask_v6"`
+ Netmaskv6 string `json:"netmask_v6"`
// Priority is the network interface priority.
- Priority int `mapstructure:"priority"`
+ Priority int `json:"priority"`
// ProjectID is the project associated with this network.
- ProjectID string `mapstructure:"project_id"`
+ ProjectID string `json:"project_id"`
// RXTXBase configures bandwidth entitlement.
- RXTXBase int `mapstructure:"rxtx_base"`
+ RXTXBase int `json:"rxtx_base"`
// UpdatedAt is the time when the network was last updated.
- UpdatedAt time.Time `mapstructure:"-"`
+ UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at,omitempty"`
// VLAN is the vlan this network runs on.
- VLAN int `mapstructure:"vlan"`
+ VLAN int `json:"vlan"`
// VPNPrivateAddress is the private address of the CloudPipe VPN.
- VPNPrivateAddress string `mapstructure:"vpn_private_address"`
+ VPNPrivateAddress string `json:"vpn_private_address"`
// VPNPublicAddress is the public address of the CloudPipe VPN.
- VPNPublicAddress string `mapstructure:"vpn_public_address"`
+ VPNPublicAddress string `json:"vpn_public_address"`
// VPNPublicPort is the port of the CloudPipe VPN.
- VPNPublicPort int `mapstructure:"vpn_public_port"`
+ VPNPublicPort int `json:"vpn_public_port"`
}
// NetworkPage stores a single, only page of Networks
@@ -110,51 +106,12 @@
// ExtractNetworks interprets a page of results as a slice of Networks
func ExtractNetworks(page pagination.Page) ([]Network, error) {
- var res struct {
- Networks []Network `mapstructure:"networks"`
+ r := page.(NetworkPage)
+ var s struct {
+ Networks []Network `json:"networks"`
}
-
- err := mapstructure.Decode(page.(NetworkPage).Body, &res)
-
- var rawNetworks []interface{}
- body := page.(NetworkPage).Body
- switch body.(type) {
- case map[string]interface{}:
- rawNetworks = body.(map[string]interface{})["networks"].([]interface{})
- case map[string][]interface{}:
- rawNetworks = body.(map[string][]interface{})["networks"]
- default:
- return res.Networks, fmt.Errorf("Unknown type")
- }
-
- for i := range rawNetworks {
- thisNetwork := rawNetworks[i].(map[string]interface{})
- if t, ok := thisNetwork["created_at"].(string); ok && t != "" {
- createdAt, err := time.Parse("2006-01-02 15:04:05.000000", t)
- if err != nil {
- return res.Networks, err
- }
- res.Networks[i].CreatedAt = createdAt
- }
-
- if t, ok := thisNetwork["updated_at"].(string); ok && t != "" {
- updatedAt, err := time.Parse("2006-01-02 15:04:05.000000", t)
- if err != nil {
- return res.Networks, err
- }
- res.Networks[i].UpdatedAt = updatedAt
- }
-
- if t, ok := thisNetwork["deleted_at"].(string); ok && t != "" {
- deletedAt, err := time.Parse("2006-01-02 15:04:05.000000", t)
- if err != nil {
- return res.Networks, err
- }
- res.Networks[i].DeletedAt = deletedAt
- }
- }
-
- return res.Networks, err
+ err := r.ExtractInto(&s)
+ return s.Networks, err
}
type NetworkResult struct {
@@ -164,55 +121,11 @@
// Extract is a method that attempts to interpret any Network resource
// response as a Network struct.
func (r NetworkResult) Extract() (*Network, error) {
- if r.Err != nil {
- return nil, r.Err
+ var s struct {
+ Network *Network `json:"network"`
}
-
- var res struct {
- Network *Network `json:"network" mapstructure:"network"`
- }
-
- config := &mapstructure.DecoderConfig{
- Result: &res,
- WeaklyTypedInput: true,
- }
- decoder, err := mapstructure.NewDecoder(config)
- if err != nil {
- return nil, err
- }
-
- if err := decoder.Decode(r.Body); err != nil {
- return nil, err
- }
-
- b := r.Body.(map[string]interface{})["network"].(map[string]interface{})
-
- if t, ok := b["created_at"].(string); ok && t != "" {
- createdAt, err := time.Parse("2006-01-02 15:04:05.000000", t)
- if err != nil {
- return res.Network, err
- }
- res.Network.CreatedAt = createdAt
- }
-
- if t, ok := b["updated_at"].(string); ok && t != "" {
- updatedAt, err := time.Parse("2006-01-02 15:04:05.000000", t)
- if err != nil {
- return res.Network, err
- }
- res.Network.UpdatedAt = updatedAt
- }
-
- if t, ok := b["deleted_at"].(string); ok && t != "" {
- deletedAt, err := time.Parse("2006-01-02 15:04:05.000000", t)
- if err != nil {
- return res.Network, err
- }
- res.Network.DeletedAt = deletedAt
- }
-
- return res.Network, err
-
+ err := r.ExtractInto(&s)
+ return s.Network, err
}
// GetResult is the response from a Get operation. Call its Extract method to interpret it