update gophercloud deps

This commit is contained in:
Jesse Haka 2021-11-16 17:10:04 +02:00
parent e9368feab4
commit c7e0585e3a
34 changed files with 855 additions and 103 deletions

2
go.mod
View File

@ -55,7 +55,7 @@ require (
github.com/google/go-tpm v0.3.2
github.com/google/go-tpm-tools v0.3.0-beta1
github.com/google/uuid v1.2.0
github.com/gophercloud/gophercloud v0.18.0
github.com/gophercloud/gophercloud v0.23.0
github.com/hashicorp/hcl/v2 v2.10.1
github.com/hashicorp/vault/api v1.1.1
github.com/jacksontj/memberlistmesh v0.0.0-20190905163944-93462b9d2bb7

4
go.sum
View File

@ -702,8 +702,8 @@ github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2c
github.com/googleapis/gnostic v0.5.5 h1:9fHAtK0uDfpveeqqo1hkEZJcFvYXAiCN3UutL8F9xHw=
github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA=
github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8=
github.com/gophercloud/gophercloud v0.18.0 h1:V6hcuMPmjXg+js9flU8T3RIHDCjV7F5CG5GD0MRhP/w=
github.com/gophercloud/gophercloud v0.18.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
github.com/gophercloud/gophercloud v0.23.0 h1:I3P10oKlGu3DHP9PrEWMr1ya+/+3Rc9uRHNkRZ9wO7g=
github.com/gophercloud/gophercloud v0.23.0/go.mod h1:MRw6uyLj8uCGbIvBlqL7QW67t0QtNZnzydUzewo1Ioc=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU=

View File

@ -54,7 +54,7 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.1.0 // indirect
github.com/gophercloud/gophercloud v0.18.0 // indirect
github.com/gophercloud/gophercloud v0.23.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-multierror v1.1.0 // indirect

View File

@ -874,8 +874,8 @@ github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3i
github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU=
github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA=
github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8=
github.com/gophercloud/gophercloud v0.18.0 h1:V6hcuMPmjXg+js9flU8T3RIHDCjV7F5CG5GD0MRhP/w=
github.com/gophercloud/gophercloud v0.18.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
github.com/gophercloud/gophercloud v0.23.0 h1:I3P10oKlGu3DHP9PrEWMr1ya+/+3Rc9uRHNkRZ9wO7g=
github.com/gophercloud/gophercloud v0.23.0/go.mod h1:MRw6uyLj8uCGbIvBlqL7QW67t0QtNZnzydUzewo1Ioc=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU=

View File

@ -31,7 +31,7 @@ func (c *openstackCloud) GetKeypair(name string) (*keypairs.KeyPair, error) {
func getKeypair(c OpenstackCloud, name string) (*keypairs.KeyPair, error) {
var k *keypairs.KeyPair
done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) {
rs, err := keypairs.Get(c.ComputeClient(), name).Extract()
rs, err := keypairs.Get(c.ComputeClient(), name, nil).Extract()
if err != nil {
if err.Error() == ErrNotFound {
return true, nil
@ -80,7 +80,7 @@ func (c *openstackCloud) DeleteKeyPair(name string) error {
func deleteKeyPair(c OpenstackCloud, name string) error {
done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) {
err := keypairs.Delete(c.ComputeClient(), name).ExtractErr()
err := keypairs.Delete(c.ComputeClient(), name, nil).ExtractErr()
if err != nil && !isNotFound(err) {
return false, fmt.Errorf("error deleting keypair: %v", err)
}
@ -105,7 +105,7 @@ func (c *openstackCloud) ListKeypairs() ([]keypairs.KeyPair, error) {
func listKeypairs(c OpenstackCloud) ([]keypairs.KeyPair, error) {
var k []keypairs.KeyPair
done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) {
allPages, err := keypairs.List(c.ComputeClient()).AllPages()
allPages, err := keypairs.List(c.ComputeClient(), nil).AllPages()
if err != nil {
return false, fmt.Errorf("error listing keypairs: %v", err)
}

View File

@ -1,3 +1,4 @@
**/*.swp
.idea
.vscode
testing_*.coverprofile

View File

@ -7,43 +7,419 @@
nodeset: ubuntu-xenial-ut
- job:
name: gophercloud-acceptance-test
name: gophercloud-acceptance-test-base
parent: golang-test
description: |
Run gophercloud acceptance test on master branch
run: .zuul/playbooks/gophercloud-acceptance-test/run.yaml
description: |
Base job for all gophercloud acceptance tests
timeout: 18000 # 5 hours
abstract: true
nodeset: ubuntu-focal
irrelevant-files:
- ^.*\.md$
- ^LICENSE$
- job:
name: gophercloud-acceptance-test-compute
parent: gophercloud-acceptance-test-base
description: |
Run gophercloud compute acceptance test on master branch. This runs when any file is patched
except if it's doc.
vars:
# the list of all available tests can generated by:
# find acceptance/openstack -name '*_test.go' -exec dirname {} \; | sort -n | uniq -c | awk '{print $2}'
acceptance_tests:
- acceptance/openstack
- acceptance/openstack/compute/v2
- acceptance/openstack/container/v1
- acceptance/openstack/identity/v2
- acceptance/openstack/identity/v3
- acceptance/openstack/keymanager/v1
- acceptance/openstack/orchestration/v1
- acceptance/openstack/placement/v1
devstack_services:
- barbican
- heat
- zun
- job:
name: gophercloud-acceptance-test-networking
parent: gophercloud-acceptance-test-base
description: |
Run gophercloud networking acceptance test on master branch
files:
- ^.*dns.*$
- ^.*loadbalancer.*$
- ^.*networking.*$
vars:
prefetch_amphora: true
devstack_env:
OCTAVIA_AMP_IMAGE_FILE: /opt/octavia-amphora/amphora-x64-haproxy.qcow2
# the list of all available tests can generated by:
# find acceptance/openstack -name '*_test.go' -exec dirname {} \; | sort -n | uniq -c | awk '{print $2}'
acceptance_tests:
- acceptance/openstack/dns/v2
- acceptance/openstack/loadbalancer/v2
- acceptance/openstack/networking/v2
- acceptance/openstack/networking/v2/extensions
- acceptance/openstack/networking/v2/extensions/agents
- acceptance/openstack/networking/v2/extensions/dns
- acceptance/openstack/networking/v2/extensions/layer3
- acceptance/openstack/networking/v2/extensions/mtu
- acceptance/openstack/networking/v2/extensions/networkipavailabilities
- acceptance/openstack/networking/v2/extensions/portsbinding
- acceptance/openstack/networking/v2/extensions/qos/policies
- acceptance/openstack/networking/v2/extensions/qos/rules
- acceptance/openstack/networking/v2/extensions/qos/ruletypes
- acceptance/openstack/networking/v2/extensions/quotas
- acceptance/openstack/networking/v2/extensions/rbacpolicies
- acceptance/openstack/networking/v2/extensions/subnetpools
- acceptance/openstack/networking/v2/extensions/trunks
- acceptance/openstack/networking/v2/extensions/vlantransparent
devstack_services:
- designate
- neutron-ext
- octavia
- job:
name: gophercloud-acceptance-test-storage
parent: gophercloud-acceptance-test-base
description: |
Run gophercloud storage acceptance test on master branch
files:
- ^.*blockstorage.*$
- ^.*imageservice.*$
- ^.*objectstorage.*$
- ^.*sharedfilesystems.*$
vars:
acceptance_tests:
- acceptance/openstack/blockstorage
- acceptance/openstack/blockstorage/extensions
- acceptance/openstack/blockstorage/v3
- acceptance/openstack/imageservice/v2
- acceptance/openstack/objectstorage/v1
- acceptance/openstack/sharedfilesystems/v2
- acceptance/openstack/sharedfilesystems/v2/messages
devstack_services:
- manila
- job:
name: gophercloud-acceptance-test-ironic
parent: golang-test
parent: gophercloud-acceptance-test-base
description: |
Run gophercloud ironic acceptance test on master branch
run: .zuul/playbooks/gophercloud-acceptance-test-ironic/run.yaml
nodeset: ubuntu-focal
files:
- ^.*baremetal.*$
vars:
devstack_services:
- ironic
devstack_override_enabled_services: 'g-api,g-reg,q-agt,q-dhcp,q-l3,q-svc,key,mysql,rabbit,ir-api,ir-cond,s-account,s-container,s-object,s-proxy'
devstack_projects: 'openstack/ironic-python-agent-builder openstack/ironic'
acceptance_tests:
- acceptance/openstack/baremetal/v1
- job:
name: gophercloud-acceptance-test-ussuri
parent: gophercloud-acceptance-test
name: gophercloud-acceptance-test-compute-ussuri
parent: gophercloud-acceptance-test-compute
nodeset: ubuntu-bionic
description: |
Run gophercloud acceptance test on ussuri branch
Run gophercloud compute acceptance test on ussuri branch
vars:
global_env:
OS_BRANCH: stable/ussuri
- job:
name: gophercloud-acceptance-test-train
parent: gophercloud-acceptance-test
name: gophercloud-acceptance-test-networking-ussuri
parent: gophercloud-acceptance-test-networking
nodeset: ubuntu-bionic
description: |
Run gophercloud acceptance test on train branch
Run gophercloud networking acceptance test on ussuri branch
vars:
global_env:
OS_BRANCH: stable/ussuri
- job:
name: gophercloud-acceptance-test-storage-ussuri
parent: gophercloud-acceptance-test-storage
nodeset: ubuntu-bionic
description: |
Run gophercloud storage test on ussuri branch
vars:
global_env:
OS_BRANCH: stable/ussuri
- job:
name: gophercloud-acceptance-test-compute-train
parent: gophercloud-acceptance-test-compute
nodeset: ubuntu-xenial
description: |
Run gophercloud compute acceptance test on train branch
vars:
global_env:
OS_BRANCH: stable/train
- job:
name: gophercloud-acceptance-test-networking-train
parent: gophercloud-acceptance-test-networking
nodeset: ubuntu-xenial
description: |
Run gophercloud networking acceptance test on train branch
vars:
global_env:
OS_BRANCH: stable/train
- job:
name: gophercloud-acceptance-test-storage-train
parent: gophercloud-acceptance-test-storage
nodeset: ubuntu-xenial
description: |
Run gophercloud storage acceptance test on train branch
vars:
global_env:
OS_BRANCH: stable/train
- job:
name: gophercloud-acceptance-test-compute-stein
parent: gophercloud-acceptance-test-compute
nodeset: ubuntu-xenial
description: |
Run gophercloud compute acceptance test on stein branch
vars:
global_env:
OS_BRANCH: stable/stein
- job:
name: gophercloud-acceptance-test-networking-stein
parent: gophercloud-acceptance-test-networking
nodeset: ubuntu-xenial
description: |
Run gophercloud networking acceptance test on stein branch
vars:
global_env:
OS_BRANCH: stable/stein
- job:
name: gophercloud-acceptance-test-storage-stein
parent: gophercloud-acceptance-test-storage
nodeset: ubuntu-xenial
description: |
Run gophercloud storage acceptance test on stein branch
vars:
global_env:
OS_BRANCH: stable/stein
- job:
name: gophercloud-acceptance-test-compute-rocky
parent: gophercloud-acceptance-test-compute
nodeset: ubuntu-xenial
description: |
Run gophercloud compute acceptance test on rocky branch
vars:
global_env:
OS_BRANCH: stable/rocky
- job:
name: gophercloud-acceptance-test-networking-rocky
parent: gophercloud-acceptance-test-networking
nodeset: ubuntu-xenial
description: |
Run gophercloud networking acceptance test on rocky branch
vars:
global_env:
OS_BRANCH: stable/rocky
- job:
name: gophercloud-acceptance-test-storage-rocky
parent: gophercloud-acceptance-test-storage
nodeset: ubuntu-xenial
description: |
Run gophercloud storage acceptance test on rocky branch
vars:
global_env:
OS_BRANCH: stable/rocky
- job:
name: gophercloud-acceptance-test-compute-queens
parent: gophercloud-acceptance-test-compute
description: |
Run gophercloud compute acceptance test on queens branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/queens
- job:
name: gophercloud-acceptance-test-networking-queens
parent: gophercloud-acceptance-test-networking
description: |
Run gophercloud networking acceptance test on queens branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/queens
- job:
name: gophercloud-acceptance-test-storage-queens
parent: gophercloud-acceptance-test-storage
description: |
Run gophercloud storage acceptance test on queens branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/queens
# NOTE: A Pike-based devstack environment is currently
# not building correctly. This might be a temporary issue.
- job:
name: gophercloud-acceptance-test-compute-pike
parent: gophercloud-acceptance-test-compute
description: |
Run gophercloud compute acceptance test on pike branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/pike
- job:
name: gophercloud-acceptance-test-networking-pike
parent: gophercloud-acceptance-test-networking
description: |
Run gophercloud networking acceptance test on pike branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/pike
- job:
name: gophercloud-acceptance-test-storage-pike
parent: gophercloud-acceptance-test-storage
description: |
Run gophercloud storage acceptance test on pike branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/pike
- job:
name: gophercloud-acceptance-test-compute-ocata
parent: gophercloud-acceptance-test-compute
description: |
Run gophercloud compute acceptance test on ocata branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/ocata
- job:
name: gophercloud-acceptance-test-networking-ocata
parent: gophercloud-acceptance-test-networking
description: |
Run gophercloud networking acceptance test on ocata branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/ocata
- job:
name: gophercloud-acceptance-test-storage-ocata
parent: gophercloud-acceptance-test-storage
description: |
Run gophercloud storage acceptance test on ocata branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/ocata
# NOTE: A Newton-based devstack environment is currently
# not building correctly. This might be a temporary issue.
- job:
name: gophercloud-acceptance-test-compute-newton
parent: gophercloud-acceptance-test-compute
description: |
Run gophercloud compute acceptance test on newton branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/newton
- job:
name: gophercloud-acceptance-test-networking-newton
parent: gophercloud-acceptance-test-networking
description: |
Run gophercloud networking acceptance test on newton branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/newton
- job:
name: gophercloud-acceptance-test-storage-newton
parent: gophercloud-acceptance-test-storage
description: |
Run gophercloud storage acceptance test on newton branch
nodeset: ubuntu-xenial
vars:
global_env:
OS_BRANCH: stable/newton
# The following jobs are maintained because they are parents
# for gophercloud v0.4.0 acceptance tests in theopenlab/openlab-zuul-jobs.
# TODO(emilien) update the childs to use the new variants.
- job:
name: gophercloud-acceptance-test-legacy
parent: gophercloud-acceptance-test-base
description: |
THIS JOB REMAINS FOR LEGACY. Will be removed soon to be replaced by its variants.
Run gophercloud acceptance test on the master branch. This runs when any file is patched
except if it's doc.
vars:
# the list of all available tests can generated by:
# find acceptance/openstack -name '*_test.go' -exec dirname {} \; | sort -n | uniq -c | awk '{print $2}'
acceptance_tests:
- acceptance/openstack
- acceptance/openstack/blockstorage
- acceptance/openstack/blockstorage/extensions
- acceptance/openstack/blockstorage/v3
- acceptance/openstack/compute/v2
- acceptance/openstack/container/v1
- acceptance/openstack/dns/v2
- acceptance/openstack/identity/v2
- acceptance/openstack/identity/v3
- acceptance/openstack/imageservice/v2
- acceptance/openstack/keymanager/v1
- acceptance/openstack/loadbalancer/v2
- acceptance/openstack/networking/v2
- acceptance/openstack/networking/v2/extensions
- acceptance/openstack/networking/v2/extensions/agents
- acceptance/openstack/networking/v2/extensions/dns
- acceptance/openstack/networking/v2/extensions/layer3
- acceptance/openstack/networking/v2/extensions/mtu
- acceptance/openstack/networking/v2/extensions/networkipavailabilities
- acceptance/openstack/networking/v2/extensions/portsbinding
- acceptance/openstack/networking/v2/extensions/qos/policies
- acceptance/openstack/networking/v2/extensions/qos/rules
- acceptance/openstack/networking/v2/extensions/qos/ruletypes
- acceptance/openstack/networking/v2/extensions/quotas
- acceptance/openstack/networking/v2/extensions/rbacpolicies
- acceptance/openstack/networking/v2/extensions/subnetpools
- acceptance/openstack/networking/v2/extensions/trunks
- acceptance/openstack/networking/v2/extensions/vlantransparent
- acceptance/openstack/objectstorage/v1
- acceptance/openstack/orchestration/v1
- acceptance/openstack/placement/v1
- acceptance/openstack/sharedfilesystems/v2
- acceptance/openstack/sharedfilesystems/v2/messages
devstack_services:
- designate
- manila
- neutron-ext
- octavia
- zun
- job:
name: gophercloud-acceptance-test-stein
parent: gophercloud-acceptance-test
parent: gophercloud-acceptance-test-legacy
nodeset: ubuntu-xenial
description: |
Run gophercloud acceptance test on stein branch
vars:
@ -52,7 +428,8 @@
- job:
name: gophercloud-acceptance-test-rocky
parent: gophercloud-acceptance-test
parent: gophercloud-acceptance-test-legacy
nodeset: ubuntu-xenial
description: |
Run gophercloud acceptance test on rocky branch
vars:
@ -61,7 +438,7 @@
- job:
name: gophercloud-acceptance-test-queens
parent: gophercloud-acceptance-test
parent: gophercloud-acceptance-test-legacy
description: |
Run gophercloud acceptance test on queens branch
nodeset: ubuntu-xenial
@ -73,7 +450,7 @@
# not building correctly. This might be a temporary issue.
- job:
name: gophercloud-acceptance-test-pike
parent: gophercloud-acceptance-test
parent: gophercloud-acceptance-test-legacy
description: |
Run gophercloud acceptance test on pike branch
nodeset: ubuntu-xenial
@ -83,7 +460,7 @@
- job:
name: gophercloud-acceptance-test-ocata
parent: gophercloud-acceptance-test
parent: gophercloud-acceptance-test-legacy
description: |
Run gophercloud acceptance test on ocata branch
nodeset: ubuntu-xenial
@ -95,7 +472,7 @@
# not building correctly. This might be a temporary issue.
- job:
name: gophercloud-acceptance-test-newton
parent: gophercloud-acceptance-test
parent: gophercloud-acceptance-test-legacy
description: |
Run gophercloud acceptance test on newton branch
nodeset: ubuntu-xenial
@ -108,29 +485,47 @@
check:
jobs:
- gophercloud-unittest
- gophercloud-acceptance-test
- gophercloud-acceptance-test-compute
- gophercloud-acceptance-test-networking
- gophercloud-acceptance-test-storage
- gophercloud-acceptance-test-ironic
recheck-newton:
jobs:
- gophercloud-acceptance-test-newton
- gophercloud-acceptance-test-compute-newton
- gophercloud-acceptance-test-networking-newton
- gophercloud-acceptance-test-storage-newton
recheck-ocata:
jobs:
- gophercloud-acceptance-test-ocata
- gophercloud-acceptance-test-compute-ocata
- gophercloud-acceptance-test-networking-ocata
- gophercloud-acceptance-test-storage-ocata
recheck-pike:
jobs:
- gophercloud-acceptance-test-pike
- gophercloud-acceptance-test-compute-pike
- gophercloud-acceptance-test-networking-pike
- gophercloud-acceptance-test-storage-pike
recheck-queens:
jobs:
- gophercloud-acceptance-test-queens
- gophercloud-acceptance-test-compute-queens
- gophercloud-acceptance-test-networking-queens
- gophercloud-acceptance-test-storage-queens
recheck-rocky:
jobs:
- gophercloud-acceptance-test-rocky
- gophercloud-acceptance-test-compute-rocky
- gophercloud-acceptance-test-networking-rocky
- gophercloud-acceptance-test-storage-rocky
recheck-stein:
jobs:
- gophercloud-acceptance-test-stein
- gophercloud-acceptance-test-compute-stein
- gophercloud-acceptance-test-networking-stein
- gophercloud-acceptance-test-storage-stein
recheck-train:
jobs:
- gophercloud-acceptance-test-train
- gophercloud-acceptance-test-compute-train
- gophercloud-acceptance-test-networking-train
- gophercloud-acceptance-test-storage-train
recheck-ussuri:
jobs:
- gophercloud-acceptance-test-ussuri
- gophercloud-acceptance-test-compute-ussuri
- gophercloud-acceptance-test-networking-ussuri
- gophercloud-acceptance-test-storage-ussuri

View File

@ -1,4 +1,97 @@
## 0.19.0 (Unreleased)
## 0.23.0 (November 12, 2021)
IMPROVEMENTS
* Added `networking/v2/extensions/agents.ListBGPSpeakers` [GH-2229](https://github.com/gophercloud/gophercloud/pull/2229)
* Added `networking/v2/extensions/bgp/speakers.BGPSpeaker` [GH-2229](https://github.com/gophercloud/gophercloud/pull/2229)
* Added `identity/v3/roles.Project.Domain` [GH-2235](https://github.com/gophercloud/gophercloud/pull/2235)
* Added `identity/v3/roles.User.Domain` [GH-2235](https://github.com/gophercloud/gophercloud/pull/2235)
* Added `identity/v3/roles.Group.Domain` [GH-2235](https://github.com/gophercloud/gophercloud/pull/2235)
* Added `loadbalancer/v2/pools.CreateOpts.Tags` [GH-2237](https://github.com/gophercloud/gophercloud/pull/2237)
* Added `loadbalancer/v2/pools.UpdateOpts.Tags` [GH-2237](https://github.com/gophercloud/gophercloud/pull/2237)
* Added `loadbalancer/v2/pools.Pool.Tags` [GH-2237](https://github.com/gophercloud/gophercloud/pull/2237)
* Added `networking/v2/extensions/bgp/speakers.List` [GH-2238](https://github.com/gophercloud/gophercloud/pull/2238)
* Added `networking/v2/extensions/bgp/speakers.Get` [GH-2238](https://github.com/gophercloud/gophercloud/pull/2238)
* Added `compute/v2/extensions/keypairs.CreateOpts.Type` [GH-2231](https://github.com/gophercloud/gophercloud/pull/2231)
* When doing Keystone re-authentification, keep the error if it failed [GH-2259](https://github.com/gophercloud/gophercloud/pull/2259)
* Added new loadbalancer pool monitor types (TLS-HELLO, UDP-CONNECT and SCTP) [GH-2237](https://github.com/gophercloud/gophercloud/pull/2261)
## 0.22.0 (October 7, 2021)
BREAKING CHANGES
* The types of several Object Storage Update fields have been changed to pointers in order to allow the value to be unset via the HTTP headers:
* `objectstorage/v1/accounts.UpdateOpts.ContentType`
* `objectstorage/v1/accounts.UpdateOpts.DetectContentType`
* `objectstorage/v1/containers.UpdateOpts.ContainerRead`
* `objectstorage/v1/containers.UpdateOpts.ContainerSyncTo`
* `objectstorage/v1/containers.UpdateOpts.ContainerSyncKey`
* `objectstorage/v1/containers.UpdateOpts.ContainerWrite`
* `objectstorage/v1/containers.UpdateOpts.ContentType`
* `objectstorage/v1/containers.UpdateOpts.DetectContentType`
* `objectstorage/v1/objects.UpdateOpts.ContentDisposition`
* `objectstorage/v1/objects.UpdateOpts.ContentEncoding`
* `objectstorage/v1/objects.UpdateOpts.ContentType`
* `objectstorage/v1/objects.UpdateOpts.DeleteAfter`
* `objectstorage/v1/objects.UpdateOpts.DeleteAt`
* `objectstorage/v1/objects.UpdateOpts.DetectContentType`
BUG FIXES
* Fixed issue with not being able to unset Object Storage values via HTTP headers [GH-2218](https://github.com/gophercloud/gophercloud/pull/2218)
IMPROVEMENTS
* Added `compute/v2/servers.Server.ServerGroups` [GH-2217](https://github.com/gophercloud/gophercloud/pull/2217)
* Added `imageservice/v2/images.ReplaceImageProtected` to allow the `protected` field to be updated [GH-2221](https://github.com/gophercloud/gophercloud/pull/2221)
* More details added to the 404/Not Found error message [GH-2223](https://github.com/gophercloud/gophercloud/pull/2223)
* Added `openstack/baremetal/v1/nodes.CreateSubscriptionOpts.HttpHeaders` [GH-2224](https://github.com/gophercloud/gophercloud/pull/2224)
## 0.21.0 (September 14, 2021)
IMPROVEMENTS
* Added `blockstorage/extensions/volumehost` [GH-2212](https://github.com/gophercloud/gophercloud/pull/2212)
* Added `loadbalancer/v2/listeners.CreateOpts.Tags` [GH-2214](https://github.com/gophercloud/gophercloud/pull/2214)
* Added `loadbalancer/v2/listeners.UpdateOpts.Tags` [GH-2214](https://github.com/gophercloud/gophercloud/pull/2214)
* Added `loadbalancer/v2/listeners.Listener.Tags` [GH-2214](https://github.com/gophercloud/gophercloud/pull/2214)
## 0.20.0 (August 10, 2021)
IMPROVEMENTS
* Added `RetryFunc` to enable custom retry functions. [GH-2194](https://github.com/gophercloud/gophercloud/pull/2194)
* Added `openstack/baremetal/v1/nodes.GetVendorPassthruMethods` [GH-2201](https://github.com/gophercloud/gophercloud/pull/2201)
* Added `openstack/baremetal/v1/nodes.GetAllSubscriptions` [GH-2201](https://github.com/gophercloud/gophercloud/pull/2201)
* Added `openstack/baremetal/v1/nodes.GetSubscription` [GH-2201](https://github.com/gophercloud/gophercloud/pull/2201)
* Added `openstack/baremetal/v1/nodes.DeleteSubscription` [GH-2201](https://github.com/gophercloud/gophercloud/pull/2201)
* Added `openstack/baremetal/v1/nodes.CreateSubscription` [GH-2201](https://github.com/gophercloud/gophercloud/pull/2201)
## 0.19.0 (July 22, 2021)
NOTES / BREAKING CHANGES
* `compute/v2/extensions/keypairs.List` now takes a `ListOptsBuilder` argument [GH-2186](https://github.com/gophercloud/gophercloud/pull/2186)
* `compute/v2/extensions/keypairs.Get` now takes a `GetOptsBuilder` argument [GH-2186](https://github.com/gophercloud/gophercloud/pull/2186)
* `compute/v2/extensions/keypairs.Delete` now takes a `DeleteOptsBuilder` argument [GH-2186](https://github.com/gophercloud/gophercloud/pull/2186)
* `compute/v2/extensions/hypervisors.List` now takes a `ListOptsBuilder` argument [GH-2187](https://github.com/gophercloud/gophercloud/pull/2187)
IMPROVEMENTS
* Added `blockstorage/v3/qos.List` [GH-2167](https://github.com/gophercloud/gophercloud/pull/2167)
* Added `compute/v2/extensions/volumeattach.CreateOpts.Tag` [GH-2177](https://github.com/gophercloud/gophercloud/pull/2177)
* Added `compute/v2/extensions/volumeattach.CreateOpts.DeleteOnTermination` [GH-2177](https://github.com/gophercloud/gophercloud/pull/2177)
* Added `compute/v2/extensions/volumeattach.VolumeAttachment.Tag` [GH-2177](https://github.com/gophercloud/gophercloud/pull/2177)
* Added `compute/v2/extensions/volumeattach.VolumeAttachment.DeleteOnTermination` [GH-2177](https://github.com/gophercloud/gophercloud/pull/2177)
* Added `db/v1/instances.Instance.Address` [GH-2179](https://github.com/gophercloud/gophercloud/pull/2179)
* Added `compute/v2/servers.ListOpts.AvailabilityZone` [GH-2098](https://github.com/gophercloud/gophercloud/pull/2098)
* Added `compute/v2/extensions/keypairs.ListOpts` [GH-2186](https://github.com/gophercloud/gophercloud/pull/2186)
* Added `compute/v2/extensions/keypairs.GetOpts` [GH-2186](https://github.com/gophercloud/gophercloud/pull/2186)
* Added `compute/v2/extensions/keypairs.DeleteOpts` [GH-2186](https://github.com/gophercloud/gophercloud/pull/2186)
* Added `objectstorage/v2/containers.GetHeader.Timestamp` [GH-2185](https://github.com/gophercloud/gophercloud/pull/2185)
* Added `compute/v2/extensions.ListOpts` [GH-2187](https://github.com/gophercloud/gophercloud/pull/2187)
* Added `sharedfilesystems/v2/shares.Share.CreateShareFromSnapshotSupport` [GH-2191](https://github.com/gophercloud/gophercloud/pull/2191)
* Added `compute/v2/servers.Network.Tag` for use in `CreateOpts` [GH-2193](https://github.com/gophercloud/gophercloud/pull/2193)
## 0.18.0 (June 11, 2021)

View File

@ -11,30 +11,18 @@ Gophercloud is an OpenStack Go SDK.
## How to install
Before installing, you need to ensure that your [GOPATH environment variable](https://golang.org/doc/code.html#GOPATH)
is pointing to an appropriate directory where you want to install Gophercloud:
Reference a Gophercloud package in your code:
```bash
mkdir $HOME/go
export GOPATH=$HOME/go
```Go
import "github.com/gophercloud/gophercloud"
```
To protect yourself against changes in your dependencies, we highly recommend choosing a
[dependency management solution](https://github.com/golang/go/wiki/PackageManagementTools) for
your projects, such as [godep](https://github.com/tools/godep). Once this is set up, you can install
Gophercloud as a dependency like so:
Then update your `go.mod`:
```bash
go get github.com/gophercloud/gophercloud
# Edit your code to import relevant packages from "github.com/gophercloud/gophercloud"
godep save ./...
```shell
go mod tidy
```
This will install all the source files you need into a `Godeps/_workspace` directory, which is
referenceable from your own source files when you use the `godep go` command.
## Getting started
### Credentials

View File

@ -179,7 +179,11 @@ func (e ErrDefault403) Error() string {
return e.choseErrString()
}
func (e ErrDefault404) Error() string {
return "Resource not found"
e.DefaultErrString = fmt.Sprintf(
"Resource not found: [%s %s], error message: %s",
e.Method, e.URL, e.Body,
)
return e.choseErrString()
}
func (e ErrDefault405) Error() string {
return "Method not allowed"
@ -273,10 +277,11 @@ func (e ErrTimeOut) Error() string {
type ErrUnableToReauthenticate struct {
BaseError
ErrOriginal error
ErrReauth error
}
func (e ErrUnableToReauthenticate) Error() string {
e.DefaultErrString = fmt.Sprintf("Unable to re-authenticate: %s", e.ErrOriginal)
e.DefaultErrString = fmt.Sprintf("Unable to re-authenticate: %s: %s", e.ErrOriginal, e.ErrReauth)
return e.choseErrString()
}

View File

@ -4,7 +4,29 @@ servers with a specified key pair.
Example to List Key Pairs
allPages, err := keypairs.List(computeClient).AllPages()
allPages, err := keypairs.List(computeClient, nil).AllPages()
if err != nil {
panic(err)
}
allKeyPairs, err := keypairs.ExtractKeyPairs(allPages)
if err != nil {
panic(err)
}
for _, kp := range allKeyPairs {
fmt.Printf("%+v\n", kp)
}
Example to List Key Pairs using microversion 2.10 or greater
client.Microversion = "2.10"
listOpts := keypairs.ListOpts{
UserID: "user-id",
}
allPages, err := keypairs.List(computeClient, listOpts).AllPages()
if err != nil {
panic(err)
}
@ -45,7 +67,20 @@ Example to Import a Key Pair
Example to Delete a Key Pair
err := keypairs.Delete(computeClient, "keypair-name").ExtractErr()
err := keypairs.Delete(computeClient, "keypair-name", nil).ExtractErr()
if err != nil {
panic(err)
}
Example to Delete a Key Pair owned by a certain user using microversion 2.10 or greater
client.Microversion = "2.10"
deleteOpts := keypairs.DeleteOpts{
UserID: "user-id",
}
err := keypairs.Delete(client, "keypair-name", deleteOpts).ExtractErr()
if err != nil {
panic(err)
}
@ -67,5 +102,19 @@ Example to Create a Server With a Key Pair
if err != nil {
panic(err)
}
Example to Get a Key Pair owned by a certain user using microversion 2.10 or greater
client.Microversion = "2.10"
getOpts := keypairs.GetOpts{
UserID: "user-id",
}
keypair, err := keypairs.Get(computeClient, "keypair-name", getOpts).Extract()
if err != nil {
panic(err)
}
*/
package keypairs

View File

@ -31,9 +31,36 @@ func (opts CreateOptsExt) ToServerCreateMap() (map[string]interface{}, error) {
return base, nil
}
// ListOptsBuilder allows extensions to add additional parameters to the
// List request.
type ListOptsBuilder interface {
ToKeyPairListQuery() (string, error)
}
// ListOpts enables listing KeyPairs based on specific attributes.
type ListOpts struct {
// UserID is the user ID that owns the key pair.
// This requires microversion 2.10 or higher.
UserID string `q:"user_id"`
}
// ToKeyPairListQuery formats a ListOpts into a query string.
func (opts ListOpts) ToKeyPairListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
return q.String(), err
}
// List returns a Pager that allows you to iterate over a collection of KeyPairs.
func List(client *gophercloud.ServiceClient) pagination.Pager {
return pagination.NewPager(client, listURL(client), func(r pagination.PageResult) pagination.Page {
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
url := listURL(client)
if opts != nil {
query, err := opts.ToKeyPairListQuery()
if err != nil {
return pagination.Pager{Err: err}
}
url += query
}
return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
return KeyPairPage{pagination.SinglePageBase(r)}
})
}
@ -49,6 +76,15 @@ type CreateOpts struct {
// Name is a friendly name to refer to this KeyPair in other services.
Name string `json:"name" required:"true"`
// UserID [optional] is the user_id for a keypair.
// This allows administrative users to upload keys for other users than themselves.
// This requires microversion 2.10 or higher.
UserID string `json:"user_id,omitempty"`
// The type of the keypair. Allowed values are ssh or x509
// This requires microversion 2.2 or higher.
Type string `json:"type,omitempty"`
// PublicKey [optional] is a pregenerated OpenSSH-formatted public key.
// If provided, this key will be imported and no new key will be created.
PublicKey string `json:"public_key,omitempty"`
@ -74,16 +110,74 @@ func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r Create
return
}
// GetOptsBuilder allows extensions to add additional parameters to the
// Get request.
type GetOptsBuilder interface {
ToKeyPairGetQuery() (string, error)
}
// GetOpts enables retrieving KeyPairs based on specific attributes.
type GetOpts struct {
// UserID is the user ID that owns the key pair.
// This requires microversion 2.10 or higher.
UserID string `q:"user_id"`
}
// ToKeyPairGetQuery formats a GetOpts into a query string.
func (opts GetOpts) ToKeyPairGetQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
return q.String(), err
}
// Get returns public data about a previously uploaded KeyPair.
func Get(client *gophercloud.ServiceClient, name string) (r GetResult) {
resp, err := client.Get(getURL(client, name), &r.Body, nil)
func Get(client *gophercloud.ServiceClient, name string, opts GetOptsBuilder) (r GetResult) {
url := getURL(client, name)
if opts != nil {
query, err := opts.ToKeyPairGetQuery()
if err != nil {
r.Err = err
return
}
url += query
}
resp, err := client.Get(url, &r.Body, nil)
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// DeleteOptsBuilder allows extensions to add additional parameters to the
// Delete request.
type DeleteOptsBuilder interface {
ToKeyPairDeleteQuery() (string, error)
}
// DeleteOpts enables deleting KeyPairs based on specific attributes.
type DeleteOpts struct {
// UserID is the user ID of the user that owns the key pair.
// This requires microversion 2.10 or higher.
UserID string `q:"user_id"`
}
// ToKeyPairDeleteQuery formats a DeleteOpts into a query string.
func (opts DeleteOpts) ToKeyPairDeleteQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
return q.String(), err
}
// Delete requests the deletion of a previous stored KeyPair from the server.
func Delete(client *gophercloud.ServiceClient, name string) (r DeleteResult) {
resp, err := client.Delete(deleteURL(client, name), nil)
func Delete(client *gophercloud.ServiceClient, name string, opts DeleteOptsBuilder) (r DeleteResult) {
url := deleteURL(client, name)
if opts != nil {
query, err := opts.ToKeyPairDeleteQuery()
if err != nil {
r.Err = err
return
}
url += query
}
resp, err := client.Delete(url, nil)
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}

View File

@ -27,6 +27,9 @@ type KeyPair struct {
// UserID is the user who owns this KeyPair.
UserID string `json:"user_id"`
// The type of the keypair
Type string `json:"type"`
}
// KeyPairPage stores a single page of all KeyPair results from a List call.

View File

@ -26,6 +26,14 @@ type CreateOpts struct {
// VolumeID is the ID of the volume to attach to the instance.
VolumeID string `json:"volumeId" required:"true"`
// Tag is a device role tag that can be applied to a volume when attaching
// it to the VM. Requires 2.49 microversion
Tag string `json:"tag,omitempty"`
// DeleteOnTermination specifies whether or not to delete the volume when the server
// is destroyed. Requires 2.79 microversion
DeleteOnTermination bool `json:"delete_on_termination,omitempty"`
}
// ToVolumeAttachmentCreateMap constructs a request body from CreateOpts.

View File

@ -19,6 +19,14 @@ type VolumeAttachment struct {
// ServerID is the ID of the instance that has the volume attached.
ServerID string `json:"serverId"`
// Tag is a device role tag that can be applied to a volume when attaching
// it to the VM. Requires 2.70 microversion
Tag *string `json:"tag"`
// DeleteOnTermination specifies whether or not to delete the volume when the server
// is destroyed. Requires 2.79 microversion
DeleteOnTermination *bool `json:"delete_on_termination"`
}
// VolumeAttachmentPage stores a single page all of VolumeAttachment

View File

@ -83,6 +83,9 @@ type ListOpts struct {
// This requires the client to be set to microversion 2.26 or later.
// NotTagsAny filters on specific server tags. At least one of the tags must be absent for the server.
NotTagsAny string `q:"not-tags-any"`
// Display servers based on their availability zone (Admin only until microversion 2.82).
AvailabilityZone string `q:"availability_zone"`
}
// ToServerListQuery formats a ListOpts into a query string.
@ -125,6 +128,13 @@ type Network struct {
// FixedIP specifies a fixed IPv4 address to be used on this network.
FixedIP string
// Tag may contain an optional device role tag for the server's virtual
// network interface. This can be used to identify network interfaces when
// multiple networks are connected to one server.
//
// Requires microversion 2.32 through 2.36 or 2.42 or later.
Tag string
}
// Personality is an array of files that are injected into the server at launch.
@ -258,6 +268,9 @@ func (opts CreateOpts) ToServerCreateMap() (map[string]interface{}, error) {
if net.FixedIP != "" {
networks[i]["fixed_ip"] = net.FixedIP
}
if net.Tag != "" {
networks[i]["tag"] = net.Tag
}
}
b["networks"] = networks
}

View File

@ -221,6 +221,12 @@ type Server struct {
// Tags is a slice/list of string tags in a server.
// The requires microversion 2.26 or later.
Tags *[]string `json:"tags"`
// ServerGroups is a slice of strings containing the UUIDs of the
// server groups to which the server belongs. Currently this can
// contain at most one entry.
// New in microversion 2.71
ServerGroups *[]string `json:"server_groups"`
}
type AttachedVolume struct {

View File

@ -373,6 +373,20 @@ func (r ReplaceImageMinRam) ToImagePatchMap() map[string]interface{} {
}
}
// ReplaceImageProtected represents an updated protected property request.
type ReplaceImageProtected struct {
NewProtected bool
}
// ToImagePatchMap assembles a request body based on ReplaceImageProtected
func (r ReplaceImageProtected) ToImagePatchMap() map[string]interface{} {
return map[string]interface{}{
"op": "replace",
"path": "/protected",
"value": r.NewProtected,
}
}
// UpdateOp represents a valid update operation.
type UpdateOp string

View File

@ -31,6 +31,7 @@ Example to Create a Listener
AdminStateUp: gophercloud.Enabled,
DefaultPoolID: "41efe233-7591-43c5-9cf7-923964759f9e",
ProtocolPort: 3306,
Tags: []string{"test", "stage"},
}
listener, err := listeners.Create(networkClient, createOpts).Extract()
@ -44,10 +45,12 @@ Example to Update a Listener
i1001 := 1001
i181000 := 181000
newTags := []string{"prod"}
updateOpts := listeners.UpdateOpts{
ConnLimit: &i1001,
TimeoutClientData: &i181000,
TimeoutMemberData: &i181000,
Tags: &newTags,
}
listener, err := listeners.Update(networkClient, listenerID, updateOpts).Extract()

View File

@ -167,6 +167,9 @@ type CreateOpts struct {
// A list of TLS protocol versions. Available from microversion 2.17
TLSVersions []TLSVersion `json:"tls_versions,omitempty"`
// Tags is a set of resource tags. New in version 2.5
Tags []string `json:"tags,omitempty"`
}
// ToListenerCreateMap builds a request body from CreateOpts.
@ -249,6 +252,9 @@ type UpdateOpts struct {
// A list of TLS protocol versions. Available from microversion 2.17
TLSVersions *[]TLSVersion `json:"tls_versions,omitempty"`
// Tags is a set of resource tags. New in version 2.5
Tags *[]string `json:"tags,omitempty"`
}
// ToListenerUpdateMap builds a request body from UpdateOpts.

View File

@ -86,6 +86,10 @@ type Listener struct {
// A list of TLS protocol versions. Available from microversion 2.17
TLSVersions []string `json:"tls_versions"`
// Tags is a list of resource tags. Tags are arbitrarily defined strings
// attached to the resource. New in version 2.5
Tags []string `json:"tags"`
}
type Stats struct {

View File

@ -71,10 +71,13 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
// Constants that represent approved monitoring types.
const (
TypePING = "PING"
TypeTCP = "TCP"
TypeHTTP = "HTTP"
TypeHTTPS = "HTTPS"
TypePING = "PING"
TypeTCP = "TCP"
TypeHTTP = "HTTP"
TypeHTTPS = "HTTPS"
TypeTLSHELLO = "TLS-HELLO"
TypeUDPConnect = "UDP-CONNECT"
TypeSCTP = "SCTP"
)
var (

View File

@ -18,6 +18,9 @@ type PoolID struct {
// TCP: used to connect to the members using TCP.
// HTTP: used to send an HTTP request to the member.
// HTTPS: used to send a secure HTTP request to the member.
// TLS-HELLO: used to send TLS-HELLO request to the member.
// UDP-CONNECT: used to send UDP-CONNECT request to the member.
// SCTP: used to send SCTP request to the member.
//
// When a pool has several monitors associated with it, each member of the pool
// is monitored by all these monitors. If any monitor declares the member as
@ -35,7 +38,7 @@ type Monitor struct {
ProjectID string `json:"project_id"`
// The type of probe sent by the load balancer to verify the member state,
// which is PING, TCP, HTTP, or HTTPS.
// which is PING, TCP, HTTP, HTTPS, TLS-HELLO, UDP-CONNECT or SCTP.
Type string `json:"type"`
// The time, in seconds, between sending probes to members.

View File

@ -28,6 +28,7 @@ Example to Create a Pool
LBMethod: pools.LBMethodRoundRobin,
Protocol: "HTTP",
Name: "Example pool",
Tags: []string{"test"},
LoadbalancerID: "79e05663-7f03-45d2-a092-8b94062f22ab",
}
@ -40,8 +41,10 @@ Example to Update a Pool
poolID := "d67d56a6-4a86-4688-a282-f46444705c64"
newTags := []string{"prod"}
updateOpts := pools.UpdateOpts{
Name: "new-name",
Tags: &newTags,
}
pool, err := pools.Update(networkClient, poolID, updateOpts).Extract()

View File

@ -135,6 +135,9 @@ type CreateOpts struct {
// This is only possible to use when creating a fully populated
// Loadbalancer.
Monitor *monitors.CreateOpts `json:"healthmonitor,omitempty"`
// Tags is a set of resource tags. New in version 2.5
Tags []string `json:"tags,omitempty"`
}
// ToPoolCreateMap builds a request body from CreateOpts.
@ -185,6 +188,9 @@ type UpdateOpts struct {
// The administrative state of the Pool. A valid value is true (UP)
// or false (DOWN).
AdminStateUp *bool `json:"admin_state_up,omitempty"`
// Tags is a set of resource tags. New in version 2.5
Tags *[]string `json:"tags,omitempty"`
}
// ToPoolUpdateMap builds a request body from UpdateOpts.

View File

@ -102,6 +102,10 @@ type Pool struct {
// The operating status of the pool.
OperatingStatus string `json:"operating_status"`
// Tags is a list of resource tags. Tags are arbitrarily defined strings
// attached to the resource. New in version 2.5
Tags []string `json:"tags"`
}
// PoolPage is the page returned by a pager when traversing over a

View File

@ -29,7 +29,7 @@ Example to List Networks with External Information
}
for _, network := range allNetworks {
fmt.Println("%+v\n", network)
fmt.Printf("%+v\n", network)
}
Example to Create a Network with External Information

View File

@ -54,10 +54,10 @@ type UpdateOptsBuilder interface {
type UpdateOpts struct {
Metadata map[string]string
RemoveMetadata []string
ContentType string `h:"Content-Type"`
DetectContentType bool `h:"X-Detect-Content-Type"`
TempURLKey string `h:"X-Account-Meta-Temp-URL-Key"`
TempURLKey2 string `h:"X-Account-Meta-Temp-URL-Key-2"`
ContentType *string `h:"Content-Type"`
DetectContentType *bool `h:"X-Detect-Content-Type"`
TempURLKey string `h:"X-Account-Meta-Temp-URL-Key"`
TempURLKey2 string `h:"X-Account-Meta-Temp-URL-Key-2"`
}
// ToAccountUpdateMap formats an UpdateOpts into a map[string]string of headers.

View File

@ -154,18 +154,18 @@ type UpdateOptsBuilder interface {
type UpdateOpts struct {
Metadata map[string]string
RemoveMetadata []string
ContainerRead string `h:"X-Container-Read"`
ContainerSyncTo string `h:"X-Container-Sync-To"`
ContainerSyncKey string `h:"X-Container-Sync-Key"`
ContainerWrite string `h:"X-Container-Write"`
ContentType string `h:"Content-Type"`
DetectContentType bool `h:"X-Detect-Content-Type"`
RemoveVersionsLocation string `h:"X-Remove-Versions-Location"`
VersionsLocation string `h:"X-Versions-Location"`
RemoveHistoryLocation string `h:"X-Remove-History-Location"`
HistoryLocation string `h:"X-History-Location"`
TempURLKey string `h:"X-Container-Meta-Temp-URL-Key"`
TempURLKey2 string `h:"X-Container-Meta-Temp-URL-Key-2"`
ContainerRead *string `h:"X-Container-Read"`
ContainerSyncTo *string `h:"X-Container-Sync-To"`
ContainerSyncKey *string `h:"X-Container-Sync-Key"`
ContainerWrite *string `h:"X-Container-Write"`
ContentType *string `h:"Content-Type"`
DetectContentType *bool `h:"X-Detect-Content-Type"`
RemoveVersionsLocation string `h:"X-Remove-Versions-Location"`
VersionsLocation string `h:"X-Versions-Location"`
RemoveHistoryLocation string `h:"X-Remove-History-Location"`
HistoryLocation string `h:"X-History-Location"`
TempURLKey string `h:"X-Container-Meta-Temp-URL-Key"`
TempURLKey2 string `h:"X-Container-Meta-Temp-URL-Key-2"`
}
// ToContainerUpdateMap formats a UpdateOpts into a map of headers.

View File

@ -28,7 +28,7 @@ type ContainerPage struct {
pagination.MarkerPageBase
}
//IsEmpty returns true if a ListResult contains no container names.
// IsEmpty returns true if a ListResult contains no container names.
func (r ContainerPage) IsEmpty() (bool, error) {
names, err := ExtractNames(r)
return len(names) == 0, err
@ -104,6 +104,7 @@ type GetHeader struct {
StoragePolicy string `json:"X-Storage-Policy"`
TempURLKey string `json:"X-Container-Meta-Temp-URL-Key"`
TempURLKey2 string `json:"X-Container-Meta-Temp-URL-Key-2"`
Timestamp float64 `json:"X-Timestamp,string"`
}
func (r *GetHeader) UnmarshalJSON(b []byte) error {
@ -114,6 +115,7 @@ func (r *GetHeader) UnmarshalJSON(b []byte) error {
Read string `json:"X-Container-Read"`
Date gophercloud.JSONRFC1123 `json:"Date"`
}
err := json.Unmarshal(b, &s)
if err != nil {
return err

View File

@ -394,12 +394,12 @@ type UpdateOptsBuilder interface {
type UpdateOpts struct {
Metadata map[string]string
RemoveMetadata []string
ContentDisposition string `h:"Content-Disposition"`
ContentEncoding string `h:"Content-Encoding"`
ContentType string `h:"Content-Type"`
DeleteAfter int64 `h:"X-Delete-After"`
DeleteAt int64 `h:"X-Delete-At"`
DetectContentType bool `h:"X-Detect-Content-Type"`
ContentDisposition *string `h:"Content-Disposition"`
ContentEncoding *string `h:"Content-Encoding"`
ContentType *string `h:"Content-Type"`
DeleteAfter *int64 `h:"X-Delete-After"`
DeleteAt *int64 `h:"X-Delete-At"`
DetectContentType *bool `h:"X-Detect-Content-Type"`
}
// ToObjectUpdateMap formats a UpdateOpts into a map of headers.

View File

@ -445,6 +445,9 @@ func BuildHeaders(opts interface{}) (map[string]string, error) {
// if the field is set, add it to the slice of query pieces
if !isZero(v) {
if v.Kind() == reflect.Ptr {
v = v.Elem()
}
switch v.Kind() {
case reflect.String:
optsMap[tags[0]] = v.String()

View File

@ -25,7 +25,13 @@ type UserAgent struct {
prepend []string
}
type RetryFunc func(context.Context, *ErrUnexpectedResponseCode, error, uint) error
type RetryBackoffFunc func(context.Context, *ErrUnexpectedResponseCode, error, uint) error
// RetryFunc is a catch-all function for retrying failed API requests.
// If it returns nil, the request will be retried. If it returns an error,
// the request method will exit with that error. failCount is the number of
// times the request has failed (starting at 1).
type RetryFunc func(context context.Context, method, url string, options *RequestOpts, err error, failCount uint) error
// Prepend prepends a user-defined string to the default User-Agent string. Users
// may pass in one or more strings to prepend.
@ -85,12 +91,16 @@ type ProviderClient struct {
// Context is the context passed to the HTTP request.
Context context.Context
// Retry backoff func
RetryBackoffFunc RetryFunc
// Retry backoff func is called when rate limited.
RetryBackoffFunc RetryBackoffFunc
// MaxBackoffRetries set the maximum number of backoffs. When not set, defaults to DefaultMaxBackoffRetries
MaxBackoffRetries uint
// A general failed request handler method - this is always called in the end if a request failed. Leave as nil
// to abort when an error is encountered.
RetryFunc RetryFunc
// mut is a mutex for the client. It protects read and write access to client attributes such as getting
// and setting the TokenID.
mut *sync.RWMutex
@ -398,11 +408,7 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts
if options.MoreHeaders != nil {
for k, v := range options.MoreHeaders {
if v != "" {
req.Header.Set(k, v)
} else {
req.Header.Del(k)
}
req.Header.Set(k, v)
}
}
@ -416,6 +422,16 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts
// Issue the request.
resp, err := client.HTTPClient.Do(req)
if err != nil {
if client.RetryFunc != nil {
var e error
state.retries = state.retries + 1
e = client.RetryFunc(client.Context, method, url, options, err, state.retries)
if e != nil {
return nil, e
}
return client.doRequest(method, url, options, state)
}
return nil, err
}
@ -459,6 +475,7 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts
if err != nil {
e := &ErrUnableToReauthenticate{}
e.ErrOriginal = respErr
e.ErrReauth = err
return nil, e
}
if options.RawBody != nil {
@ -550,6 +567,17 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts
err = respErr
}
if err != nil && client.RetryFunc != nil {
var e error
state.retries = state.retries + 1
e = client.RetryFunc(client.Context, method, url, options, err, state.retries)
if e != nil {
return resp, e
}
return client.doRequest(method, url, options, state)
}
return resp, err
}
@ -563,6 +591,16 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts
return resp, err
}
if err := json.NewDecoder(resp.Body).Decode(options.JSONResponse); err != nil {
if client.RetryFunc != nil {
var e error
state.retries = state.retries + 1
e = client.RetryFunc(client.Context, method, url, options, err, state.retries)
if e != nil {
return resp, e
}
return client.doRequest(method, url, options, state)
}
return nil, err
}
}

2
vendor/modules.txt generated vendored
View File

@ -411,7 +411,7 @@ github.com/googleapis/gnostic/compiler
github.com/googleapis/gnostic/extensions
github.com/googleapis/gnostic/jsonschema
github.com/googleapis/gnostic/openapiv2
# github.com/gophercloud/gophercloud v0.18.0
# github.com/gophercloud/gophercloud v0.23.0
## explicit; go 1.13
github.com/gophercloud/gophercloud
github.com/gophercloud/gophercloud/openstack