Package: golang-gopkg-goose.v1 / 0.0~git20170406.3228e4f-6

0001-cherry-pick-28d991a.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From: Heather Lanigan <heather.lanigan@canonical.com>
Date: Wed, 3 May 2017 19:09:48 -0400
Subject: [PATCH] Fix bug lp:1683495,
 if nova ServerDetail.Image fails to unmarshall as a nova.Entity,
 try as a string before failing.  Added related test.

Fix goose bug 49, update expected error message in apiversion_test.so to
match past changes.
---
 client/apiversion_test.go |  2 +-
 nova/json.go              | 11 ++++++++++-
 nova/json_test.go         | 11 +++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/client/apiversion_test.go b/client/apiversion_test.go
index 636a715..8e9f332 100644
--- a/client/apiversion_test.go
+++ b/client/apiversion_test.go
@@ -74,7 +74,7 @@ func (s *localLiveSuite) makeServiceURLTests() []makeServiceURLTest {
 			version:     "q2.0",
 			parts:       []string{"foo", "bar/"},
 			success:     false,
-			err:         "strconv.ParseInt: parsing \"q2\": invalid syntax",
+			err:         "strconv.Atoi: parsing \"q2\": invalid syntax",
 		},
 		{
 			serviceType: "object-store",
diff --git a/nova/json.go b/nova/json.go
index ba5129d..e2a8cfe 100644
--- a/nova/json.go
+++ b/nova/json.go
@@ -88,7 +88,16 @@ func (entity *Entity) UnmarshalJSON(b []byte) error {
 	var je jsonEntity = jsonEntity(*entity)
 	var err error
 	if err = json.Unmarshal(b, &je); err != nil {
-		return err
+		// Related Bug lp:1683495, within the openstack compute api
+		// response to List Servers Detailed, the image object might
+		// be an empty string when you boot the server from a volume.
+		// Before failing here, let's check to see if that's the case.
+		if string(b) == "\"\"" {
+			*entity = Entity(je)
+			return nil
+		} else {
+			return err
+		}
 	}
 	if je.Id, err = getIdAsString(b, idTag); err != nil {
 		return err
diff --git a/nova/json_test.go b/nova/json_test.go
index e6b6f89..4fa140b 100644
--- a/nova/json_test.go
+++ b/nova/json_test.go
@@ -81,3 +81,14 @@ func (s *JsonSuite) TestUnmarshallRuleInfoNilStrings(c *gc.C) {
 	}
 	c.Assert(ri, gc.DeepEquals, expected)
 }
+
+func (s *JsonSuite) TestUnmarshallServerDetailImage(c *gc.C) {
+	var image nova.Entity
+	data := []byte(`""`)
+	err := json.Unmarshal(data, &image)
+	c.Assert(err, gc.IsNil)
+	expected := nova.Entity{
+		Id: "",
+	}
+	c.Assert(image, gc.DeepEquals, expected)
+}