From 47442f1c57c0c12d3679e265a3a58c3ca3079a69 Mon Sep 17 00:00:00 2001 From: Di Xu Date: Mon, 24 Apr 2017 09:04:25 +0000 Subject: [PATCH] update gophercloud that fixed code format mainly to include #265(https://github.com/gophercloud/gophercloud/pull/265) --- Godeps/Godeps.json | 60 +++++++++---------- .../src/k8s.io/apiserver/Godeps/Godeps.json | 14 ++--- .../gophercloud/gophercloud/README.md | 2 +- .../gophercloud/gophercloud/auth_options.go | 9 ++- .../github.com/gophercloud/gophercloud/doc.go | 8 ++- .../blockstorage/v1/apiversions/urls.go | 2 +- .../gophercloud/openstack/client.go | 13 ++++ .../openstack/compute/v2/flavors/requests.go | 41 +++++++++++++ .../openstack/compute/v2/flavors/results.go | 47 +++++++-------- .../openstack/compute/v2/flavors/urls.go | 4 ++ .../openstack/compute/v2/images/results.go | 4 +- .../openstack/compute/v2/servers/requests.go | 3 +- .../openstack/compute/v2/servers/results.go | 22 ++++--- .../extensions/layer3/floatingips/requests.go | 1 + .../extensions/layer3/floatingips/results.go | 3 + .../gophercloud/pagination/pager.go | 21 +++---- 16 files changed, 162 insertions(+), 92 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index f48b66ff90c..a7dc3e38aa7 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1449,123 +1449,123 @@ }, { "ImportPath": "github.com/gophercloud/gophercloud", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/apiversions", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumes", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/common/extensions", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/compute/v2/images", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/compute/v2/servers", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/trusts", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/members", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/monitors", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/pools", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/vips", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/listeners", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/loadbalancers", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/monitors", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/pools", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/ports", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/utils", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/pagination", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gorilla/context", diff --git a/staging/src/k8s.io/apiserver/Godeps/Godeps.json b/staging/src/k8s.io/apiserver/Godeps/Godeps.json index 3be8ea220d7..abe0805e9a7 100644 --- a/staging/src/k8s.io/apiserver/Godeps/Godeps.json +++ b/staging/src/k8s.io/apiserver/Godeps/Godeps.json @@ -384,31 +384,31 @@ }, { "ImportPath": "github.com/gophercloud/gophercloud", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/openstack/utils", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/gophercloud/gophercloud/pagination", - "Rev": "b06120d13e262ceaf890ef38ee30898813696af0" + "Rev": "9a5595b8ffe429439c63781cdc312c254e4ad990" }, { "ImportPath": "github.com/grpc-ecosystem/go-grpc-prometheus", diff --git a/vendor/github.com/gophercloud/gophercloud/README.md b/vendor/github.com/gophercloud/gophercloud/README.md index 8d8d0a5c64e..60ca479de89 100644 --- a/vendor/github.com/gophercloud/gophercloud/README.md +++ b/vendor/github.com/gophercloud/gophercloud/README.md @@ -74,7 +74,7 @@ import ( // Option 1: Pass in the values yourself opts := gophercloud.AuthOptions{ - IdentityEndpoint: "https://my-openstack.com:5000/v2.0", + IdentityEndpoint: "https://openstack.example.com:5000/v2.0", Username: "{username}", Password: "{password}", } diff --git a/vendor/github.com/gophercloud/gophercloud/auth_options.go b/vendor/github.com/gophercloud/gophercloud/auth_options.go index 3ee97dfb323..7a16131093f 100644 --- a/vendor/github.com/gophercloud/gophercloud/auth_options.go +++ b/vendor/github.com/gophercloud/gophercloud/auth_options.go @@ -1,7 +1,7 @@ package gophercloud /* -AuthOptions stores information needed to authenticate to an OpenStack cluster. +AuthOptions stores information needed to authenticate to an OpenStack Cloud. You can populate one manually, or use a provider's AuthOptionsFromEnv() function to read relevant information from the standard environment variables. Pass one to a provider's AuthenticatedClient function to authenticate and obtain a @@ -31,9 +31,16 @@ type AuthOptions struct { DomainName string `json:"name,omitempty"` // The TenantID and TenantName fields are optional for the Identity V2 API. + // The same fields are known as project_id and project_name in the Identity + // V3 API, but are collected as TenantID and TenantName here in both cases. // Some providers allow you to specify a TenantName instead of the TenantId. // Some require both. Your provider's authentication policies will determine // how these fields influence authentication. + // If DomainID or DomainName are provided, they will also apply to TenantName. + // It is not currently possible to authenticate with Username and a Domain + // and scope to a Project in a different Domain by using TenantName. To + // accomplish that, the ProjectID will need to be provided to the TenantID + // option. TenantID string `json:"tenantId,omitempty"` TenantName string `json:"tenantName,omitempty"` diff --git a/vendor/github.com/gophercloud/gophercloud/doc.go b/vendor/github.com/gophercloud/gophercloud/doc.go index fb81a9d8f17..b559516f91a 100644 --- a/vendor/github.com/gophercloud/gophercloud/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/doc.go @@ -4,11 +4,13 @@ clouds. The library has a three-level hierarchy: providers, services, and resources. Provider structs represent the service providers that offer and manage a -collection of services. Examples of providers include: OpenStack, Rackspace, -HP. These are defined like so: +collection of services. The IdentityEndpoint is typically refered to as +"auth_url" in information provided by the cloud operator. Additionally, +the cloud may refer to TenantID or TenantName as project_id and project_name. +These are defined like so: opts := gophercloud.AuthOptions{ - IdentityEndpoint: "https://my-openstack.com:5000/v2.0", + IdentityEndpoint: "https://openstack.example.com:5000/v2.0", Username: "{username}", Password: "{password}", TenantID: "{tenant_id}", diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v1/apiversions/urls.go b/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v1/apiversions/urls.go index c9cf895b133..d1861ac196d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v1/apiversions/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v1/apiversions/urls.go @@ -1,8 +1,8 @@ package apiversions import ( - "strings" "net/url" + "strings" "github.com/gophercloud/gophercloud" ) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/client.go b/vendor/github.com/gophercloud/gophercloud/openstack/client.go index 6e61944a128..2d30cc60ad9 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/client.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/client.go @@ -310,6 +310,19 @@ func NewDBV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (* return &gophercloud.ServiceClient{ProviderClient: client, Endpoint: url}, nil } +// NewDNSV2 creates a ServiceClient that may be used to access the v2 DNS service. +func NewDNSV2(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) { + eo.ApplyDefaults("dns") + url, err := client.EndpointLocator(eo) + if err != nil { + return nil, err + } + return &gophercloud.ServiceClient{ + ProviderClient: client, + Endpoint: url, + ResourceBase: url + "v2/"}, nil +} + // NewImageServiceV2 creates a ServiceClient that may be used to access the v2 image service. func NewImageServiceV2(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) { eo.ApplyDefaults("image") diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/requests.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/requests.go index ef133ff8094..d5d571c3d6f 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/requests.go @@ -54,6 +54,47 @@ func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) paginat }) } +type CreateOptsBuilder interface { + ToFlavorCreateMap() (map[string]interface{}, error) +} + +// CreateOpts is passed to Create to create a flavor +// Source: +// https://github.com/openstack/nova/blob/stable/newton/nova/api/openstack/compute/schemas/flavor_manage.py#L20 +type CreateOpts struct { + Name string `json:"name" required:"true"` + // memory size, in MBs + RAM int `json:"ram" required:"true"` + VCPUs int `json:"vcpus" required:"true"` + // disk size, in GBs + Disk *int `json:"disk" required:"true"` + ID string `json:"id,omitempty"` + // non-zero, positive + Swap *int `json:"swap,omitempty"` + RxTxFactor float64 `json:"rxtx_factor,omitempty"` + IsPublic *bool `json:"os-flavor-access:is_public,omitempty"` + // ephemeral disk size, in GBs, non-zero, positive + Ephemeral *int `json:"OS-FLV-EXT-DATA:ephemeral,omitempty"` +} + +// ToFlavorCreateMap satisfies the CreateOptsBuilder interface +func (opts *CreateOpts) ToFlavorCreateMap() (map[string]interface{}, error) { + return gophercloud.BuildRequestBody(opts, "flavor") +} + +// Create a flavor +func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { + b, err := opts.ToFlavorCreateMap() + if err != nil { + r.Err = err + return + } + _, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200, 201}, + }) + return +} + // Get instructs OpenStack to provide details on a single flavor, identified by its ID. // Use ExtractFlavor to convert its result into a Flavor. func Get(client *gophercloud.ServiceClient, id string) (r GetResult) { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/results.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/results.go index a49de0da7cd..18b84340555 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/results.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/results.go @@ -8,13 +8,21 @@ import ( "github.com/gophercloud/gophercloud/pagination" ) -// GetResult temporarily holds the response from a Get call. -type GetResult struct { +type commonResult struct { gophercloud.Result } -// Extract provides access to the individual Flavor returned by the Get function. -func (r GetResult) Extract() (*Flavor, error) { +type CreateResult struct { + commonResult +} + +// GetResult temporarily holds the response from a Get call. +type GetResult struct { + commonResult +} + +// Extract provides access to the individual Flavor returned by the Get and Create functions. +func (r commonResult) Extract() (*Flavor, error) { var s struct { Flavor *Flavor `json:"flavor"` } @@ -40,41 +48,32 @@ type Flavor struct { VCPUs int `json:"vcpus"` } -func (f *Flavor) UnmarshalJSON(b []byte) error { - var flavor struct { - ID string `json:"id"` - Disk int `json:"disk"` - RAM int `json:"ram"` - Name string `json:"name"` - RxTxFactor float64 `json:"rxtx_factor"` - Swap interface{} `json:"swap"` - VCPUs int `json:"vcpus"` +func (r *Flavor) UnmarshalJSON(b []byte) error { + type tmp Flavor + var s struct { + tmp + Swap interface{} `json:"swap"` } - err := json.Unmarshal(b, &flavor) + err := json.Unmarshal(b, &s) if err != nil { return err } - f.ID = flavor.ID - f.Disk = flavor.Disk - f.RAM = flavor.RAM - f.Name = flavor.Name - f.RxTxFactor = flavor.RxTxFactor - f.VCPUs = flavor.VCPUs + *r = Flavor(s.tmp) - switch t := flavor.Swap.(type) { + switch t := s.Swap.(type) { case float64: - f.Swap = int(t) + r.Swap = int(t) case string: switch t { case "": - f.Swap = 0 + r.Swap = 0 default: swap, err := strconv.ParseFloat(t, 64) if err != nil { return err } - f.Swap = int(swap) + r.Swap = int(swap) } } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/urls.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/urls.go index ee0dfdbe39d..2fc21796f74 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/urls.go @@ -11,3 +11,7 @@ func getURL(client *gophercloud.ServiceClient, id string) string { func listURL(client *gophercloud.ServiceClient) string { return client.ServiceURL("flavors", "detail") } + +func createURL(client *gophercloud.ServiceClient) string { + return client.ServiceURL("flavors") +} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/images/results.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/images/results.go index a55b8f160a4..f9ebc69e98d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/images/results.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/images/results.go @@ -45,8 +45,8 @@ type Image struct { Status string Updated string - - Metadata map[string]string + + Metadata map[string]interface{} } // ImagePage contains a single page of results from a List operation. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go index c79a6e6f6b8..96186373176 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go @@ -401,11 +401,10 @@ type RebuildOptsBuilder interface { // operation type RebuildOpts struct { // The server's admin password - AdminPass string `json:"adminPass" required:"true"` + AdminPass string `json:"adminPass,omitempty"` // The ID of the image you want your server to be provisioned on ImageID string `json:"imageRef"` ImageName string `json:"-"` - //ImageName string `json:"-"` // Name to set the server to Name string `json:"name,omitempty"` // AccessIPv4 [optional] provides a new IPv4 address for the instance. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/results.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/results.go index c121a6be7d6..1ae1e91c784 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/results.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/results.go @@ -19,11 +19,17 @@ type serverResult struct { // Extract interprets any serverResult as a Server, if possible. func (r serverResult) Extract() (*Server, error) { - var s struct { - Server *Server `json:"server"` - } + var s Server err := r.ExtractInto(&s) - return s.Server, err + return &s, err +} + +func (r serverResult) ExtractInto(v interface{}) error { + return r.Result.ExtractIntoStructPtr(v, "server") +} + +func ExtractServersInto(r pagination.Page, v interface{}) error { + return r.(ServerPage).Result.ExtractIntoSlicePtr(v, "servers") } // CreateResult temporarily contains the response from a Create call. @@ -221,11 +227,9 @@ func (r ServerPage) NextPageURL() (string, error) { // ExtractServers interprets the results of a single page from a List() call, producing a slice of Server entities. func ExtractServers(r pagination.Page) ([]Server, error) { - var s struct { - Servers []Server `json:"servers"` - } - err := (r.(ServerPage)).ExtractInto(&s) - return s.Servers, err + var s []Server + err := ExtractServersInto(r, &s) + return s, err } // MetadataResult contains the result of a call for (potentially) multiple key-value pairs. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/requests.go b/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/requests.go index 21a3b266c2f..83930874c5d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/requests.go @@ -21,6 +21,7 @@ type ListOpts struct { Marker string `q:"marker"` SortKey string `q:"sort_key"` SortDir string `q:"sort_dir"` + RouterID string `q:"router_id"` } // List returns a Pager which allows you to iterate over a collection of diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/results.go b/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/results.go index 838ca2ca649..29d5b5662b0 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/results.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/results.go @@ -34,6 +34,9 @@ type FloatingIP struct { // The condition of the API resource. Status string `json:"status"` + + //The ID of the router used for this Floating-IP + RouterID string `json:"router_id"` } type commonResult struct { diff --git a/vendor/github.com/gophercloud/gophercloud/pagination/pager.go b/vendor/github.com/gophercloud/gophercloud/pagination/pager.go index 1b5192ad611..6f1609ef2e3 100644 --- a/vendor/github.com/gophercloud/gophercloud/pagination/pager.go +++ b/vendor/github.com/gophercloud/gophercloud/pagination/pager.go @@ -145,27 +145,24 @@ func (p Pager) AllPages() (Page, error) { // Switch on the page body type. Recognized types are `map[string]interface{}`, // `[]byte`, and `[]interface{}`. - switch testPage.GetBody().(type) { + switch pb := testPage.GetBody().(type) { case map[string]interface{}: // key is the map key for the page body if the body type is `map[string]interface{}`. var key string // Iterate over the pages to concatenate the bodies. err = p.EachPage(func(page Page) (bool, error) { b := page.GetBody().(map[string]interface{}) - for k := range b { + for k, v := range b { // If it's a linked page, we don't want the `links`, we want the other one. if !strings.HasSuffix(k, "links") { - key = k + // check the field's type. we only want []interface{} (which is really []map[string]interface{}) + switch vt := v.(type) { + case []interface{}: + key = k + pagesSlice = append(pagesSlice, vt...) + } } } - switch keyType := b[key].(type) { - case map[string]interface{}: - pagesSlice = append(pagesSlice, keyType) - case []interface{}: - pagesSlice = append(pagesSlice, b[key].([]interface{})...) - default: - return false, fmt.Errorf("Unsupported page body type: %+v", keyType) - } return true, nil }) if err != nil { @@ -216,7 +213,7 @@ func (p Pager) AllPages() (Page, error) { default: err := gophercloud.ErrUnexpectedType{} err.Expected = "map[string]interface{}/[]byte/[]interface{}" - err.Actual = fmt.Sprintf("%v", reflect.TypeOf(testPage.GetBody())) + err.Actual = fmt.Sprintf("%T", pb) return nil, err }