Merge pull request #59821 from dims/update-latest-gophercloud-1.10

Automatic merge from submit-queue (batch tested with PRs 59634, 59821, 57850, 59916, 60032). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Update to latest gophercloud/gophercloud for 1.10

**What this PR does / why we need it**:

Looks like we end up with just the following change:
https://github.com/gophercloud/gophercloud/pull/730
(Prevent Recursive BuildRequestBody)

The full set of changes between the old and new SHA are here:
8e59687aa4...6da026c32e


**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2018-02-20 12:39:34 -08:00 committed by GitHub
commit 7725425522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 188 additions and 43 deletions

60
Godeps/Godeps.json generated
View File

@ -1741,123 +1741,123 @@
},
{
"ImportPath": "github.com/gophercloud/gophercloud",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumes",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/common/extensions",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/compute/v2/images",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/compute/v2/servers",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/trusts",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/listeners",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/loadbalancers",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/monitors",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/pools",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/networks",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/networking/v2/ports",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/utils",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/pagination",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gorilla/context",

View File

@ -136,31 +136,31 @@
},
{
"ImportPath": "github.com/gophercloud/gophercloud",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/openstack/utils",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/gophercloud/gophercloud/pagination",
"Rev": "8e59687aa4b27ab22a0bf3295f1e165ff7bd5f97"
"Rev": "6da026c32e2d622cc242d32984259c77237aefe1"
},
{
"ImportPath": "github.com/hashicorp/golang-lru",

View File

@ -73,6 +73,19 @@ Example to Grant Access to a Flavor
panic(err)
}
Example to Remove/Revoke Access to a Flavor
flavorID := "e91758d6-a54a-4778-ad72-0c73a1cb695b"
accessOpts := flavors.RemoveAccessOpts{
Tenant: "15153a0979884b59b0592248ef947921",
}
accessList, err := flavors.RemoveAccess(computeClient, flavor.ID, accessOpts).Extract()
if err != nil {
panic(err)
}
Example to Create Extra Specs for a Flavor
flavorID := "e91758d6-a54a-4778-ad72-0c73a1cb695b"
@ -99,5 +112,26 @@ Example to Get Extra Specs for a Flavor
fmt.Printf("%+v", extraSpecs)
Example to Update Extra Specs for a Flavor
flavorID := "e91758d6-a54a-4778-ad72-0c73a1cb695b"
updateOpts := flavors.ExtraSpecsOpts{
"hw:cpu_thread_policy": "CPU-THREAD-POLICY-UPDATED",
}
updatedExtraSpec, err := flavors.UpdateExtraSpec(computeClient, flavorID, updateOpts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v", updatedExtraSpec)
Example to Delete an Extra Spec for a Flavor
flavorID := "e91758d6-a54a-4778-ad72-0c73a1cb695b"
err := flavors.DeleteExtraSpec(computeClient, flavorID, "hw:cpu_thread_policy").ExtractErr()
if err != nil {
panic(err)
}
*/
package flavors

View File

@ -165,7 +165,7 @@ func ListAccesses(client *gophercloud.ServiceClient, id string) pagination.Pager
// AddAccessOptsBuilder allows extensions to add additional parameters to the
// AddAccess requests.
type AddAccessOptsBuilder interface {
ToAddAccessMap() (map[string]interface{}, error)
ToFlavorAddAccessMap() (map[string]interface{}, error)
}
// AddAccessOpts represents options for adding access to a flavor.
@ -174,14 +174,44 @@ type AddAccessOpts struct {
Tenant string `json:"tenant"`
}
// ToAddAccessMap constructs a request body from AddAccessOpts.
func (opts AddAccessOpts) ToAddAccessMap() (map[string]interface{}, error) {
// ToFlavorAddAccessMap constructs a request body from AddAccessOpts.
func (opts AddAccessOpts) ToFlavorAddAccessMap() (map[string]interface{}, error) {
return gophercloud.BuildRequestBody(opts, "addTenantAccess")
}
// AddAccess grants a tenant/project access to a flavor.
func AddAccess(client *gophercloud.ServiceClient, id string, opts AddAccessOptsBuilder) (r AddAccessResult) {
b, err := opts.ToAddAccessMap()
b, err := opts.ToFlavorAddAccessMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Post(accessActionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
return
}
// RemoveAccessOptsBuilder allows extensions to add additional parameters to the
// RemoveAccess requests.
type RemoveAccessOptsBuilder interface {
ToFlavorRemoveAccessMap() (map[string]interface{}, error)
}
// RemoveAccessOpts represents options for removing access to a flavor.
type RemoveAccessOpts struct {
// Tenant is the project/tenant ID to grant access.
Tenant string `json:"tenant"`
}
// ToFlavorRemoveAccessMap constructs a request body from RemoveAccessOpts.
func (opts RemoveAccessOpts) ToFlavorRemoveAccessMap() (map[string]interface{}, error) {
return gophercloud.BuildRequestBody(opts, "removeTenantAccess")
}
// RemoveAccess removes/revokes a tenant/project access to a flavor.
func RemoveAccess(client *gophercloud.ServiceClient, id string, opts RemoveAccessOptsBuilder) (r RemoveAccessResult) {
b, err := opts.ToFlavorRemoveAccessMap()
if err != nil {
r.Err = err
return
@ -231,6 +261,52 @@ func CreateExtraSpecs(client *gophercloud.ServiceClient, flavorID string, opts C
return
}
// UpdateExtraSpecOptsBuilder allows extensions to add additional parameters to the
// Update request.
type UpdateExtraSpecOptsBuilder interface {
ToExtraSpecUpdateMap() (map[string]string, string, error)
}
// ToExtraSpecUpdateMap assembles a body for an Update request based on the
// contents of a ExtraSpecOpts.
func (opts ExtraSpecsOpts) ToExtraSpecUpdateMap() (map[string]string, string, error) {
if len(opts) != 1 {
err := gophercloud.ErrInvalidInput{}
err.Argument = "flavors.ExtraSpecOpts"
err.Info = "Must have 1 and only one key-value pair"
return nil, "", err
}
var key string
for k := range opts {
key = k
}
return opts, key, nil
}
// UpdateExtraSpec will updates the value of the specified flavor's extra spec for the key in opts.
func UpdateExtraSpec(client *gophercloud.ServiceClient, flavorID string, opts UpdateExtraSpecOptsBuilder) (r UpdateExtraSpecResult) {
b, key, err := opts.ToExtraSpecUpdateMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Put(extraSpecUpdateURL(client, flavorID, key), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
return
}
// DeleteExtraSpec will delete the key-value pair with the given key for the given
// flavor ID.
func DeleteExtraSpec(client *gophercloud.ServiceClient, flavorID, key string) (r DeleteExtraSpecResult) {
_, r.Err = client.Delete(extraSpecDeleteURL(client, flavorID, key), &gophercloud.RequestOpts{
OkCodes: []int{200},
})
return
}
// IDFromName is a convienience function that returns a flavor's ID given its
// name.
func IDFromName(client *gophercloud.ServiceClient, name string) (string, error) {

View File

@ -66,6 +66,9 @@ type Flavor struct {
// IsPublic indicates whether the flavor is public.
IsPublic bool `json:"os-flavor-access:is_public"`
// Ephemeral is the amount of ephemeral disk space, measured in GB.
Ephemeral int `json:"OS-FLV-EXT-DATA:ephemeral"`
}
func (r *Flavor) UnmarshalJSON(b []byte) error {
@ -158,12 +161,18 @@ type accessResult struct {
gophercloud.Result
}
// AddAccessResult is the response of an AddAccess operations. Call its
// AddAccessResult is the response of an AddAccess operation. Call its
// Extract method to interpret it as a slice of FlavorAccess.
type AddAccessResult struct {
accessResult
}
// RemoveAccessResult is the response of a RemoveAccess operation. Call its
// Extract method to interpret it as a slice of FlavorAccess.
type RemoveAccessResult struct {
accessResult
}
// Extract provides access to the result of an access create or delete.
// The result will be all accesses that the flavor has.
func (r accessResult) Extract() ([]FlavorAccess, error) {
@ -223,6 +232,18 @@ type GetExtraSpecResult struct {
extraSpecResult
}
// UpdateExtraSpecResult contains the result of an Update operation. Call its
// Extract method to interpret it as a map[string]interface.
type UpdateExtraSpecResult struct {
extraSpecResult
}
// DeleteExtraSpecResult contains the result of a Delete operation. Call its
// ExtractErr method to determine if the call succeeded or failed.
type DeleteExtraSpecResult struct {
gophercloud.ErrResult
}
// Extract interprets any extraSpecResult as an ExtraSpec, if possible.
func (r extraSpecResult) Extract() (map[string]string, error) {
var s map[string]string

View File

@ -39,3 +39,11 @@ func extraSpecsGetURL(client *gophercloud.ServiceClient, id, key string) string
func extraSpecsCreateURL(client *gophercloud.ServiceClient, id string) string {
return client.ServiceURL("flavors", id, "os-extra_specs")
}
func extraSpecUpdateURL(client *gophercloud.ServiceClient, id, key string) string {
return client.ServiceURL("flavors", id, "os-extra_specs", key)
}
func extraSpecDeleteURL(client *gophercloud.ServiceClient, id, key string) string {
return client.ServiceURL("flavors", id, "os-extra_specs", key)
}

View File

@ -53,6 +53,7 @@ type CreateOpts struct {
FloatingIP string `json:"floating_ip_address,omitempty"`
PortID string `json:"port_id,omitempty"`
FixedIP string `json:"fixed_ip_address,omitempty"`
SubnetID string `json:"subnet_id,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
}

View File

@ -115,10 +115,15 @@ func BuildRequestBody(opts interface{}, parent string) (map[string]interface{},
}
}
jsonTag := f.Tag.Get("json")
if jsonTag == "-" {
continue
}
if v.Kind() == reflect.Struct || (v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Struct) {
if zero {
//fmt.Printf("value before change: %+v\n", optsValue.Field(i))
if jsonTag := f.Tag.Get("json"); jsonTag != "" {
if jsonTag != "" {
jsonTagPieces := strings.Split(jsonTag, ",")
if len(jsonTagPieces) > 1 && jsonTagPieces[1] == "omitempty" {
if v.CanSet() {