add logic to handle AllPages result page
diff --git a/openstack/orchestration/v1/stackevents/results.go b/openstack/orchestration/v1/stackevents/results.go
index bf233ae..3c8f1da 100644
--- a/openstack/orchestration/v1/stackevents/results.go
+++ b/openstack/orchestration/v1/stackevents/results.go
@@ -1,6 +1,8 @@
package stackevents
import (
+ "fmt"
+ "reflect"
"time"
"github.com/mitchellh/mapstructure"
@@ -106,7 +108,15 @@
return nil, err
}
- events := casted.(map[string]interface{})["events"].([]interface{})
+ var events []interface{}
+ switch casted.(type) {
+ case map[string]interface{}:
+ events = casted.(map[string]interface{})["events"].([]interface{})
+ case map[string][]interface{}:
+ events = casted.(map[string][]interface{})["events"]
+ default:
+ return res.Res, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
+ }
for i, eventRaw := range events {
event := eventRaw.(map[string]interface{})
diff --git a/openstack/orchestration/v1/stackresources/results.go b/openstack/orchestration/v1/stackresources/results.go
index 13f5dd2..69f21da 100644
--- a/openstack/orchestration/v1/stackresources/results.go
+++ b/openstack/orchestration/v1/stackresources/results.go
@@ -1,6 +1,8 @@
package stackresources
import (
+ "fmt"
+ "reflect"
"time"
"github.com/mitchellh/mapstructure"
@@ -94,7 +96,15 @@
}
err := mapstructure.Decode(casted, &response)
- resources := casted.(map[string]interface{})["resources"].([]interface{})
+ var resources []interface{}
+ switch casted.(type) {
+ case map[string]interface{}:
+ resources = casted.(map[string]interface{})["resources"].([]interface{})
+ case map[string][]interface{}:
+ resources = casted.(map[string][]interface{})["resources"]
+ default:
+ return response.Resources, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
+ }
for i, resourceRaw := range resources {
resource := resourceRaw.(map[string]interface{})
diff --git a/openstack/orchestration/v1/stacks/results.go b/openstack/orchestration/v1/stacks/results.go
index ff971e8..04d3f8e 100644
--- a/openstack/orchestration/v1/stacks/results.go
+++ b/openstack/orchestration/v1/stacks/results.go
@@ -2,6 +2,8 @@
import (
"encoding/json"
+ "fmt"
+ "reflect"
"time"
"github.com/mitchellh/mapstructure"
@@ -73,6 +75,8 @@
// ExtractStacks extracts and returns a slice of ListedStack. It is used while iterating
// over a stacks.List call.
func ExtractStacks(page pagination.Page) ([]ListedStack, error) {
+ casted := page.(StackPage).Body
+
var res struct {
Stacks []ListedStack `mapstructure:"stacks"`
}
@@ -82,7 +86,16 @@
return nil, err
}
- rawStacks := (((page.(StackPage).Body).(map[string]interface{}))["stacks"]).([]interface{})
+ var rawStacks []interface{}
+ switch casted.(type) {
+ case map[string]interface{}:
+ rawStacks = casted.(map[string]interface{})["stacks"].([]interface{})
+ case map[string][]interface{}:
+ rawStacks = casted.(map[string][]interface{})["stacks"]
+ default:
+ return res.Stacks, fmt.Errorf("Unknown type: %v", reflect.TypeOf(casted))
+ }
+
for i := range rawStacks {
thisStack := (rawStacks[i]).(map[string]interface{})