Skip to content

Commit 3cda80a

Browse files
authored
Merge pull request #3346 from kayrus/routers-extract-into
[networking] add ExtractRoutersInto func helper to routers
2 parents 849d9ea + 91498be commit 3cda80a

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

  • openstack/networking/v2/extensions/layer3/routers

openstack/networking/v2/extensions/layer3/routers/results.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,14 @@ func (r RouterPage) IsEmpty() (bool, error) {
122122
// and extracts the elements into a slice of Router structs. In other words,
123123
// a generic collection is mapped into a relevant slice.
124124
func ExtractRouters(r pagination.Page) ([]Router, error) {
125-
var s struct {
126-
Routers []Router `json:"routers"`
127-
}
128-
err := (r.(RouterPage)).ExtractInto(&s)
129-
return s.Routers, err
125+
var s []Router
126+
err := ExtractRoutersInto(r, &s)
127+
return s, err
128+
}
129+
130+
// ExtractRoutersInto extracts the elements into a slice of Router structs.
131+
func ExtractRoutersInto(r pagination.Page, v any) error {
132+
return r.(RouterPage).Result.ExtractIntoSlicePtr(v, "routers")
130133
}
131134

132135
type commonResult struct {

0 commit comments

Comments
 (0)