Compute v2: Allow correct handling of Image Metadata (#285)
The Compute v2 API expects JSON values for metadata with keys of
boot_from_volume and mappings. This commit changes the Metadata
type from map[string]string to map[string]interface{} to handle
these values.
diff --git a/openstack/compute/v2/images/results.go b/openstack/compute/v2/images/results.go
index 1090327..f9ebc69 100644
--- a/openstack/compute/v2/images/results.go
+++ b/openstack/compute/v2/images/results.go
@@ -46,7 +46,7 @@
Updated string
- Metadata map[string]string
+ Metadata map[string]interface{}
}
// ImagePage contains a single page of results from a List operation.
diff --git a/openstack/compute/v2/images/testing/requests_test.go b/openstack/compute/v2/images/testing/requests_test.go
index e2d64d3..1de0303 100644
--- a/openstack/compute/v2/images/testing/requests_test.go
+++ b/openstack/compute/v2/images/testing/requests_test.go
@@ -38,7 +38,16 @@
"created": "2014-09-23T12:54:52Z",
"minDisk": 0,
"progress": 100,
- "minRam": 0
+ "minRam": 0,
+ "metadata": {
+ "architecture": "x86_64",
+ "block_device_mapping": {
+ "guest_format": null,
+ "boot_index": 0,
+ "device_name": "/dev/vda",
+ "delete_on_termination": false
+ }
+ }
},
{
"status": "ACTIVE",
@@ -81,6 +90,15 @@
MinRAM: 0,
Progress: 100,
Status: "ACTIVE",
+ Metadata: map[string]interface{}{
+ "architecture": "x86_64",
+ "block_device_mapping": map[string]interface{}{
+ "guest_format": interface{}(nil),
+ "boot_index": float64(0),
+ "device_name": "/dev/vda",
+ "delete_on_termination": false,
+ },
+ },
},
{
ID: "f90f6034-2570-4974-8351-6b49732ef2eb",
@@ -129,7 +147,16 @@
"created": "2014-09-23T12:54:52Z",
"minDisk": 0,
"progress": 100,
- "minRam": 0
+ "minRam": 0,
+ "metadata": {
+ "architecture": "x86_64",
+ "block_device_mapping": {
+ "guest_format": null,
+ "boot_index": 0,
+ "device_name": "/dev/vda",
+ "delete_on_termination": false
+ }
+ }
}
}
`)
@@ -149,6 +176,15 @@
MinDisk: 0,
Progress: 100,
MinRAM: 0,
+ Metadata: map[string]interface{}{
+ "architecture": "x86_64",
+ "block_device_mapping": map[string]interface{}{
+ "guest_format": interface{}(nil),
+ "boot_index": float64(0),
+ "device_name": "/dev/vda",
+ "delete_on_termination": false,
+ },
+ },
}
if !reflect.DeepEqual(expected, actual) {