db: fix flavor id parsing (#197)
* Flavor IDs returned with instances are always strings
* Flavor IDs returned with flavors are integers or null, there is a
str_id parameter that contains the ID in string format
diff --git a/openstack/db/v1/instances/results.go b/openstack/db/v1/instances/results.go
index 6d60e86..b26fb29 100644
--- a/openstack/db/v1/instances/results.go
+++ b/openstack/db/v1/instances/results.go
@@ -6,7 +6,6 @@
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/db/v1/datastores"
- "github.com/gophercloud/gophercloud/openstack/db/v1/flavors"
"github.com/gophercloud/gophercloud/openstack/db/v1/users"
"github.com/gophercloud/gophercloud/pagination"
)
@@ -19,6 +18,14 @@
Used float64
}
+// Flavor represents (virtual) hardware configurations for server resources in a region.
+type Flavor struct {
+ // The flavor's unique identifier.
+ ID string
+ // Links to access the flavor.
+ Links []gophercloud.Link
+}
+
// Instance represents a remote MySQL instance.
type Instance struct {
// Indicates the datetime that the instance was created
@@ -28,7 +35,7 @@
Updated time.Time `json:"-"`
// Indicates the hardware flavor the instance uses.
- Flavor flavors.Flavor
+ Flavor Flavor
// A DNS-resolvable hostname associated with the database instance (rather
// than an IPv4 address). Since the hostname always resolves to the correct
diff --git a/openstack/db/v1/instances/testing/fixtures.go b/openstack/db/v1/instances/testing/fixtures.go
index 8603e98..79ee9c3 100644
--- a/openstack/db/v1/instances/testing/fixtures.go
+++ b/openstack/db/v1/instances/testing/fixtures.go
@@ -7,7 +7,6 @@
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/db/v1/datastores"
- "github.com/gophercloud/gophercloud/openstack/db/v1/flavors"
"github.com/gophercloud/gophercloud/openstack/db/v1/instances"
"github.com/gophercloud/gophercloud/testhelper/fixture"
)
@@ -25,7 +24,7 @@
"version": "5.6"
},
"flavor": {
- "id": 1,
+ "id": "1",
"links": [
{
"href": "https://my-openstack.com/v1.0/1234/flavors/1",
@@ -112,8 +111,8 @@
var expectedInstance = instances.Instance{
Created: timeVal,
Updated: timeVal,
- Flavor: flavors.Flavor{
- ID: 1,
+ Flavor: instances.Flavor{
+ ID: "1",
Links: []gophercloud.Link{
{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "self"},
{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "bookmark"},