From 44f831bbf4b03633c0e4c7378229ff4f78ebb8ca Mon Sep 17 00:00:00 2001 From: Pierre Prinetti Date: Tue, 22 Oct 2024 13:47:36 +0200 Subject: [PATCH] Upgrade to Gophercloud v2 Essentially: * Add a context argument to Gophercloud functions * Refactor scheduler hints for server creation --- cloudmock/openstack/mock.go | 2 +- cloudmock/openstack/mockblockstorage/api.go | 4 +- .../mockblockstorage/availabilityzones.go | 2 +- .../openstack/mockblockstorage/volumes.go | 2 +- cloudmock/openstack/mockcompute/api.go | 12 +- cloudmock/openstack/mockcompute/flavors.go | 2 +- cloudmock/openstack/mockcompute/keypairs.go | 2 +- .../openstack/mockcompute/servergroups.go | 2 +- cloudmock/openstack/mockcompute/servers.go | 10 +- cloudmock/openstack/mockdns/api.go | 4 +- cloudmock/openstack/mockdns/zones.go | 4 +- cloudmock/openstack/mockimage/api.go | 2 +- cloudmock/openstack/mockimage/images.go | 2 +- cloudmock/openstack/mockloadbalancer/api.go | 6 +- .../openstack/mockloadbalancer/listeners.go | 2 +- .../mockloadbalancer/loadbalancers.go | 6 +- cloudmock/openstack/mockloadbalancer/pools.go | 2 +- cloudmock/openstack/mocknetworking/api.go | 12 +- .../openstack/mocknetworking/floatingips.go | 2 +- cloudmock/openstack/mocknetworking/ports.go | 2 +- cloudmock/openstack/mocknetworking/routers.go | 4 +- .../mocknetworking/securitygrouprules.go | 2 +- .../mocknetworking/securitygroups.go | 2 +- cloudmock/openstack/mocknetworking/subnets.go | 2 +- .../openstack/designate/designate.go | 7 +- .../openstack/designate/interface.go | 2 +- .../openstack/designate/rrchangeset.go | 12 +- .../providers/openstack/designate/rrset.go | 2 +- .../providers/openstack/designate/rrsets.go | 10 +- .../providers/openstack/designate/zone.go | 2 +- .../providers/openstack/designate/zones.go | 10 +- go.mod | 2 +- go.sum | 8 +- pkg/instancegroups/rollingupdate_os_test.go | 8 +- pkg/model/openstackmodel/firewall.go | 4 +- pkg/model/openstackmodel/servergroup.go | 2 +- pkg/nodeidentity/openstack/identify.go | 10 +- pkg/resources/openstack/dns.go | 2 +- pkg/resources/openstack/floatingip.go | 4 +- pkg/resources/openstack/instances.go | 2 +- pkg/resources/openstack/lb.go | 6 +- pkg/resources/openstack/network.go | 6 +- pkg/resources/openstack/ports.go | 4 +- pkg/resources/openstack/securitygroups.go | 2 +- pkg/resources/openstack/servergroup.go | 2 +- pkg/resources/openstack/volumes.go | 2 +- pkg/testutils/integrationtestharness.go | 20 +- protokube/pkg/gossip/openstack/seeds.go | 9 +- tests/e2e/go.mod | 2 +- tests/e2e/go.sum | 5 +- .../fi/cloudup/openstack/availability_zone.go | 7 +- upup/pkg/fi/cloudup/openstack/cloud.go | 59 +- upup/pkg/fi/cloudup/openstack/cloud_test.go | 8 +- upup/pkg/fi/cloudup/openstack/dns.go | 11 +- upup/pkg/fi/cloudup/openstack/floatingip.go | 13 +- upup/pkg/fi/cloudup/openstack/image.go | 5 +- upup/pkg/fi/cloudup/openstack/instance.go | 36 +- .../pkg/fi/cloudup/openstack/instance_test.go | 5 +- upup/pkg/fi/cloudup/openstack/keypair.go | 11 +- upup/pkg/fi/cloudup/openstack/loadbalancer.go | 59 +- upup/pkg/fi/cloudup/openstack/mock_cloud.go | 50 +- upup/pkg/fi/cloudup/openstack/network.go | 23 +- upup/pkg/fi/cloudup/openstack/port.go | 13 +- upup/pkg/fi/cloudup/openstack/router.go | 13 +- .../fi/cloudup/openstack/security_group.go | 17 +- upup/pkg/fi/cloudup/openstack/server_group.go | 11 +- upup/pkg/fi/cloudup/openstack/status.go | 2 +- upup/pkg/fi/cloudup/openstack/subnet.go | 11 +- upup/pkg/fi/cloudup/openstack/utils.go | 7 +- upup/pkg/fi/cloudup/openstack/verifier.go | 10 +- upup/pkg/fi/cloudup/openstack/volume.go | 15 +- .../fi/cloudup/openstacktasks/floatingip.go | 7 +- .../pkg/fi/cloudup/openstacktasks/instance.go | 63 +- .../cloudup/openstacktasks/instance_test.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/lb.go | 19 +- .../fi/cloudup/openstacktasks/lblistener.go | 5 +- upup/pkg/fi/cloudup/openstacktasks/lbpool.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/network.go | 2 +- .../cloudup/openstacktasks/poolassociation.go | 6 +- .../fi/cloudup/openstacktasks/poolmonitor.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/port.go | 4 +- .../fi/cloudup/openstacktasks/port_test.go | 4 +- upup/pkg/fi/cloudup/openstacktasks/router.go | 2 +- .../cloudup/openstacktasks/routerinterface.go | 4 +- .../cloudup/openstacktasks/securitygroup.go | 4 +- .../openstacktasks/securitygrouprule.go | 4 +- .../fi/cloudup/openstacktasks/servergroup.go | 4 +- upup/pkg/fi/cloudup/openstacktasks/sshkey.go | 2 +- upup/pkg/fi/cloudup/openstacktasks/subnet.go | 7 +- upup/pkg/fi/cloudup/openstacktasks/volume.go | 2 +- util/pkg/vfs/context.go | 2 +- util/pkg/vfs/swiftfs.go | 36 +- .../gophercloud/gophercloud/README.md | 172 --- .../github.com/gophercloud/gophercloud/doc.go | 148 -- .../openstack/blockstorage/v3/volumes/doc.go | 23 - .../blockstorage/v3/volumes/requests.go | 208 --- .../blockstorage/v3/volumes/results.go | 179 --- .../openstack/blockstorage/v3/volumes/util.go | 22 - .../v2/extensions/bootfromvolume/doc.go | 152 -- .../v2/extensions/bootfromvolume/requests.go | 142 -- .../v2/extensions/bootfromvolume/results.go | 12 - .../v2/extensions/bootfromvolume/urls.go | 7 - .../v2/extensions/schedulerhints/doc.go | 76 - .../v2/extensions/schedulerhints/requests.go | 183 --- .../openstack/compute/v2/servers/doc.go | 135 -- .../openstack/compute/v2/servers/requests.go | 784 ---------- .../openstack/compute/v2/servers/util.go | 21 - .../objectstorage/v1/containers/errors.go | 13 - .../objectstorage/v1/containers/urls.go | 54 - .../objectstorage/v1/objects/errors.go | 13 - .../openstack/utils/choose_version.go | 111 -- .../gophercloud/{ => v2}/.gitignore | 1 + .../gophercloud/gophercloud/v2/.golangci.yaml | 19 + .../gophercloud/{ => v2}/CHANGELOG.md | 81 +- .../gophercloud/gophercloud/{ => v2}/LICENSE | 0 .../gophercloud/gophercloud/v2/Makefile | 109 ++ .../gophercloud/gophercloud/v2/README.md | 252 +++ .../gophercloud/{ => v2}/RELEASE.md | 0 .../gophercloud/{ => v2}/auth_options.go | 65 +- .../gophercloud/{ => v2}/auth_result.go | 6 +- .../gophercloud/{ => v2}/endpoint_search.go | 0 .../gophercloud/{ => v2}/errors.go | 260 +--- .../{ => v2}/openstack/auth_env.go | 4 +- .../openstack/blockstorage/v3/volumes/doc.go | 161 ++ .../blockstorage/v3/volumes/requests.go | 765 +++++++++ .../blockstorage/v3/volumes/results.go | 401 +++++ .../openstack/blockstorage/v3/volumes/urls.go | 6 +- .../openstack/blockstorage/v3/volumes/util.go | 23 + .../gophercloud/{ => v2}/openstack/client.go | 177 +-- .../compute/v2}/attachinterfaces/doc.go | 8 +- .../compute/v2}/attachinterfaces/requests.go | 22 +- .../compute/v2}/attachinterfaces/results.go | 4 +- .../compute/v2}/attachinterfaces/urls.go | 2 +- .../compute/v2}/availabilityzones/doc.go | 27 +- .../compute/v2}/availabilityzones/requests.go | 4 +- .../compute/v2}/availabilityzones/results.go | 10 +- .../compute/v2}/availabilityzones/urls.go | 2 +- .../openstack/compute/v2/flavors/doc.go | 20 +- .../openstack/compute/v2/flavors/requests.go | 72 +- .../openstack/compute/v2/flavors/results.go | 12 +- .../openstack/compute/v2/flavors/urls.go | 2 +- .../openstack/compute/v2}/keypairs/doc.go | 16 +- .../compute/v2}/keypairs/requests.go | 28 +- .../openstack/compute/v2}/keypairs/results.go | 4 +- .../openstack/compute/v2}/keypairs/urls.go | 2 +- .../openstack/compute/v2}/servergroups/doc.go | 8 +- .../compute/v2}/servergroups/requests.go | 22 +- .../compute/v2}/servergroups/results.go | 6 +- .../compute/v2}/servergroups/urls.go | 2 +- .../v2/openstack/compute/v2/servers/doc.go | 313 ++++ .../openstack/compute/v2/servers/errors.go | 2 +- .../openstack/compute/v2/servers/requests.go | 1369 +++++++++++++++++ .../openstack/compute/v2/servers/results.go | 250 ++- .../openstack/compute/v2/servers/urls.go | 2 +- .../v2/openstack/compute/v2/servers/util.go | 24 + .../openstack/compute/v2}/volumeattach/doc.go | 4 +- .../compute/v2}/volumeattach/requests.go | 22 +- .../compute/v2}/volumeattach/results.go | 4 +- .../compute/v2}/volumeattach/urls.go | 2 +- .../openstack/dns/v2/recordsets/doc.go | 6 +- .../openstack/dns/v2/recordsets/requests.go | 30 +- .../openstack/dns/v2/recordsets/results.go | 6 +- .../openstack/dns/v2/recordsets/urls.go | 2 +- .../{ => v2}/openstack/dns/v2/zones/doc.go | 6 +- .../openstack/dns/v2/zones/requests.go | 30 +- .../openstack/dns/v2/zones/results.go | 8 +- .../{ => v2}/openstack/dns/v2/zones/urls.go | 2 +- .../gophercloud/{ => v2}/openstack/doc.go | 2 +- .../{ => v2}/openstack/endpoint_location.go | 6 +- .../gophercloud/{ => v2}/openstack/errors.go | 2 +- .../openstack/identity/v2/tenants/doc.go | 8 +- .../openstack/identity/v2/tenants/requests.go | 30 +- .../openstack/identity/v2/tenants/results.go | 4 +- .../openstack/identity/v2/tenants/urls.go | 2 +- .../openstack/identity/v2/tokens/doc.go | 6 +- .../openstack/identity/v2/tokens/requests.go | 23 +- .../openstack/identity/v2/tokens/results.go | 4 +- .../openstack/identity/v2/tokens/urls.go | 2 +- .../openstack/identity/v3}/ec2tokens/doc.go | 4 +- .../identity/v3}/ec2tokens/requests.go | 65 +- .../openstack/identity/v3}/ec2tokens/urls.go | 2 +- .../openstack/identity/v3}/oauth1/doc.go | 14 +- .../openstack/identity/v3}/oauth1/requests.go | 85 +- .../openstack/identity/v3}/oauth1/results.go | 4 +- .../openstack/identity/v3}/oauth1/urls.go | 2 +- .../openstack/identity/v3/tokens/doc.go | 14 +- .../openstack/identity/v3/tokens/requests.go | 35 +- .../openstack/identity/v3/tokens/results.go | 25 +- .../openstack/identity/v3/tokens/urls.go | 2 +- .../openstack/image}/v2/images/doc.go | 8 +- .../openstack/image}/v2/images/requests.go | 69 +- .../openstack/image}/v2/images/results.go | 20 +- .../openstack/image}/v2/images/types.go | 0 .../openstack/image}/v2/images/urls.go | 4 +- .../loadbalancer/v2/apiversions/doc.go | 2 +- .../loadbalancer/v2/apiversions/requests.go | 4 +- .../loadbalancer/v2/apiversions/results.go | 2 +- .../loadbalancer/v2/apiversions/urls.go | 4 +- .../loadbalancer/v2/l7policies/doc.go | 20 +- .../loadbalancer/v2/l7policies/requests.go | 81 +- .../loadbalancer/v2/l7policies/results.go | 12 +- .../loadbalancer/v2/l7policies/urls.go | 2 +- .../loadbalancer/v2/listeners/doc.go | 10 +- .../loadbalancer/v2/listeners/requests.go | 177 ++- .../loadbalancer/v2/listeners/results.go | 26 +- .../loadbalancer/v2/listeners/urls.go | 2 +- .../loadbalancer/v2/loadbalancers/doc.go | 16 +- .../loadbalancer/v2/loadbalancers/requests.go | 50 +- .../loadbalancer/v2/loadbalancers/results.go | 18 +- .../loadbalancer/v2/loadbalancers/urls.go | 2 +- .../openstack/loadbalancer/v2/monitors/doc.go | 8 +- .../loadbalancer/v2/monitors/requests.go | 95 +- .../loadbalancer/v2/monitors/results.go | 14 +- .../loadbalancer/v2/monitors/urls.go | 2 +- .../openstack/loadbalancer/v2/pools/doc.go | 18 +- .../loadbalancer/v2/pools/requests.go | 194 ++- .../loadbalancer/v2/pools/results.go | 39 +- .../openstack/loadbalancer/v2/pools/urls.go | 2 +- .../v2/extensions/attributestags/doc.go | 14 +- .../v2/extensions/attributestags/requests.go | 32 +- .../v2/extensions/attributestags/results.go | 10 +- .../v2/extensions/attributestags/urls.go | 2 +- .../networking/v2/extensions/external/doc.go | 4 +- .../v2/extensions/external/requests.go | 12 +- .../v2/extensions/external/results.go | 0 .../v2/extensions/layer3/floatingips/doc.go | 10 +- .../extensions/layer3/floatingips/requests.go | 32 +- .../extensions/layer3/floatingips/results.go | 8 +- .../v2/extensions/layer3/floatingips/urls.go | 2 +- .../v2/extensions/layer3/routers/doc.go | 18 +- .../v2/extensions/layer3/routers/requests.go | 46 +- .../v2/extensions/layer3/routers/results.go | 8 +- .../v2/extensions/layer3/routers/urls.go | 2 +- .../v2/extensions/security/groups/doc.go | 8 +- .../v2/extensions/security/groups/requests.go | 30 +- .../v2/extensions/security/groups/results.go | 6 +- .../v2/extensions/security/groups/urls.go | 2 +- .../v2/extensions/security/rules/doc.go | 6 +- .../v2/extensions/security/rules/requests.go | 22 +- .../v2/extensions/security/rules/results.go | 4 +- .../v2/extensions/security/rules/urls.go | 2 +- .../openstack/networking/v2/networks/doc.go | 8 +- .../networking/v2/networks/requests.go | 29 +- .../networking/v2/networks/results.go | 8 +- .../openstack/networking/v2/networks/urls.go | 2 +- .../openstack/networking/v2/ports/doc.go | 8 +- .../openstack/networking/v2/ports/requests.go | 81 +- .../openstack/networking/v2/ports/results.go | 11 +- .../openstack/networking/v2/ports/urls.go | 2 +- .../openstack/networking/v2/subnets/doc.go | 14 +- .../networking/v2/subnets/requests.go | 33 +- .../networking/v2/subnets/results.go | 4 +- .../openstack/networking/v2/subnets/urls.go | 2 +- .../objectstorage/v1/accounts/doc.go | 4 +- .../objectstorage/v1/accounts/requests.go | 14 +- .../objectstorage/v1/accounts/results.go | 2 +- .../objectstorage/v1/accounts/urls.go | 2 +- .../objectstorage/v1/containers/doc.go | 10 +- .../objectstorage/v1/containers/requests.go | 69 +- .../objectstorage/v1/containers/results.go | 4 +- .../objectstorage/v1/containers/urls.go | 35 + .../v2/openstack/objectstorage/v1/errors.go | 54 + .../openstack/objectstorage/v1/objects/doc.go | 12 +- .../objectstorage/v1/objects/requests.go | 145 +- .../objectstorage/v1/objects/results.go | 15 +- .../objectstorage/v1/objects/urls.go | 25 +- .../{ => v2}/openstack/utils/base_endpoint.go | 0 .../v2/openstack/utils/choose_version.go | 236 +++ .../gophercloud/{ => v2}/pagination/http.go | 15 +- .../gophercloud/{ => v2}/pagination/linked.go | 16 +- .../gophercloud/{ => v2}/pagination/marker.go | 8 +- .../gophercloud/{ => v2}/pagination/pager.go | 56 +- .../gophercloud/{ => v2}/pagination/pkg.go | 0 .../gophercloud/{ => v2}/pagination/single.go | 8 +- .../gophercloud/{ => v2}/params.go | 15 +- .../gophercloud/{ => v2}/provider_client.go | 141 +- .../gophercloud/{ => v2}/results.go | 20 +- .../gophercloud/{ => v2}/service_client.go | 31 +- .../gophercloud/gophercloud/{ => v2}/util.go | 51 +- vendor/modules.txt | 83 +- 280 files changed, 6233 insertions(+), 4508 deletions(-) delete mode 100644 vendor/github.com/gophercloud/gophercloud/README.md delete mode 100644 vendor/github.com/gophercloud/gophercloud/doc.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/doc.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/requests.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/results.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/util.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/doc.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/requests.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/results.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/urls.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints/doc.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints/requests.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/doc.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/util.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/errors.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/urls.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/errors.go delete mode 100644 vendor/github.com/gophercloud/gophercloud/openstack/utils/choose_version.go rename vendor/github.com/gophercloud/gophercloud/{ => v2}/.gitignore (80%) create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/.golangci.yaml rename vendor/github.com/gophercloud/gophercloud/{ => v2}/CHANGELOG.md (92%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/LICENSE (100%) create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/Makefile create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/README.md rename vendor/github.com/gophercloud/gophercloud/{ => v2}/RELEASE.md (100%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/auth_options.go (90%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/auth_result.go (87%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/endpoint_search.go (100%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/errors.go (61%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/auth_env.go (97%) create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/doc.go create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/requests.go create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/results.go rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/blockstorage/v3/volumes/urls.go (75%) create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/util.go rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/client.go (73%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/attachinterfaces/doc.go (77%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/attachinterfaces/requests.go (74%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/attachinterfaces/results.go (96%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/attachinterfaces/urls.go (93%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/availabilityzones/doc.go (63%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/availabilityzones/requests.go (87%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/availabilityzones/results.go (84%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/availabilityzones/urls.go (83%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/compute/v2/flavors/doc.go (75%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/compute/v2/flavors/requests.go (75%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/compute/v2/flavors/results.go (94%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/compute/v2/flavors/urls.go (97%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/keypairs/doc.go (75%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/keypairs/requests.go (83%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/keypairs/results.go (96%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/keypairs/urls.go (91%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/servergroups/doc.go (75%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/servergroups/requests.go (75%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/servergroups/results.go (96%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/servergroups/urls.go (91%) create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/doc.go rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/compute/v2/servers/errors.go (98%) create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/requests.go rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/compute/v2/servers/results.go (63%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/compute/v2/servers/urls.go (96%) create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/util.go rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/volumeattach/doc.go (73%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/volumeattach/requests.go (71%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/volumeattach/results.go (96%) rename vendor/github.com/gophercloud/gophercloud/{openstack/compute/v2/extensions => v2/openstack/compute/v2}/volumeattach/urls.go (93%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/dns/v2/recordsets/doc.go (83%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/dns/v2/recordsets/requests.go (77%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/dns/v2/recordsets/results.go (96%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/dns/v2/recordsets/urls.go (86%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/dns/v2/zones/doc.go (77%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/dns/v2/zones/requests.go (79%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/dns/v2/zones/results.go (95%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/dns/v2/zones/urls.go (81%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/doc.go (86%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/endpoint_location.go (95%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/errors.go (97%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v2/tenants/doc.go (81%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v2/tenants/requests.go (72%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v2/tenants/results.go (96%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v2/tenants/urls.go (92%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v2/tokens/doc.go (76%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v2/tokens/requests.go (82%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v2/tokens/results.go (97%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v2/tokens/urls.go (87%) rename vendor/github.com/gophercloud/gophercloud/{openstack/identity/v3/extensions => v2/openstack/identity/v3}/ec2tokens/doc.go (82%) rename vendor/github.com/gophercloud/gophercloud/{openstack/identity/v3/extensions => v2/openstack/identity/v3}/ec2tokens/requests.go (88%) rename vendor/github.com/gophercloud/gophercloud/{openstack/identity/v3/extensions => v2/openstack/identity/v3}/ec2tokens/urls.go (81%) rename vendor/github.com/gophercloud/gophercloud/{openstack/identity/v3/extensions => v2/openstack/identity/v3}/oauth1/doc.go (81%) rename vendor/github.com/gophercloud/gophercloud/{openstack/identity/v3/extensions => v2/openstack/identity/v3}/oauth1/requests.go (83%) rename vendor/github.com/gophercloud/gophercloud/{openstack/identity/v3/extensions => v2/openstack/identity/v3}/oauth1/results.go (98%) rename vendor/github.com/gophercloud/gophercloud/{openstack/identity/v3/extensions => v2/openstack/identity/v3}/oauth1/urls.go (96%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v3/tokens/doc.go (74%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v3/tokens/requests.go (80%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v3/tokens/results.go (89%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/identity/v3/tokens/urls.go (70%) rename vendor/github.com/gophercloud/gophercloud/{openstack/imageservice => v2/openstack/image}/v2/images/doc.go (73%) rename vendor/github.com/gophercloud/gophercloud/{openstack/imageservice => v2/openstack/image}/v2/images/requests.go (83%) rename vendor/github.com/gophercloud/gophercloud/{openstack/imageservice => v2/openstack/image}/v2/images/results.go (92%) rename vendor/github.com/gophercloud/gophercloud/{openstack/imageservice => v2/openstack/image}/v2/images/types.go (100%) rename vendor/github.com/gophercloud/gophercloud/{openstack/imageservice => v2/openstack/image}/v2/images/urls.go (94%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/apiversions/doc.go (97%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/apiversions/requests.go (77%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/apiversions/results.go (94%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/apiversions/urls.go (69%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/l7policies/doc.go (72%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/l7policies/requests.go (81%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/l7policies/results.go (95%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/l7policies/urls.go (93%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/listeners/doc.go (80%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/listeners/requests.go (57%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/listeners/results.go (86%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/listeners/urls.go (90%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/loadbalancers/doc.go (82%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/loadbalancers/requests.go (82%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/loadbalancers/results.go (91%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/loadbalancers/urls.go (94%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/monitors/doc.go (82%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/monitors/requests.go (73%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/monitors/results.go (92%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/monitors/urls.go (86%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/pools/doc.go (80%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/pools/requests.go (68%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/pools/results.go (86%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/loadbalancer/v2/pools/urls.go (93%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/attributestags/doc.go (51%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/attributestags/requests.go (56%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/attributestags/results.go (89%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/attributestags/urls.go (94%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/external/doc.go (90%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/external/requests.go (83%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/external/results.go (100%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/layer3/floatingips/doc.go (76%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/layer3/floatingips/requests.go (85%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/layer3/floatingips/results.go (95%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/layer3/floatingips/urls.go (84%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/layer3/routers/doc.go (77%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/layer3/routers/requests.go (84%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/layer3/routers/results.go (97%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/layer3/routers/urls.go (93%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/security/groups/doc.go (78%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/security/groups/requests.go (80%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/security/groups/results.go (95%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/security/groups/urls.go (83%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/security/rules/doc.go (79%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/security/rules/requests.go (89%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/security/rules/results.go (97%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/extensions/security/rules/urls.go (84%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/networks/doc.go (82%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/networks/requests.go (82%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/networks/results.go (95%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/networks/urls.go (93%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/ports/doc.go (83%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/ports/requests.go (72%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/ports/results.go (94%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/ports/urls.go (93%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/subnets/doc.go (84%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/subnets/requests.go (88%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/subnets/results.go (98%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/networking/v2/subnets/urls.go (93%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/accounts/doc.go (78%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/accounts/requests.go (86%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/accounts/results.go (98%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/accounts/urls.go (77%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/containers/doc.go (84%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/containers/requests.go (77%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/containers/results.go (98%) create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/urls.go create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/errors.go rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/objects/doc.go (80%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/objects/requests.go (79%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/objects/results.go (97%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/objectstorage/v1/objects/urls.go (55%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/openstack/utils/base_endpoint.go (100%) create mode 100644 vendor/github.com/gophercloud/gophercloud/v2/openstack/utils/choose_version.go rename vendor/github.com/gophercloud/gophercloud/{ => v2}/pagination/http.go (76%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/pagination/linked.go (85%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/pagination/marker.go (88%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/pagination/pager.go (83%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/pagination/pkg.go (100%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/pagination/single.go (81%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/params.go (97%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/provider_client.go (79%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/results.go (96%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/service_client.go (75%) rename vendor/github.com/gophercloud/gophercloud/{ => v2}/util.go (69%) diff --git a/cloudmock/openstack/mock.go b/cloudmock/openstack/mock.go index 9f7dbde82cfd1..f33f87efa420f 100644 --- a/cloudmock/openstack/mock.go +++ b/cloudmock/openstack/mock.go @@ -21,7 +21,7 @@ import ( "net/http" "net/http/httptest" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) type MockOpenstackServer struct { diff --git a/cloudmock/openstack/mockblockstorage/api.go b/cloudmock/openstack/mockblockstorage/api.go index 5c862c1c3c8d5..2ebb3b182eb88 100644 --- a/cloudmock/openstack/mockblockstorage/api.go +++ b/cloudmock/openstack/mockblockstorage/api.go @@ -20,8 +20,8 @@ import ( "net/http/httptest" "sync" - cinderv3 "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones" + cinderv3 "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones" "k8s.io/kops/cloudmock/openstack" ) diff --git a/cloudmock/openstack/mockblockstorage/availabilityzones.go b/cloudmock/openstack/mockblockstorage/availabilityzones.go index baefba68091c8..4311ad9a57ae5 100644 --- a/cloudmock/openstack/mockblockstorage/availabilityzones.go +++ b/cloudmock/openstack/mockblockstorage/availabilityzones.go @@ -21,7 +21,7 @@ import ( "fmt" "net/http" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones" ) type availabilityZoneListResponse struct { diff --git a/cloudmock/openstack/mockblockstorage/volumes.go b/cloudmock/openstack/mockblockstorage/volumes.go index c4a24d0df018c..bb964f63b5a2c 100644 --- a/cloudmock/openstack/mockblockstorage/volumes.go +++ b/cloudmock/openstack/mockblockstorage/volumes.go @@ -25,7 +25,7 @@ import ( "strings" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" + "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" ) type volumeListResponse struct { diff --git a/cloudmock/openstack/mockcompute/api.go b/cloudmock/openstack/mockcompute/api.go index 32dbb68bdc24c..dea15034ee808 100644 --- a/cloudmock/openstack/mockcompute/api.go +++ b/cloudmock/openstack/mockcompute/api.go @@ -20,13 +20,13 @@ import ( "net/http/httptest" "sync" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" - "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/image/v2/images" "k8s.io/kops/cloudmock/openstack" ) diff --git a/cloudmock/openstack/mockcompute/flavors.go b/cloudmock/openstack/mockcompute/flavors.go index 57761bc8b0166..0338d54fb60b2 100644 --- a/cloudmock/openstack/mockcompute/flavors.go +++ b/cloudmock/openstack/mockcompute/flavors.go @@ -23,7 +23,7 @@ import ( "regexp" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors" "k8s.io/kops/upup/pkg/fi" ) diff --git a/cloudmock/openstack/mockcompute/keypairs.go b/cloudmock/openstack/mockcompute/keypairs.go index 48f6dc7426cc5..23ca3c2ee69b7 100644 --- a/cloudmock/openstack/mockcompute/keypairs.go +++ b/cloudmock/openstack/mockcompute/keypairs.go @@ -22,7 +22,7 @@ import ( "net/http" "regexp" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs" "k8s.io/kops/pkg/pki" ) diff --git a/cloudmock/openstack/mockcompute/servergroups.go b/cloudmock/openstack/mockcompute/servergroups.go index c1274e7b3e372..55b1fee42bb48 100644 --- a/cloudmock/openstack/mockcompute/servergroups.go +++ b/cloudmock/openstack/mockcompute/servergroups.go @@ -23,7 +23,7 @@ import ( "regexp" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups" ) type serverGroupListResponse struct { diff --git a/cloudmock/openstack/mockcompute/servers.go b/cloudmock/openstack/mockcompute/servers.go index cd595d394af29..12d4ebaa8333f 100644 --- a/cloudmock/openstack/mockcompute/servers.go +++ b/cloudmock/openstack/mockcompute/servers.go @@ -24,12 +24,12 @@ import ( "regexp" "strings" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "k8s.io/kops/upup/pkg/fi" "github.com/google/uuid" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" ) type serverGetResponse struct { @@ -210,7 +210,7 @@ func (m *MockClient) createServer(w http.ResponseWriter, r *http.Request) { return } - w.WriteHeader(http.StatusCreated) + w.WriteHeader(http.StatusAccepted) server := servers.Server{ ID: uuid.New().String(), @@ -225,7 +225,7 @@ func (m *MockClient) createServer(w http.ResponseWriter, r *http.Request) { server.SecurityGroups = securityGroups portID := create.Server.Networks[0].Port - ports.Update(m.networkClient, portID, ports.UpdateOpts{ + ports.Update(r.Context(), m.networkClient, portID, ports.UpdateOpts{ DeviceID: fi.PtrTo(server.ID), }) diff --git a/cloudmock/openstack/mockdns/api.go b/cloudmock/openstack/mockdns/api.go index 5daee54d6fc02..d8987a47c9cb2 100644 --- a/cloudmock/openstack/mockdns/api.go +++ b/cloudmock/openstack/mockdns/api.go @@ -20,8 +20,8 @@ import ( "net/http/httptest" "sync" - "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" - "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones" "k8s.io/kops/cloudmock/openstack" ) diff --git a/cloudmock/openstack/mockdns/zones.go b/cloudmock/openstack/mockdns/zones.go index 9d9d253a1828a..3059cbd607323 100644 --- a/cloudmock/openstack/mockdns/zones.go +++ b/cloudmock/openstack/mockdns/zones.go @@ -23,8 +23,8 @@ import ( "strings" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" - zones "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets" + zones "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones" ) type zoneListResponse struct { diff --git a/cloudmock/openstack/mockimage/api.go b/cloudmock/openstack/mockimage/api.go index 4b35b3c36e530..7c3c09f959467 100644 --- a/cloudmock/openstack/mockimage/api.go +++ b/cloudmock/openstack/mockimage/api.go @@ -20,7 +20,7 @@ import ( "net/http/httptest" "sync" - "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" + "github.com/gophercloud/gophercloud/v2/openstack/image/v2/images" "k8s.io/kops/cloudmock/openstack" ) diff --git a/cloudmock/openstack/mockimage/images.go b/cloudmock/openstack/mockimage/images.go index 3132fd325f55f..090a13166f3ab 100644 --- a/cloudmock/openstack/mockimage/images.go +++ b/cloudmock/openstack/mockimage/images.go @@ -23,7 +23,7 @@ import ( "regexp" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" + "github.com/gophercloud/gophercloud/v2/openstack/image/v2/images" ) type imageListResponse struct { diff --git a/cloudmock/openstack/mockloadbalancer/api.go b/cloudmock/openstack/mockloadbalancer/api.go index a142f39136d8e..9153068617636 100644 --- a/cloudmock/openstack/mockloadbalancer/api.go +++ b/cloudmock/openstack/mockloadbalancer/api.go @@ -20,9 +20,9 @@ import ( "net/http/httptest" "sync" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" "k8s.io/kops/cloudmock/openstack" ) diff --git a/cloudmock/openstack/mockloadbalancer/listeners.go b/cloudmock/openstack/mockloadbalancer/listeners.go index c10abd6310700..6bc1ed56b7ed4 100644 --- a/cloudmock/openstack/mockloadbalancer/listeners.go +++ b/cloudmock/openstack/mockloadbalancer/listeners.go @@ -24,7 +24,7 @@ import ( "regexp" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners" ) type listenerListResponse struct { diff --git a/cloudmock/openstack/mockloadbalancer/loadbalancers.go b/cloudmock/openstack/mockloadbalancer/loadbalancers.go index 7deef01da70e7..e9e4717608e4f 100644 --- a/cloudmock/openstack/mockloadbalancer/loadbalancers.go +++ b/cloudmock/openstack/mockloadbalancer/loadbalancers.go @@ -24,9 +24,9 @@ import ( "regexp" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" ) type loadbalancerListResponse struct { diff --git a/cloudmock/openstack/mockloadbalancer/pools.go b/cloudmock/openstack/mockloadbalancer/pools.go index 413a39de2af37..db8cc1a6cdc31 100644 --- a/cloudmock/openstack/mockloadbalancer/pools.go +++ b/cloudmock/openstack/mockloadbalancer/pools.go @@ -24,7 +24,7 @@ import ( "regexp" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" ) type poolListResponse struct { diff --git a/cloudmock/openstack/mocknetworking/api.go b/cloudmock/openstack/mocknetworking/api.go index edf0754552389..c2de033f9b850 100644 --- a/cloudmock/openstack/mocknetworking/api.go +++ b/cloudmock/openstack/mocknetworking/api.go @@ -20,13 +20,13 @@ import ( "net/http/httptest" "sync" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" "k8s.io/kops/cloudmock/openstack" ) diff --git a/cloudmock/openstack/mocknetworking/floatingips.go b/cloudmock/openstack/mocknetworking/floatingips.go index acb994f372f84..d15c4a65ac4bd 100644 --- a/cloudmock/openstack/mocknetworking/floatingips.go +++ b/cloudmock/openstack/mocknetworking/floatingips.go @@ -23,7 +23,7 @@ import ( "net/url" "regexp" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips" ) type floatingIPListResponse struct { diff --git a/cloudmock/openstack/mocknetworking/ports.go b/cloudmock/openstack/mocknetworking/ports.go index 396ffeab85bae..a72f083ab91d2 100644 --- a/cloudmock/openstack/mocknetworking/ports.go +++ b/cloudmock/openstack/mocknetworking/ports.go @@ -27,7 +27,7 @@ import ( "k8s.io/kops/upup/pkg/fi" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" ) type portListResponse struct { diff --git a/cloudmock/openstack/mocknetworking/routers.go b/cloudmock/openstack/mocknetworking/routers.go index 9253bc4eabc02..399d93da7dac9 100644 --- a/cloudmock/openstack/mocknetworking/routers.go +++ b/cloudmock/openstack/mocknetworking/routers.go @@ -24,10 +24,10 @@ import ( "regexp" "strings" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers" ) type routerListResponse struct { diff --git a/cloudmock/openstack/mocknetworking/securitygrouprules.go b/cloudmock/openstack/mocknetworking/securitygrouprules.go index 9bb6b18d75121..f86d6d4181928 100644 --- a/cloudmock/openstack/mocknetworking/securitygrouprules.go +++ b/cloudmock/openstack/mocknetworking/securitygrouprules.go @@ -25,7 +25,7 @@ import ( "strconv" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules" ) type ruleListResponse struct { diff --git a/cloudmock/openstack/mocknetworking/securitygroups.go b/cloudmock/openstack/mocknetworking/securitygroups.go index 62d75ac639547..731d880641e1b 100644 --- a/cloudmock/openstack/mocknetworking/securitygroups.go +++ b/cloudmock/openstack/mocknetworking/securitygroups.go @@ -24,7 +24,7 @@ import ( "regexp" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" ) type groupListResponse struct { diff --git a/cloudmock/openstack/mocknetworking/subnets.go b/cloudmock/openstack/mocknetworking/subnets.go index d7a96cbe3c92c..29060b7be1346 100644 --- a/cloudmock/openstack/mocknetworking/subnets.go +++ b/cloudmock/openstack/mocknetworking/subnets.go @@ -26,7 +26,7 @@ import ( "strings" "github.com/google/uuid" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" ) type subnetListResponse struct { diff --git a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/designate.go b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/designate.go index fae53a1c0ab15..244147c9ffef3 100644 --- a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/designate.go +++ b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/designate.go @@ -17,13 +17,14 @@ limitations under the License. package designate import ( + "context" "crypto/tls" "fmt" "io" "net/http" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack" "k8s.io/klog/v2" "k8s.io/kops/dnsprovider/pkg/dnsprovider" "k8s.io/kops/util/pkg/vfs" @@ -70,7 +71,7 @@ func newDesignate(_ io.Reader) (*Interface, error) { klog.V(2).Info("authenticating to keystone") - err = openstack.Authenticate(provider, ao) + err = openstack.Authenticate(context.TODO(), provider, ao) if err != nil { return nil, fmt.Errorf("error building openstack authenticated client: %v", err) } diff --git a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/interface.go b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/interface.go index 88599eb385ee8..8f540fd2b75d3 100644 --- a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/interface.go +++ b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/interface.go @@ -17,7 +17,7 @@ limitations under the License. package designate import ( - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" "k8s.io/kops/dnsprovider/pkg/dnsprovider" ) diff --git a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrchangeset.go b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrchangeset.go index 58d91b7c0dcbc..31bebfaaa0386 100644 --- a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrchangeset.go +++ b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrchangeset.go @@ -20,7 +20,7 @@ import ( "context" "fmt" - "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets" "k8s.io/kops/dnsprovider/pkg/dnsprovider" ) @@ -64,7 +64,7 @@ func (c *ResourceRecordChangeset) Apply(ctx context.Context) error { if err != nil { return err } - err = recordsets.Delete(c.zone.zones.iface.sc, zoneID, rrID).ExtractErr() + err = recordsets.Delete(ctx, c.zone.zones.iface.sc, zoneID, rrID).ExtractErr() if err != nil { return err } @@ -77,7 +77,7 @@ func (c *ResourceRecordChangeset) Apply(ctx context.Context) error { Type: string(addition.Type()), Records: addition.Rrdatas(), } - _, err := recordsets.Create(c.zone.zones.iface.sc, zoneID, opts).Extract() + _, err := recordsets.Create(ctx, c.zone.zones.iface.sc, zoneID, opts).Extract() if err != nil { return err } @@ -93,7 +93,7 @@ func (c *ResourceRecordChangeset) Apply(ctx context.Context) error { TTL: &ttl, Records: upsert.Rrdatas(), } - _, err = recordsets.Update(c.zone.zones.iface.sc, zoneID, rrID, uopts).Extract() + _, err = recordsets.Update(ctx, c.zone.zones.iface.sc, zoneID, rrID, uopts).Extract() if err != nil { copts := recordsets.CreateOpts{ Name: upsert.Name(), @@ -101,7 +101,7 @@ func (c *ResourceRecordChangeset) Apply(ctx context.Context) error { Type: string(upsert.Type()), Records: upsert.Rrdatas(), } - _, err := recordsets.Create(c.zone.zones.iface.sc, zoneID, copts).Extract() + _, err := recordsets.Create(ctx, c.zone.zones.iface.sc, zoneID, copts).Extract() if err != nil { return err } @@ -124,7 +124,7 @@ func (c *ResourceRecordChangeset) nameToID(name string) (string, error) { opts := recordsets.ListOpts{ Name: name, } - allPages, err := recordsets.ListByZone(c.zone.zones.iface.sc, c.zone.impl.ID, opts).AllPages() + allPages, err := recordsets.ListByZone(c.zone.zones.iface.sc, c.zone.impl.ID, opts).AllPages(context.TODO()) if err != nil { return "", err } diff --git a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrset.go b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrset.go index af4bc5ea79656..bcec1f9cf645c 100644 --- a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrset.go +++ b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrset.go @@ -20,7 +20,7 @@ import ( "k8s.io/kops/dnsprovider/pkg/dnsprovider" "k8s.io/kops/dnsprovider/pkg/dnsprovider/rrstype" - "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets" ) var _ dnsprovider.ResourceRecordSet = ResourceRecordSet{} diff --git a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrsets.go b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrsets.go index 38663fe290798..6323349e999b8 100644 --- a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrsets.go +++ b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrsets.go @@ -17,8 +17,10 @@ limitations under the License. package designate import ( - "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets" + "github.com/gophercloud/gophercloud/v2/pagination" "k8s.io/kops/dnsprovider/pkg/dnsprovider" "k8s.io/kops/dnsprovider/pkg/dnsprovider/rrstype" ) @@ -31,7 +33,7 @@ type ResourceRecordSets struct { func (rrsets ResourceRecordSets) List() ([]dnsprovider.ResourceRecordSet, error) { var list []dnsprovider.ResourceRecordSet - err := recordsets.ListByZone(rrsets.zone.zones.iface.sc, rrsets.zone.impl.ID, nil).EachPage(func(page pagination.Page) (bool, error) { + err := recordsets.ListByZone(rrsets.zone.zones.iface.sc, rrsets.zone.impl.ID, nil).EachPage(context.TODO(), func(ctx context.Context, page pagination.Page) (bool, error) { rrs, err := recordsets.ExtractRecordSets(page) if err != nil { return false, err @@ -54,7 +56,7 @@ func (rrsets ResourceRecordSets) Get(name string) ([]dnsprovider.ResourceRecordS } var list []dnsprovider.ResourceRecordSet - err := recordsets.ListByZone(rrsets.zone.zones.iface.sc, rrsets.zone.impl.ID, opts).EachPage(func(page pagination.Page) (bool, error) { + err := recordsets.ListByZone(rrsets.zone.zones.iface.sc, rrsets.zone.impl.ID, opts).EachPage(context.TODO(), func(ctx context.Context, page pagination.Page) (bool, error) { rrs, err := recordsets.ExtractRecordSets(page) if err != nil { return false, err diff --git a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/zone.go b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/zone.go index 65a41563724a8..f728ff5452673 100644 --- a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/zone.go +++ b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/zone.go @@ -19,7 +19,7 @@ package designate import ( "k8s.io/kops/dnsprovider/pkg/dnsprovider" - "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones" ) var _ dnsprovider.Zone = &Zone{} diff --git a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/zones.go b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/zones.go index 5b1a766b60e6f..0357403ec81da 100644 --- a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/zones.go +++ b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/zones.go @@ -17,7 +17,9 @@ limitations under the License. package designate import ( - "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" + "context" + + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones" "k8s.io/kops/dnsprovider/pkg/dnsprovider" ) @@ -31,7 +33,7 @@ type Zones struct { func (kzs Zones) List() ([]dnsprovider.Zone, error) { var zoneList []dnsprovider.Zone - allPages, err := zones.List(kzs.iface.sc, nil).AllPages() + allPages, err := zones.List(kzs.iface.sc, nil).AllPages(context.TODO()) if err != nil { return zoneList, err } @@ -51,7 +53,7 @@ func (kzs Zones) List() ([]dnsprovider.Zone, error) { func (kzs Zones) Add(zone dnsprovider.Zone) (dnsprovider.Zone, error) { opts := &zones.CreateOpts{Name: zone.Name()} - z, err := zones.Create(kzs.iface.sc, opts).Extract() + z, err := zones.Create(context.TODO(), kzs.iface.sc, opts).Extract() if err != nil { return nil, err } @@ -62,7 +64,7 @@ func (kzs Zones) Add(zone dnsprovider.Zone) (dnsprovider.Zone, error) { } func (kzs Zones) Remove(zone dnsprovider.Zone) error { - _, err := zones.Delete(kzs.iface.sc, zone.ID()).Extract() + _, err := zones.Delete(context.TODO(), kzs.iface.sc, zone.ID()).Extract() return err } diff --git a/go.mod b/go.mod index b82e4482f5f97..8889c5821fad3 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/google/go-tpm v0.9.1 github.com/google/go-tpm-tools v0.4.4 github.com/google/uuid v1.6.0 - github.com/gophercloud/gophercloud v1.14.1 + github.com/gophercloud/gophercloud/v2 v2.2.0 github.com/hetznercloud/hcloud-go v1.59.1 github.com/jacksontj/memberlistmesh v0.0.0-20190905163944-93462b9d2bb7 github.com/pelletier/go-toml v1.9.5 diff --git a/go.sum b/go.sum index a374a72c3f499..4f4db242e1b77 100644 --- a/go.sum +++ b/go.sum @@ -367,8 +367,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.4 h1:XYIDZApgAnrN1c855gT github.com/googleapis/enterprise-certificate-proxy v0.3.4/go.mod h1:YKe7cfqYXjKGpGvmSg28/fFvhNzinZQm8DGnaburhGA= github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s= github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A= -github.com/gophercloud/gophercloud v1.14.1 h1:DTCNaTVGl8/cFu58O1JwWgis9gtISAFONqpMKNg/Vpw= -github.com/gophercloud/gophercloud v1.14.1/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= +github.com/gophercloud/gophercloud/v2 v2.2.0 h1:STqqnSXuhcg1OPBOZ14z6JDm8fKIN13H2bJg6bBuHp8= +github.com/gophercloud/gophercloud/v2 v2.2.0/go.mod h1:f2hMRC7Kakbv5vM7wSGHrIPZh6JZR60GVHryJlF/K44= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= @@ -698,7 +698,6 @@ golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= @@ -728,7 +727,6 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= @@ -759,7 +757,6 @@ golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -780,7 +777,6 @@ golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= diff --git a/pkg/instancegroups/rollingupdate_os_test.go b/pkg/instancegroups/rollingupdate_os_test.go index 7cf83be198607..ffefbc95daa5a 100644 --- a/pkg/instancegroups/rollingupdate_os_test.go +++ b/pkg/instancegroups/rollingupdate_os_test.go @@ -21,9 +21,9 @@ import ( "testing" "time" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "github.com/stretchr/testify/assert" v1 "k8s.io/api/core/v1" v1meta "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -161,7 +161,7 @@ func makeGroupOS(t *testing.T, groups map[string]*cloudinstances.CloudInstanceGr Port: port.ID, }, }, - }, "") + }, nil, "") if err != nil { t.Fatalf("Failed to make group: %v", err) } diff --git a/pkg/model/openstackmodel/firewall.go b/pkg/model/openstackmodel/firewall.go index 1c34460b7733e..5732425a666c8 100644 --- a/pkg/model/openstackmodel/firewall.go +++ b/pkg/model/openstackmodel/firewall.go @@ -27,8 +27,8 @@ import ( "k8s.io/kops/pkg/wellknownports" "k8s.io/utils/net" - sg "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" + sg "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules" ) const ( diff --git a/pkg/model/openstackmodel/servergroup.go b/pkg/model/openstackmodel/servergroup.go index 94b0d4e4994f3..71df04841e6c5 100644 --- a/pkg/model/openstackmodel/servergroup.go +++ b/pkg/model/openstackmodel/servergroup.go @@ -22,7 +22,7 @@ import ( "sort" "strings" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "k8s.io/klog/v2" "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/model" diff --git a/pkg/nodeidentity/openstack/identify.go b/pkg/nodeidentity/openstack/identify.go index 2a482f202e80a..2ec978cc1a45d 100644 --- a/pkg/nodeidentity/openstack/identify.go +++ b/pkg/nodeidentity/openstack/identify.go @@ -23,9 +23,9 @@ import ( "strings" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" corev1 "k8s.io/api/core/v1" expirationcache "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" @@ -71,7 +71,7 @@ func New(CacheNodeidentityInfo bool) (nodeidentity.Identifier, error) { // node-controller should be able to renew it tokens against OpenStack API env.AllowReauth = true - err = openstack.Authenticate(provider, env) + err = openstack.Authenticate(context.TODO(), provider, env) if err != nil { return nil, err } @@ -118,7 +118,7 @@ func (i *nodeIdentifier) IdentifyNode(ctx context.Context, node *corev1.Node) (* } } - server, err := servers.Get(i.novaClient, instanceID).Extract() + server, err := servers.Get(ctx, i.novaClient, instanceID).Extract() if err != nil { return nil, err } diff --git a/pkg/resources/openstack/dns.go b/pkg/resources/openstack/dns.go index 26fa3b2fc9c74..efe35955abd0c 100644 --- a/pkg/resources/openstack/dns.go +++ b/pkg/resources/openstack/dns.go @@ -22,7 +22,7 @@ import ( "k8s.io/kops/pkg/dns" - "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones" "k8s.io/kops/pkg/resources" "k8s.io/kops/upup/pkg/fi" ) diff --git a/pkg/resources/openstack/floatingip.go b/pkg/resources/openstack/floatingip.go index 8e6cc5e44d95f..70e22b5255312 100644 --- a/pkg/resources/openstack/floatingip.go +++ b/pkg/resources/openstack/floatingip.go @@ -17,8 +17,8 @@ limitations under the License. package openstack import ( - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - l3floatingip "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + l3floatingip "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips" "k8s.io/kops/pkg/resources" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/pkg/resources/openstack/instances.go b/pkg/resources/openstack/instances.go index 292cd26806cc6..2ddb87e26e7e0 100644 --- a/pkg/resources/openstack/instances.go +++ b/pkg/resources/openstack/instances.go @@ -17,7 +17,7 @@ limitations under the License. package openstack import ( - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" "k8s.io/kops/pkg/resources" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/pkg/resources/openstack/lb.go b/pkg/resources/openstack/lb.go index f524441482ad9..7b47e8b5fbd68 100644 --- a/pkg/resources/openstack/lb.go +++ b/pkg/resources/openstack/lb.go @@ -20,9 +20,9 @@ import ( "fmt" "strings" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" "k8s.io/klog/v2" "k8s.io/kops/pkg/resources" "k8s.io/kops/upup/pkg/fi" diff --git a/pkg/resources/openstack/network.go b/pkg/resources/openstack/network.go index 6af2aae9655a7..7b5d74326cd29 100644 --- a/pkg/resources/openstack/network.go +++ b/pkg/resources/openstack/network.go @@ -19,9 +19,9 @@ package openstack import ( "strings" - osrouter "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" - "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + osrouter "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" "k8s.io/kops/pkg/resources" "k8s.io/kops/upup/pkg/fi" diff --git a/pkg/resources/openstack/ports.go b/pkg/resources/openstack/ports.go index d4c908a3b566c..19455bf7563f3 100644 --- a/pkg/resources/openstack/ports.go +++ b/pkg/resources/openstack/ports.go @@ -17,8 +17,8 @@ limitations under the License. package openstack import ( - "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "k8s.io/kops/pkg/resources" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/pkg/resources/openstack/securitygroups.go b/pkg/resources/openstack/securitygroups.go index 98ccfcd54ee57..43c9f706b5604 100644 --- a/pkg/resources/openstack/securitygroups.go +++ b/pkg/resources/openstack/securitygroups.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - sg "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" + sg "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" "k8s.io/kops/pkg/resources" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/pkg/resources/openstack/servergroup.go b/pkg/resources/openstack/servergroup.go index a083f9cd32e6e..dc4e8a1049396 100644 --- a/pkg/resources/openstack/servergroup.go +++ b/pkg/resources/openstack/servergroup.go @@ -19,7 +19,7 @@ package openstack import ( "strings" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups" "k8s.io/kops/pkg/resources" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/pkg/resources/openstack/volumes.go b/pkg/resources/openstack/volumes.go index 1a4651a7cc449..f1511c50158ca 100644 --- a/pkg/resources/openstack/volumes.go +++ b/pkg/resources/openstack/volumes.go @@ -17,7 +17,7 @@ limitations under the License. package openstack import ( - cinder "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" + cinder "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" "k8s.io/kops/pkg/resources" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/pkg/testutils/integrationtestharness.go b/pkg/testutils/integrationtestharness.go index 5134220c4dd78..bb88f2ac23c22 100644 --- a/pkg/testutils/integrationtestharness.go +++ b/pkg/testutils/integrationtestharness.go @@ -33,12 +33,12 @@ import ( elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2" "github.com/aws/aws-sdk-go-v2/service/iam" route53types "github.com/aws/aws-sdk-go-v2/service/route53/types" - "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" - "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" - "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external" - "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones" + "github.com/gophercloud/gophercloud/v2/openstack/image/v2/images" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" "k8s.io/klog/v2" kopsroot "k8s.io/kops" "k8s.io/kops/cloudmock/aws/mockautoscaling" @@ -339,23 +339,23 @@ func SetupMockOpenstack() *openstack.MockCloud { c.CreateSubnet(extSubnet) c.SetExternalSubnet(fi.PtrTo(extSubnetName)) c.SetLBFloatingSubnet(fi.PtrTo(extSubnetName)) - images.Create(c.MockImageClient.ServiceClient(), images.CreateOpts{ + images.Create(context.TODO(), c.MockImageClient.ServiceClient(), images.CreateOpts{ Name: "Ubuntu-20.04", MinDisk: 12, }) - flavors.Create(c.MockNovaClient.ServiceClient(), flavors.CreateOpts{ + flavors.Create(context.TODO(), c.MockNovaClient.ServiceClient(), flavors.CreateOpts{ Name: "n1-standard-2", RAM: 8192, VCPUs: 8, Disk: fi.PtrTo(16), }) - flavors.Create(c.MockNovaClient.ServiceClient(), flavors.CreateOpts{ + flavors.Create(context.TODO(), c.MockNovaClient.ServiceClient(), flavors.CreateOpts{ Name: "n1-standard-1", RAM: 8192, VCPUs: 4, Disk: fi.PtrTo(16), }) - zones.Create(c.MockDNSClient.ServiceClient(), zones.CreateOpts{ + zones.Create(context.TODO(), c.MockDNSClient.ServiceClient(), zones.CreateOpts{ Name: "minimal-openstack.k8s.local", }) return c diff --git a/protokube/pkg/gossip/openstack/seeds.go b/protokube/pkg/gossip/openstack/seeds.go index 2d0681910cc83..16e32e8d93cd6 100644 --- a/protokube/pkg/gossip/openstack/seeds.go +++ b/protokube/pkg/gossip/openstack/seeds.go @@ -17,11 +17,12 @@ limitations under the License. package gce import ( + "context" "fmt" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/pagination" "k8s.io/klog/v2" "k8s.io/kops/protokube/pkg/gossip" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" @@ -40,7 +41,7 @@ func (p *SeedProvider) GetSeeds() ([]string, error) { err := servers.List(p.computeClient, servers.ListOpts{ TenantID: p.projectID, - }).EachPage(func(page pagination.Page) (bool, error) { + }).EachPage(context.TODO(), func(ctx context.Context, page pagination.Page) (bool, error) { var s []servers.Server err := servers.ExtractServersInto(page, &s) if err != nil { diff --git a/tests/e2e/go.mod b/tests/e2e/go.mod index 45b36a7a5b30e..87b6f3f4556fe 100644 --- a/tests/e2e/go.mod +++ b/tests/e2e/go.mod @@ -164,7 +164,7 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect github.com/googleapis/gax-go/v2 v2.13.0 // indirect - github.com/gophercloud/gophercloud v1.14.1 // indirect + github.com/gophercloud/gophercloud/v2 v2.2.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect diff --git a/tests/e2e/go.sum b/tests/e2e/go.sum index 00f50a616a098..cf8b0e473d76b 100644 --- a/tests/e2e/go.sum +++ b/tests/e2e/go.sum @@ -587,8 +587,8 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s= github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A= -github.com/gophercloud/gophercloud v1.14.1 h1:DTCNaTVGl8/cFu58O1JwWgis9gtISAFONqpMKNg/Vpw= -github.com/gophercloud/gophercloud v1.14.1/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= +github.com/gophercloud/gophercloud/v2 v2.2.0 h1:STqqnSXuhcg1OPBOZ14z6JDm8fKIN13H2bJg6bBuHp8= +github.com/gophercloud/gophercloud/v2 v2.2.0/go.mod h1:f2hMRC7Kakbv5vM7wSGHrIPZh6JZR60GVHryJlF/K44= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= @@ -1094,7 +1094,6 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= diff --git a/upup/pkg/fi/cloudup/openstack/availability_zone.go b/upup/pkg/fi/cloudup/openstack/availability_zone.go index 43c445686737f..fe7e73fe64825 100644 --- a/upup/pkg/fi/cloudup/openstack/availability_zone.go +++ b/upup/pkg/fi/cloudup/openstack/availability_zone.go @@ -17,10 +17,11 @@ limitations under the License. package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud" - az "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones" + "github.com/gophercloud/gophercloud/v2" + az "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kops/util/pkg/vfs" ) @@ -31,7 +32,7 @@ func (c *openstackCloud) ListAvailabilityZones(serviceClient *gophercloud.Servic func listAvailabilityZones(c OpenstackCloud, serviceClient *gophercloud.ServiceClient) (azList []az.AvailabilityZone, err error) { done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - azPage, err := az.List(serviceClient).AllPages() + azPage, err := az.List(serviceClient).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("failed to list storage availability zones: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/cloud.go b/upup/pkg/fi/cloudup/openstack/cloud.go index 853a9a47ec092..e4e274e8a20b2 100644 --- a/upup/pkg/fi/cloudup/openstack/cloud.go +++ b/upup/pkg/fi/cloudup/openstack/cloud.go @@ -17,6 +17,7 @@ limitations under the License. package openstack import ( + "context" "crypto/tls" "fmt" "net/http" @@ -25,30 +26,30 @@ import ( "time" "github.com/blang/semver/v4" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack" - cinder "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" - az "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach" - "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" - "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" - "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors" - v2pools "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" - l3floatingip "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" - sg "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" - sgr "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" - "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack" + cinder "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" + az "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones" + "github.com/gophercloud/gophercloud/v2/openstack/image/v2/images" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors" + v2pools "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" + l3floatingip "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers" + sg "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" + sgr "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" @@ -117,7 +118,7 @@ type OpenstackCloud interface { ListInstances(servers.ListOptsBuilder) ([]servers.Server, error) // CreateInstance will create an openstack server provided create opts - CreateInstance(servers.CreateOptsBuilder, string) (*servers.Server, error) + CreateInstance(servers.CreateOptsBuilder, servers.SchedulerHintOptsBuilder, string) (*servers.Server, error) // DeleteInstanceWithID will delete instance DeleteInstanceWithID(instanceID string) error @@ -361,7 +362,7 @@ func NewOpenstackCloud(cluster *kops.Cluster, uagent string) (OpenstackCloud, er klog.V(2).Info("authenticating to keystone") - err = openstack.Authenticate(provider, authOption) + err = openstack.Authenticate(context.TODO(), provider, authOption) if err != nil { return nil, fmt.Errorf("error building openstack authenticated client: %v", err) } @@ -404,7 +405,7 @@ func buildClients(provider *gophercloud.ProviderClient, tags map[string]string, // 2.47 is the minimum version where the compute API /server/details returns flavor names novaClient.Microversion = "2.47" - glanceClient, err := openstack.NewImageServiceV2(provider, gophercloud.EndpointOpts{ + glanceClient, err := openstack.NewImageV2(provider, gophercloud.EndpointOpts{ Type: "image", Region: region, }) @@ -714,7 +715,7 @@ func useLoadBalancerVIPACL(c OpenstackCloud) (bool, error) { if c.LoadBalancerClient() == nil { return false, nil } - allPages, err := apiversions.List(c.LoadBalancerClient()).AllPages() + allPages, err := apiversions.List(c.LoadBalancerClient()).AllPages(context.TODO()) if err != nil { return false, err } @@ -829,7 +830,7 @@ func getIPIngressStatus(c OpenstackCloud, cluster *kops.Cluster) (ingresses []fi } func isNotFound(err error) bool { - if _, ok := err.(gophercloud.ErrDefault404); ok { + if gophercloud.ResponseCodeIs(err, http.StatusNotFound) { return true } diff --git a/upup/pkg/fi/cloudup/openstack/cloud_test.go b/upup/pkg/fi/cloudup/openstack/cloud_test.go index 0a6b2d8b0fd81..4aa916dd6379e 100644 --- a/upup/pkg/fi/cloudup/openstack/cloud_test.go +++ b/upup/pkg/fi/cloudup/openstack/cloud_test.go @@ -25,10 +25,10 @@ import ( "sort" "testing" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" - l3floatingips "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers" + l3floatingips "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/upup/pkg/fi" diff --git a/upup/pkg/fi/cloudup/openstack/dns.go b/upup/pkg/fi/cloudup/openstack/dns.go index ae1c2c4b76999..b8de012a1c3a2 100644 --- a/upup/pkg/fi/cloudup/openstack/dns.go +++ b/upup/pkg/fi/cloudup/openstack/dns.go @@ -17,10 +17,11 @@ limitations under the License. package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" - "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kops/util/pkg/vfs" ) @@ -34,7 +35,7 @@ func listDNSZones(c OpenstackCloud, opt zones.ListOptsBuilder) ([]zones.Zone, er var zs []zones.Zone done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := zones.List(c.DNSClient(), opt).AllPages() + allPages, err := zones.List(c.DNSClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("failed to list dns zones: %s", err) } @@ -56,7 +57,7 @@ func listDNSZones(c OpenstackCloud, opt zones.ListOptsBuilder) ([]zones.Zone, er func deleteDNSRecordset(c OpenstackCloud, zoneID string, rrsetID string) error { done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - err := recordsets.Delete(c.DNSClient(), zoneID, rrsetID).ExtractErr() + err := recordsets.Delete(context.TODO(), c.DNSClient(), zoneID, rrsetID).ExtractErr() if err != nil { return false, fmt.Errorf("failed to delete dns recordset: %s", err) } @@ -85,7 +86,7 @@ func listDNSRecordsets(c OpenstackCloud, zoneID string, opt recordsets.ListOptsB var rrs []recordsets.RecordSet done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := recordsets.ListByZone(c.DNSClient(), zoneID, opt).AllPages() + allPages, err := recordsets.ListByZone(c.DNSClient(), zoneID, opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("failed to list dns recordsets: %s", err) } diff --git a/upup/pkg/fi/cloudup/openstack/floatingip.go b/upup/pkg/fi/cloudup/openstack/floatingip.go index 52492fa5cb9a6..8724e237def84 100644 --- a/upup/pkg/fi/cloudup/openstack/floatingip.go +++ b/upup/pkg/fi/cloudup/openstack/floatingip.go @@ -17,9 +17,10 @@ limitations under the License. package openstack import ( + "context" "fmt" - l3floatingip "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" + l3floatingip "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kops/util/pkg/vfs" ) @@ -30,7 +31,7 @@ func (c *openstackCloud) GetL3FloatingIP(id string) (fip *l3floatingip.FloatingI func getL3FloatingIP(c OpenstackCloud, id string) (fip *l3floatingip.FloatingIP, err error) { done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - fip, err = l3floatingip.Get(c.NetworkingClient(), id).Extract() + fip, err = l3floatingip.Get(context.TODO(), c.NetworkingClient(), id).Extract() if err != nil { return false, fmt.Errorf("GetFloatingIP: fetching floating IP (%s) failed: %v", id, err) } @@ -51,7 +52,7 @@ func (c *openstackCloud) CreateL3FloatingIP(opts l3floatingip.CreateOpts) (fip * func createL3FloatingIP(c OpenstackCloud, opts l3floatingip.CreateOpts) (fip *l3floatingip.FloatingIP, err error) { done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - fip, err = l3floatingip.Create(c.NetworkingClient(), opts).Extract() + fip, err = l3floatingip.Create(context.TODO(), c.NetworkingClient(), opts).Extract() if err != nil { return false, fmt.Errorf("CreateL3FloatingIP: create L3 floating IP failed: %v", err) } @@ -72,7 +73,7 @@ func (c *openstackCloud) ListL3FloatingIPs(opts l3floatingip.ListOpts) (fips []l func listL3FloatingIPs(c OpenstackCloud, opts l3floatingip.ListOpts) (fips []l3floatingip.FloatingIP, err error) { done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - page, err := l3floatingip.List(c.NetworkingClient(), opts).AllPages() + page, err := l3floatingip.List(c.NetworkingClient(), opts).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("failed to list L3 floating ip: %v", err) } @@ -97,7 +98,7 @@ func (c *openstackCloud) DeleteFloatingIP(id string) (err error) { func deleteFloatingIP(c OpenstackCloud, id string) (err error) { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err = l3floatingip.Delete(c.ComputeClient(), id).ExtractErr() + err = l3floatingip.Delete(context.TODO(), c.ComputeClient(), id).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("failed to delete floating ip %s: %v", id, err) } @@ -118,7 +119,7 @@ func (c *openstackCloud) DeleteL3FloatingIP(id string) (err error) { func deleteL3FloatingIP(c OpenstackCloud, id string) (err error) { done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - err = l3floatingip.Delete(c.NetworkingClient(), id).ExtractErr() + err = l3floatingip.Delete(context.TODO(), c.NetworkingClient(), id).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("failed to delete L3 floating ip %s: %v", id, err) } diff --git a/upup/pkg/fi/cloudup/openstack/image.go b/upup/pkg/fi/cloudup/openstack/image.go index 35e18150b66c9..693475e785bea 100644 --- a/upup/pkg/fi/cloudup/openstack/image.go +++ b/upup/pkg/fi/cloudup/openstack/image.go @@ -17,9 +17,10 @@ limitations under the License. package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" + "github.com/gophercloud/gophercloud/v2/openstack/image/v2/images" ) func (c *openstackCloud) GetImage(name string) (*images.Image, error) { @@ -29,7 +30,7 @@ func (c *openstackCloud) GetImage(name string) (*images.Image, error) { func getImage(c OpenstackCloud, name string) (*images.Image, error) { opts := images.ListOpts{Name: name} pager := images.List(c.ImageClient(), opts) - page, err := pager.AllPages() + page, err := pager.AllPages(context.TODO()) if err != nil { return nil, fmt.Errorf("failed to list images: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/instance.go b/upup/pkg/fi/cloudup/openstack/instance.go index 75c336b6c606d..36c051229b61d 100644 --- a/upup/pkg/fi/cloudup/openstack/instance.go +++ b/upup/pkg/fi/cloudup/openstack/instance.go @@ -19,16 +19,17 @@ package openstack import ( "context" "fmt" + "net/http" "time" - "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors" "github.com/go-viper/mapstructure/v2" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" - v2pools "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers" + v2pools "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "golang.org/x/sync/errgroup" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" @@ -60,12 +61,12 @@ var floatingBackoff = wait.Backoff{ Steps: 20, } -func (c *openstackCloud) CreateInstance(opt servers.CreateOptsBuilder, portID string) (*servers.Server, error) { - return createInstance(c, opt, portID) +func (c *openstackCloud) CreateInstance(opt servers.CreateOptsBuilder, schedulerHints servers.SchedulerHintOptsBuilder, portID string) (*servers.Server, error) { + return createInstance(c, opt, schedulerHints, portID) } func IsPortInUse(err error) bool { - if _, ok := err.(gophercloud.ErrDefault409); ok { + if gophercloud.ResponseCodeIs(err, http.StatusConflict) { return true } return false @@ -79,8 +80,9 @@ func waitForStatusActive(c OpenstackCloud, serverID string, timeout *time.Durati if timeout == nil { timeout = fi.PtrTo(defaultActiveTimeout) } - - return gophercloud.WaitFor(int(timeout.Seconds()), func() (bool, error) { + ctx, cancel := context.WithTimeout(context.TODO(), time.Duration(timeout.Seconds())*time.Second) + defer cancel() + return gophercloud.WaitFor(ctx, func(_ context.Context) (bool, error) { server, err := c.GetInstance(serverID) if err != nil { return false, err @@ -98,12 +100,12 @@ func waitForStatusActive(c OpenstackCloud, serverID string, timeout *time.Durati }) } -func createInstance(c OpenstackCloud, opt servers.CreateOptsBuilder, portID string) (*servers.Server, error) { +func createInstance(c OpenstackCloud, opt servers.CreateOptsBuilder, schedulerHints servers.SchedulerHintOptsBuilder, portID string) (*servers.Server, error) { var server *servers.Server done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - v, err := servers.Create(c.ComputeClient(), opt).Extract() + v, err := servers.Create(context.TODO(), c.ComputeClient(), opt, schedulerHints).Extract() if err != nil { if IsPortInUse(err) && portID != "" { port, err := c.GetPort(portID) @@ -196,7 +198,7 @@ func (c *openstackCloud) DeleteInstanceWithID(instanceID string) error { func deleteInstanceWithID(c OpenstackCloud, instanceID string) error { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := servers.Delete(c.ComputeClient(), instanceID).ExtractErr() + err := servers.Delete(context.TODO(), c.ComputeClient(), instanceID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting instance: %s", err) } @@ -325,7 +327,7 @@ func getInstance(c OpenstackCloud, id string) (*servers.Server, error) { var server *servers.Server done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - instance, err := servers.Get(c.ComputeClient(), id).Extract() + instance, err := servers.Get(context.TODO(), c.ComputeClient(), id).Extract() if err != nil { return false, err } @@ -349,7 +351,7 @@ func listInstances(c OpenstackCloud, opt servers.ListOptsBuilder) ([]servers.Ser var instances []servers.Server done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := servers.List(c.ComputeClient(), opt).AllPages() + allPages, err := servers.List(c.ComputeClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing servers %v: %v", opt, err) } @@ -377,7 +379,7 @@ func (c *openstackCloud) GetFlavor(name string) (*flavors.Flavor, error) { func getFlavor(c OpenstackCloud, name string) (*flavors.Flavor, error) { opts := flavors.ListOpts{} pager := flavors.ListDetail(c.ComputeClient(), opts) - page, err := pager.AllPages() + page, err := pager.AllPages(context.TODO()) if err != nil { return nil, fmt.Errorf("failed to list flavors: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/instance_test.go b/upup/pkg/fi/cloudup/openstack/instance_test.go index 5d60bab1ae828..dac52777b80d4 100644 --- a/upup/pkg/fi/cloudup/openstack/instance_test.go +++ b/upup/pkg/fi/cloudup/openstack/instance_test.go @@ -17,12 +17,13 @@ limitations under the License. package openstack import ( + "context" "fmt" "testing" "time" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" "k8s.io/kops/upup/pkg/fi" ) @@ -84,6 +85,6 @@ func Test_WaitForStatusActiveResultsInTimeout(t *testing.T) { actualErr := waitForStatusActive(c, serverID, fi.PtrTo(time.Second)) - expectedErr := fmt.Errorf("A timeout occurred") + expectedErr := context.DeadlineExceeded assertTestResults(t, nil, expectedErr, actualErr) } diff --git a/upup/pkg/fi/cloudup/openstack/keypair.go b/upup/pkg/fi/cloudup/openstack/keypair.go index 77ddfc3141984..f527513308bd6 100644 --- a/upup/pkg/fi/cloudup/openstack/keypair.go +++ b/upup/pkg/fi/cloudup/openstack/keypair.go @@ -17,9 +17,10 @@ limitations under the License. package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kops/util/pkg/vfs" ) @@ -31,7 +32,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, nil).Extract() + rs, err := keypairs.Get(context.TODO(), c.ComputeClient(), name, nil).Extract() if err != nil { if isNotFound(err) { return true, nil @@ -58,7 +59,7 @@ func createKeypair(c OpenstackCloud, opt keypairs.CreateOptsBuilder) (*keypairs. var k *keypairs.KeyPair done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - v, err := keypairs.Create(c.ComputeClient(), opt).Extract() + v, err := keypairs.Create(context.TODO(), c.ComputeClient(), opt).Extract() if err != nil { return false, fmt.Errorf("error creating keypair: %v", err) } @@ -80,7 +81,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, nil).ExtractErr() + err := keypairs.Delete(context.TODO(), c.ComputeClient(), name, nil).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting keypair: %v", err) } @@ -105,7 +106,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(), nil).AllPages() + allPages, err := keypairs.List(c.ComputeClient(), nil).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing keypairs: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/loadbalancer.go b/upup/pkg/fi/cloudup/openstack/loadbalancer.go index 618c7cf5e3364..3e96a642cf374 100644 --- a/upup/pkg/fi/cloudup/openstack/loadbalancer.go +++ b/upup/pkg/fi/cloudup/openstack/loadbalancer.go @@ -17,15 +17,17 @@ limitations under the License. package openstack import ( + "context" "fmt" + "net/http" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors" - v2pools "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors" + v2pools "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" "k8s.io/kops/util/pkg/vfs" @@ -49,7 +51,7 @@ func createPoolMonitor(c OpenstackCloud, opts monitors.CreateOpts) (poolMonitor } done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - poolMonitor, err = monitors.Create(c.LoadBalancerClient(), opts).Extract() + poolMonitor, err = monitors.Create(context.TODO(), c.LoadBalancerClient(), opts).Extract() if err != nil { return false, fmt.Errorf("failed to create pool monitor: %v", err) } @@ -73,7 +75,7 @@ func listMonitors(c OpenstackCloud, opts monitors.ListOpts) (monitorList []monit return monitorList, fmt.Errorf("loadbalancer support not available in this deployment") } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := monitors.List(c.LoadBalancerClient(), opts).AllPages() + allPages, err := monitors.List(c.LoadBalancerClient(), opts).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("failed to list monitors: %s", err) } @@ -101,7 +103,7 @@ func deleteMonitor(c OpenstackCloud, monitorID string) error { return fmt.Errorf("loadbalancer support not available in this deployment") } done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := monitors.Delete(c.LoadBalancerClient(), monitorID).ExtractErr() + err := monitors.Delete(context.TODO(), c.LoadBalancerClient(), monitorID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting pool: %v", err) } @@ -129,7 +131,7 @@ func deletePool(c OpenstackCloud, poolID string) error { } done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := v2pools.Delete(c.LoadBalancerClient(), poolID).ExtractErr() + err := v2pools.Delete(context.TODO(), c.LoadBalancerClient(), poolID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting pool: %v", err) } @@ -157,7 +159,7 @@ func deleteListener(c OpenstackCloud, listenerID string) error { } done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := listeners.Delete(c.LoadBalancerClient(), listenerID).ExtractErr() + err := listeners.Delete(context.TODO(), c.LoadBalancerClient(), listenerID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting listener: %v", err) } @@ -185,7 +187,7 @@ func deleteLB(c OpenstackCloud, lbID string, opts loadbalancers.DeleteOpts) erro } done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := loadbalancers.Delete(c.LoadBalancerClient(), lbID, opts).ExtractErr() + err := loadbalancers.Delete(context.TODO(), c.LoadBalancerClient(), lbID, opts).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting loadbalancer: %v", err) } @@ -214,7 +216,7 @@ func createLB(c OpenstackCloud, opt loadbalancers.CreateOptsBuilder) (*loadbalan var i *loadbalancers.LoadBalancer done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - v, err := loadbalancers.Create(c.LoadBalancerClient(), opt).Extract() + v, err := loadbalancers.Create(context.TODO(), c.LoadBalancerClient(), opt).Extract() if err != nil { return false, fmt.Errorf("error creating loadbalancer: %v", err) } @@ -240,7 +242,7 @@ func getLB(c OpenstackCloud, loadbalancerID string) (lb *loadbalancers.LoadBalan } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - lb, err = loadbalancers.Get(c.LoadBalancerClient(), loadbalancerID).Extract() + lb, err = loadbalancers.Get(context.TODO(), c.LoadBalancerClient(), loadbalancerID).Extract() if err != nil { return false, err } @@ -267,7 +269,7 @@ func listLBs(c OpenstackCloud, opt loadbalancers.ListOptsBuilder) (lbs []loadbal } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := loadbalancers.List(c.LoadBalancerClient(), opt).AllPages() + allPages, err := loadbalancers.List(c.LoadBalancerClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("failed to list loadbalancers: %s", err) } @@ -296,7 +298,7 @@ func getLBStats(c OpenstackCloud, loadbalancerID string) (stats *loadbalancers.S } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - stats, err = loadbalancers.GetStats(c.LoadBalancerClient(), loadbalancerID).Extract() + stats, err = loadbalancers.GetStats(context.TODO(), c.LoadBalancerClient(), loadbalancerID).Extract() if err != nil { return false, fmt.Errorf("Error getting load balancer stats %v", err) } @@ -321,7 +323,7 @@ func getPool(c OpenstackCloud, poolID string) (pool *v2pools.Pool, err error) { } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - pool, err = v2pools.Get(c.LoadBalancerClient(), poolID).Extract() + pool, err = v2pools.Get(context.TODO(), c.LoadBalancerClient(), poolID).Extract() if err != nil { return false, err } @@ -346,7 +348,7 @@ func getPoolMember(c OpenstackCloud, poolID string, memberID string) (member *v2 } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - member, err = v2pools.GetMember(c.LoadBalancerClient(), poolID, memberID).Extract() + member, err = v2pools.GetMember(context.TODO(), c.LoadBalancerClient(), poolID, memberID).Extract() if err != nil { return false, err } @@ -371,16 +373,15 @@ func updateMemberInPool(c OpenstackCloud, poolID string, memberID string, opts v } done, err := vfs.RetryWithBackoff(memberBackoff, func() (bool, error) { - association, err = v2pools.UpdateMember(c.LoadBalancerClient(), poolID, memberID, opts).Extract() + association, err = v2pools.UpdateMember(context.TODO(), c.LoadBalancerClient(), poolID, memberID, opts).Extract() if err != nil { // member not found anymore if isNotFound(err) { return true, nil } // pool is currently in immutable state, try to retry - errCode, ok := err.(gophercloud.ErrDefault409) - if ok { - klog.Infof("got error %v retrying...", errCode) + if gophercloud.ResponseCodeIs(err, http.StatusConflict) { + klog.Infof("got error %v retrying...", http.StatusConflict) return false, nil } return false, fmt.Errorf("failed to update pool membership: %v", err) @@ -406,10 +407,10 @@ func associateToPool(c OpenstackCloud, server *servers.Server, poolID string, op } done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - association, err = v2pools.GetMember(c.LoadBalancerClient(), poolID, server.ID).Extract() + association, err = v2pools.GetMember(context.TODO(), c.LoadBalancerClient(), poolID, server.ID).Extract() if err != nil || association == nil { // Pool association does not exist. Create it - association, err = v2pools.CreateMember(c.LoadBalancerClient(), poolID, opts).Extract() + association, err = v2pools.CreateMember(context.TODO(), c.LoadBalancerClient(), poolID, opts).Extract() if err != nil { return false, fmt.Errorf("failed to create pool association: %v", err) } @@ -437,7 +438,7 @@ func createPool(c OpenstackCloud, opts v2pools.CreateOpts) (pool *v2pools.Pool, } done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - pool, err = v2pools.Create(c.LoadBalancerClient(), opts).Extract() + pool, err = v2pools.Create(context.TODO(), c.LoadBalancerClient(), opts).Extract() if err != nil { return false, fmt.Errorf("failed to create pool: %v", err) } @@ -462,7 +463,7 @@ func listPoolMembers(c OpenstackCloud, poolID string, opts v2pools.ListMembersOp } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - memberPage, err := v2pools.ListMembers(c.LoadBalancerClient(), poolID, opts).AllPages() + memberPage, err := v2pools.ListMembers(c.LoadBalancerClient(), poolID, opts).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("failed to list members: %v", err) } @@ -491,7 +492,7 @@ func listPools(c OpenstackCloud, opts v2pools.ListOpts) (poolList []v2pools.Pool } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - poolPage, err := v2pools.List(c.LoadBalancerClient(), opts).AllPages() + poolPage, err := v2pools.List(c.LoadBalancerClient(), opts).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("failed to list pools: %v", err) } @@ -520,7 +521,7 @@ func listListeners(c OpenstackCloud, opts listeners.ListOpts) (listenerList []li } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - listenerPage, err := listeners.List(c.LoadBalancerClient(), opts).AllPages() + listenerPage, err := listeners.List(c.LoadBalancerClient(), opts).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("failed to list listeners: %v", err) } @@ -549,7 +550,7 @@ func createListener(c OpenstackCloud, opts listeners.CreateOpts) (listener *list } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - listener, err = listeners.Create(c.LoadBalancerClient(), opts).Extract() + listener, err = listeners.Create(context.TODO(), c.LoadBalancerClient(), opts).Extract() if err != nil { return false, fmt.Errorf("unabled to create listener: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/mock_cloud.go b/upup/pkg/fi/cloudup/openstack/mock_cloud.go index 99f3e3e90d31c..0627a9481968f 100644 --- a/upup/pkg/fi/cloudup/openstack/mock_cloud.go +++ b/upup/pkg/fi/cloudup/openstack/mock_cloud.go @@ -19,29 +19,29 @@ package openstack import ( "fmt" - "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" - - "github.com/gophercloud/gophercloud" - cinder "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" - az "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets" - "github.com/gophercloud/gophercloud/openstack/dns/v2/zones" - "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors" - v2pools "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" - l3floatingip "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" - sg "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" - sgr "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" - "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors" + + "github.com/gophercloud/gophercloud/v2" + cinder "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" + az "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets" + "github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones" + "github.com/gophercloud/gophercloud/v2/openstack/image/v2/images" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors" + v2pools "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" + l3floatingip "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers" + sg "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" + sgr "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" v1 "k8s.io/api/core/v1" "k8s.io/kops/cloudmock/openstack/mockblockstorage" "k8s.io/kops/cloudmock/openstack/mockcompute" @@ -173,8 +173,8 @@ func (c *MockCloud) AttachVolume(serverID string, opts volumeattach.CreateOpts) return attachVolume(c, serverID, opts) } -func (c *MockCloud) CreateInstance(opt servers.CreateOptsBuilder, portID string) (*servers.Server, error) { - return createInstance(c, opt, portID) +func (c *MockCloud) CreateInstance(opt servers.CreateOptsBuilder, schedulerHints servers.SchedulerHintOptsBuilder, portID string) (*servers.Server, error) { + return createInstance(c, opt, schedulerHints, portID) } func (c *MockCloud) CreateKeypair(opt keypairs.CreateOptsBuilder) (*keypairs.KeyPair, error) { diff --git a/upup/pkg/fi/cloudup/openstack/network.go b/upup/pkg/fi/cloudup/openstack/network.go index aa610623f206f..98bd7b643c952 100644 --- a/upup/pkg/fi/cloudup/openstack/network.go +++ b/upup/pkg/fi/cloudup/openstack/network.go @@ -17,12 +17,13 @@ limitations under the License. package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external" - "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks" + "github.com/gophercloud/gophercloud/v2/pagination" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kops/util/pkg/vfs" ) @@ -33,7 +34,7 @@ func (c *openstackCloud) AppendTag(resource string, id string, tag string) error func appendTag(c OpenstackCloud, resource string, id string, tag string) error { done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - err := attributestags.Add(c.NetworkingClient(), resource, id, tag).ExtractErr() + err := attributestags.Add(context.TODO(), c.NetworkingClient(), resource, id, tag).ExtractErr() if err != nil { return false, fmt.Errorf("error appending tag %s: %v", tag, err) } @@ -54,7 +55,7 @@ func (c *openstackCloud) DeleteTag(resource string, id string, tag string) error func deleteTag(c OpenstackCloud, resource string, id string, tag string) error { done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - err := attributestags.Delete(c.NetworkingClient(), resource, id, tag).ExtractErr() + err := attributestags.Delete(context.TODO(), c.NetworkingClient(), resource, id, tag).ExtractErr() if err != nil { return false, fmt.Errorf("error deleting tag %s: %v", tag, err) } @@ -105,7 +106,7 @@ func (c *openstackCloud) GetNetwork(id string) (*networks.Network, error) { func getNetwork(c OpenstackCloud, id string) (*networks.Network, error) { var network *networks.Network done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - r, err := networks.Get(c.NetworkingClient(), id).Extract() + r, err := networks.Get(context.TODO(), c.NetworkingClient(), id).Extract() if err != nil { return false, fmt.Errorf("error retrieving network with id %s: %v", id, err) } @@ -129,7 +130,7 @@ func listNetworks(c OpenstackCloud, opt networks.ListOptsBuilder) ([]networks.Ne var ns []networks.Network done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := networks.List(c.NetworkingClient(), opt).AllPages() + allPages, err := networks.List(c.NetworkingClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing networks: %v", err) } @@ -161,7 +162,7 @@ func getExternalNetwork(c OpenstackCloud, networkName string) (net *networks.Net } done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - err = networks.List(c.NetworkingClient(), networks.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) { + err = networks.List(c.NetworkingClient(), networks.ListOpts{}).EachPage(context.TODO(), func(ctx context.Context, page pagination.Page) (bool, error) { var externalNetwork []NetworkWithExternalExt err := networks.ExtractNetworksInto(page, &externalNetwork) if err != nil { @@ -198,7 +199,7 @@ func createNetwork(c OpenstackCloud, opt networks.CreateOptsBuilder) (*networks. var n *networks.Network done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - r, err := networks.Create(c.NetworkingClient(), opt).Extract() + r, err := networks.Create(context.TODO(), c.NetworkingClient(), opt).Extract() if err != nil { return false, fmt.Errorf("error creating network: %v", err) } @@ -220,7 +221,7 @@ func (c *openstackCloud) DeleteNetwork(networkID string) error { func deleteNetwork(c OpenstackCloud, networkID string) error { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := networks.Delete(c.NetworkingClient(), networkID).ExtractErr() + err := networks.Delete(context.TODO(), c.NetworkingClient(), networkID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting network: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/port.go b/upup/pkg/fi/cloudup/openstack/port.go index fb35908fce21a..203ea49467c12 100644 --- a/upup/pkg/fi/cloudup/openstack/port.go +++ b/upup/pkg/fi/cloudup/openstack/port.go @@ -17,9 +17,10 @@ limitations under the License. package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kops/util/pkg/vfs" ) @@ -32,7 +33,7 @@ func createPort(c OpenstackCloud, opt ports.CreateOptsBuilder) (*ports.Port, err var p *ports.Port done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - port, err := ports.Create(c.NetworkingClient(), opt).Extract() + port, err := ports.Create(context.TODO(), c.NetworkingClient(), opt).Extract() if err != nil { return false, fmt.Errorf("error creating port: %v", err) } @@ -56,7 +57,7 @@ func updatePort(c OpenstackCloud, id string, opt ports.UpdateOptsBuilder) (*port var p *ports.Port done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - port, err := ports.Update(c.NetworkingClient(), id, opt).Extract() + port, err := ports.Update(context.TODO(), c.NetworkingClient(), id, opt).Extract() if err != nil { return false, err } @@ -80,7 +81,7 @@ func getPort(c OpenstackCloud, id string) (*ports.Port, error) { var p *ports.Port done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - port, err := ports.Get(c.NetworkingClient(), id).Extract() + port, err := ports.Get(context.TODO(), c.NetworkingClient(), id).Extract() if err != nil { return false, err } @@ -104,7 +105,7 @@ func listPorts(c OpenstackCloud, opt ports.ListOptsBuilder) ([]ports.Port, error var p []ports.Port done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := ports.List(c.NetworkingClient(), opt).AllPages() + allPages, err := ports.List(c.NetworkingClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing ports: %v", err) } @@ -131,7 +132,7 @@ func (c *openstackCloud) DeletePort(portID string) error { func deletePort(c OpenstackCloud, portID string) error { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := ports.Delete(c.NetworkingClient(), portID).ExtractErr() + err := ports.Delete(context.TODO(), c.NetworkingClient(), portID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting port: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/router.go b/upup/pkg/fi/cloudup/openstack/router.go index 89b86a187073f..742f9fc12fb24 100644 --- a/upup/pkg/fi/cloudup/openstack/router.go +++ b/upup/pkg/fi/cloudup/openstack/router.go @@ -17,9 +17,10 @@ limitations under the License. package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kops/util/pkg/vfs" ) @@ -32,7 +33,7 @@ func listRouters(c OpenstackCloud, opt routers.ListOpts) ([]routers.Router, erro var rs []routers.Router done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := routers.List(c.NetworkingClient(), opt).AllPages() + allPages, err := routers.List(c.NetworkingClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing routers: %v", err) } @@ -61,7 +62,7 @@ func createRouter(c OpenstackCloud, opt routers.CreateOptsBuilder) (*routers.Rou var r *routers.Router done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - v, err := routers.Create(c.NetworkingClient(), opt).Extract() + v, err := routers.Create(context.TODO(), c.NetworkingClient(), opt).Extract() if err != nil { return false, fmt.Errorf("error creating router: %v", err) } @@ -85,7 +86,7 @@ func createRouterInterface(c OpenstackCloud, routerID string, opt routers.AddInt var i *routers.InterfaceInfo done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - v, err := routers.AddInterface(c.NetworkingClient(), routerID, opt).Extract() + v, err := routers.AddInterface(context.TODO(), c.NetworkingClient(), routerID, opt).Extract() if err != nil { return false, fmt.Errorf("error creating router interface: %v", err) } @@ -107,7 +108,7 @@ func (c *openstackCloud) DeleteRouterInterface(routerID string, opt routers.Remo func deleteRouterInterface(c OpenstackCloud, routerID string, opt routers.RemoveInterfaceOptsBuilder) error { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - _, err := routers.RemoveInterface(c.NetworkingClient(), routerID, opt).Extract() + _, err := routers.RemoveInterface(context.TODO(), c.NetworkingClient(), routerID, opt).Extract() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting router interface: %v", err) } @@ -131,7 +132,7 @@ func (c *openstackCloud) DeleteRouter(routerID string) error { func deleteRouter(c OpenstackCloud, routerID string) error { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := routers.Delete(c.NetworkingClient(), routerID).ExtractErr() + err := routers.Delete(context.TODO(), c.NetworkingClient(), routerID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting router: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/security_group.go b/upup/pkg/fi/cloudup/openstack/security_group.go index 06efaa057a14e..1b94634b34727 100644 --- a/upup/pkg/fi/cloudup/openstack/security_group.go +++ b/upup/pkg/fi/cloudup/openstack/security_group.go @@ -17,10 +17,11 @@ limitations under the License. package openstack import ( + "context" "fmt" - sg "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" - sgr "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" + sg "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" + sgr "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kops/util/pkg/vfs" ) @@ -33,7 +34,7 @@ func listSecurityGroups(c OpenstackCloud, opt sg.ListOpts) ([]sg.SecGroup, error var groups []sg.SecGroup done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := sg.List(c.NetworkingClient(), opt).AllPages() + allPages, err := sg.List(c.NetworkingClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing security groups %v: %v", opt, err) } @@ -62,7 +63,7 @@ func createSecurityGroup(c OpenstackCloud, opt sg.CreateOptsBuilder) (*sg.SecGro var group *sg.SecGroup done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - g, err := sg.Create(c.NetworkingClient(), opt).Extract() + g, err := sg.Create(context.TODO(), c.NetworkingClient(), opt).Extract() if err != nil { return false, fmt.Errorf("error creating security group %v: %v", opt, err) } @@ -86,7 +87,7 @@ func listSecurityGroupRules(c OpenstackCloud, opt sgr.ListOpts) ([]sgr.SecGroupR var rules []sgr.SecGroupRule done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := sgr.List(c.NetworkingClient(), opt).AllPages() + allPages, err := sgr.List(c.NetworkingClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing security group rules %v: %v", opt, err) } @@ -115,7 +116,7 @@ func createSecurityGroupRule(c OpenstackCloud, opt sgr.CreateOptsBuilder) (*sgr. var rule *sgr.SecGroupRule done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - r, err := sgr.Create(c.NetworkingClient(), opt).Extract() + r, err := sgr.Create(context.TODO(), c.NetworkingClient(), opt).Extract() if err != nil { return false, fmt.Errorf("error creating security group rule %v: %v", opt, err) } @@ -137,7 +138,7 @@ func (c *openstackCloud) DeleteSecurityGroup(sgID string) error { func deleteSecurityGroup(c OpenstackCloud, sgID string) error { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := sg.Delete(c.NetworkingClient(), sgID).ExtractErr() + err := sg.Delete(context.TODO(), c.NetworkingClient(), sgID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting security group: %v", err) } @@ -161,7 +162,7 @@ func (c *openstackCloud) DeleteSecurityGroupRule(ruleID string) error { func deleteSecurityGroupRule(c OpenstackCloud, ruleID string) error { done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - err := sgr.Delete(c.NetworkingClient(), ruleID).ExtractErr() + err := sgr.Delete(context.TODO(), c.NetworkingClient(), ruleID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting security group rule: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/server_group.go b/upup/pkg/fi/cloudup/openstack/server_group.go index d11ad80496100..483d9c3a38a04 100644 --- a/upup/pkg/fi/cloudup/openstack/server_group.go +++ b/upup/pkg/fi/cloudup/openstack/server_group.go @@ -17,11 +17,12 @@ limitations under the License. package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" @@ -39,7 +40,7 @@ func createServerGroup(c OpenstackCloud, opt servergroups.CreateOptsBuilder) (*s var i *servergroups.ServerGroup done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - v, err := servergroups.Create(c.ComputeClient(), opt).Extract() + v, err := servergroups.Create(context.TODO(), c.ComputeClient(), opt).Extract() if err != nil { return false, fmt.Errorf("error creating server group: %v", err) } @@ -63,7 +64,7 @@ func listServerGroups(c OpenstackCloud, opts servergroups.ListOptsBuilder) ([]se var sgs []servergroups.ServerGroup done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := servergroups.List(c.ComputeClient(), opts).AllPages() + allPages, err := servergroups.List(c.ComputeClient(), opts).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing server groups: %v", err) } @@ -141,7 +142,7 @@ func (c *openstackCloud) DeleteServerGroup(groupID string) error { func deleteServerGroup(c OpenstackCloud, groupID string) error { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := servergroups.Delete(c.ComputeClient(), groupID).ExtractErr() + err := servergroups.Delete(context.TODO(), c.ComputeClient(), groupID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting server group: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/status.go b/upup/pkg/fi/cloudup/openstack/status.go index 1dc35b6a50db7..4292ca56fffcb 100644 --- a/upup/pkg/fi/cloudup/openstack/status.go +++ b/upup/pkg/fi/cloudup/openstack/status.go @@ -33,7 +33,7 @@ import ( "fmt" "strings" - cinderv3 "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" + cinderv3 "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" "k8s.io/klog/v2" "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/protokube/pkg/etcd" diff --git a/upup/pkg/fi/cloudup/openstack/subnet.go b/upup/pkg/fi/cloudup/openstack/subnet.go index 7908f1866cfcd..1fddc9de54fff 100644 --- a/upup/pkg/fi/cloudup/openstack/subnet.go +++ b/upup/pkg/fi/cloudup/openstack/subnet.go @@ -17,9 +17,10 @@ limitations under the License. package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/util/pkg/vfs" @@ -33,7 +34,7 @@ func listSubnets(c OpenstackCloud, opt subnets.ListOptsBuilder) ([]subnets.Subne var s []subnets.Subnet done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := subnets.List(c.NetworkingClient(), opt).AllPages() + allPages, err := subnets.List(c.NetworkingClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing subnets: %v", err) } @@ -61,7 +62,7 @@ func (c *openstackCloud) GetSubnet(subnetID string) (*subnets.Subnet, error) { func getSubnet(c OpenstackCloud, subnetID string) (*subnets.Subnet, error) { var subnet *subnets.Subnet done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - sub, err := subnets.Get(c.NetworkingClient(), subnetID).Extract() + sub, err := subnets.Get(context.TODO(), c.NetworkingClient(), subnetID).Extract() if err != nil { return false, fmt.Errorf("error retrieving subnet: %v", err) } @@ -85,7 +86,7 @@ func createSubnet(c OpenstackCloud, opt subnets.CreateOptsBuilder) (*subnets.Sub var s *subnets.Subnet done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - v, err := subnets.Create(c.NetworkingClient(), opt).Extract() + v, err := subnets.Create(context.TODO(), c.NetworkingClient(), opt).Extract() if err != nil { return false, fmt.Errorf("error creating subnet: %v", err) } @@ -107,7 +108,7 @@ func (c *openstackCloud) DeleteSubnet(subnetID string) error { func deleteSubnet(c OpenstackCloud, subnetID string) error { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := subnets.Delete(c.NetworkingClient(), subnetID).ExtractErr() + err := subnets.Delete(context.TODO(), c.NetworkingClient(), subnetID).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting subnet: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/utils.go b/upup/pkg/fi/cloudup/openstack/utils.go index c5a8372fba84b..7a59b8f9cb840 100644 --- a/upup/pkg/fi/cloudup/openstack/utils.go +++ b/upup/pkg/fi/cloudup/openstack/utils.go @@ -17,11 +17,12 @@ limitations under the License. package openstack import ( + "context" "fmt" "sort" - "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" "k8s.io/kops/pkg/apis/kops" ) @@ -58,7 +59,7 @@ func (c *openstackCloud) DefaultInstanceType(cluster *kops.Cluster, ig *kops.Ins func defaultInstanceType(c OpenstackCloud, cluster *kops.Cluster, ig *kops.InstanceGroup) (string, error) { flavorPage, err := flavors.ListDetail(c.ComputeClient(), flavors.ListOpts{ MinRAM: 1024, - }).AllPages() + }).AllPages(context.TODO()) if err != nil { return "", fmt.Errorf("Could not list flavors: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstack/verifier.go b/upup/pkg/fi/cloudup/openstack/verifier.go index 17b7c92c55d65..07da13a945f64 100644 --- a/upup/pkg/fi/cloudup/openstack/verifier.go +++ b/upup/pkg/fi/cloudup/openstack/verifier.go @@ -26,9 +26,9 @@ import ( "strings" "github.com/go-viper/mapstructure/v2" - "github.com/gophercloud/gophercloud" - gos "github.com/gophercloud/gophercloud/openstack" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2" + gos "github.com/gophercloud/gophercloud/v2/openstack" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" "k8s.io/apimachinery/pkg/api/errors" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -72,7 +72,7 @@ func NewOpenstackVerifier(opt *OpenStackVerifierOptions) (bootstrap.Verifier, er // node-controller should be able to renew it tokens against OpenStack API env.AllowReauth = true - err = gos.Authenticate(provider, env) + err = gos.Authenticate(context.TODO(), provider, env) if err != nil { return nil, err } @@ -126,7 +126,7 @@ func (o openstackVerifier) VerifyToken(ctx context.Context, rawRequest *http.Req } serverID := strings.TrimPrefix(token, OpenstackAuthenticationTokenPrefix) - instance, err := servers.Get(o.novaClient, serverID).Extract() + instance, err := servers.Get(context.TODO(), o.novaClient, serverID).Extract() if err != nil { return nil, fmt.Errorf("failed to get info for server %q: %w", token, err) } diff --git a/upup/pkg/fi/cloudup/openstack/volume.go b/upup/pkg/fi/cloudup/openstack/volume.go index 6f65ba378386f..439cdc3d6387e 100644 --- a/upup/pkg/fi/cloudup/openstack/volume.go +++ b/upup/pkg/fi/cloudup/openstack/volume.go @@ -17,10 +17,11 @@ limitations under the License. package openstack import ( + "context" "fmt" - cinder "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach" + cinder "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" "k8s.io/kops/util/pkg/vfs" @@ -34,7 +35,7 @@ func listVolumes(c OpenstackCloud, opt cinder.ListOptsBuilder) ([]cinder.Volume, var volumes []cinder.Volume done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) { - allPages, err := cinder.List(c.BlockStorageClient(), opt).AllPages() + allPages, err := cinder.List(c.BlockStorageClient(), opt).AllPages(context.TODO()) if err != nil { return false, fmt.Errorf("error listing volumes %v: %v", opt, err) } @@ -63,7 +64,7 @@ func createVolume(c OpenstackCloud, opt cinder.CreateOptsBuilder) (*cinder.Volum var volume *cinder.Volume done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - v, err := cinder.Create(c.BlockStorageClient(), opt).Extract() + v, err := cinder.Create(context.TODO(), c.BlockStorageClient(), opt, nil).Extract() if err != nil { return false, fmt.Errorf("error creating volume %v: %v", opt, err) } @@ -85,7 +86,7 @@ func (c *openstackCloud) AttachVolume(serverID string, opts volumeattach.CreateO func attachVolume(c OpenstackCloud, serverID string, opts volumeattach.CreateOpts) (attachment *volumeattach.VolumeAttachment, err error) { done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - volumeAttachment, err := volumeattach.Create(c.ComputeClient(), serverID, opts).Extract() + volumeAttachment, err := volumeattach.Create(context.TODO(), c.ComputeClient(), serverID, opts).Extract() if err != nil { return false, fmt.Errorf("error attaching volume %s to server %s: %v", opts.VolumeID, serverID, err) } @@ -116,7 +117,7 @@ func setVolumeTags(c OpenstackCloud, id string, tags map[string]string) error { opt := cinder.UpdateOpts{Metadata: tags} done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) { - _, err := cinder.Update(c.BlockStorageClient(), id, opt).Extract() + _, err := cinder.Update(context.TODO(), c.BlockStorageClient(), id, opt).Extract() if err != nil { return false, fmt.Errorf("error setting tags to cinder volume %q: %v", id, err) } @@ -137,7 +138,7 @@ func (c *openstackCloud) DeleteVolume(volumeID string) error { func deleteVolume(c OpenstackCloud, volumeID string) error { done, err := vfs.RetryWithBackoff(deleteBackoff, func() (bool, error) { - err := cinder.Delete(c.BlockStorageClient(), volumeID, cinder.DeleteOpts{}).ExtractErr() + err := cinder.Delete(context.TODO(), c.BlockStorageClient(), volumeID, cinder.DeleteOpts{}).ExtractErr() if err != nil && !isNotFound(err) { return false, fmt.Errorf("error deleting volume: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstacktasks/floatingip.go b/upup/pkg/fi/cloudup/openstacktasks/floatingip.go index e0c76d311f950..6d2c0eecc7363 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/floatingip.go +++ b/upup/pkg/fi/cloudup/openstacktasks/floatingip.go @@ -17,13 +17,14 @@ limitations under the License. package openstacktasks import ( + "context" "fmt" "strings" "time" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" - l3floatingip "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" + l3floatingip "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" "k8s.io/kops/pkg/wellknownservices" @@ -298,7 +299,7 @@ func (f *FloatingIP) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, chan return nil } if changes.Name != nil { - _, err := l3floatingip.Update(cloud.NetworkingClient(), fi.ValueOf(a.ID), l3floatingip.UpdateOpts{ + _, err := l3floatingip.Update(context.TODO(), cloud.NetworkingClient(), fi.ValueOf(a.ID), l3floatingip.UpdateOpts{ Description: e.Name, }).Extract() if err != nil { diff --git a/upup/pkg/fi/cloudup/openstacktasks/instance.go b/upup/pkg/fi/cloudup/openstacktasks/instance.go index 658d22c4356ae..a0eaa36aa9225 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/instance.go +++ b/upup/pkg/fi/cloudup/openstacktasks/instance.go @@ -17,18 +17,17 @@ limitations under the License. package openstacktasks import ( + "context" "fmt" "strconv" "strings" - l3floatingip "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + l3floatingip "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" "k8s.io/klog/v2" "k8s.io/kops/pkg/truncate" "k8s.io/kops/pkg/wellknownservices" @@ -366,24 +365,18 @@ func (_ *Instance) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, change if e.AvailabilityZone != nil { opt.AvailabilityZone = fi.ValueOf(e.AvailabilityZone) } + if opt, err = includeBootVolumeOptions(t, e, opt); err != nil { + return err + } + keyext := keypairs.CreateOptsExt{ CreateOptsBuilder: opt, KeyName: openstackKeyPairName(fi.ValueOf(e.SSHKey)), } - sgext := schedulerhints.CreateOptsExt{ - CreateOptsBuilder: keyext, - SchedulerHints: &schedulerhints.SchedulerHints{ - Group: *e.ServerGroup.ID, - }, - } - - opts, err := includeBootVolumeOptions(t, e, sgext) - if err != nil { - return err - } + schedulerHints := servers.SchedulerHintOpts{Group: *e.ServerGroup.ID} - v, err := t.Cloud.CreateInstance(opts, fi.ValueOf(e.Port.ID)) + v, err := t.Cloud.CreateInstance(keyext, schedulerHints, fi.ValueOf(e.Port.ID)) if err != nil { return fmt.Errorf("Error creating instance: %v", err) } @@ -401,7 +394,7 @@ func (_ *Instance) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, change return nil } if changes.Port != nil { - _, err := attachinterfaces.Create(cloud.ComputeClient(), fi.ValueOf(e.ID), attachinterfaces.CreateOpts{ + _, err := attachinterfaces.Create(context.TODO(), cloud.ComputeClient(), fi.ValueOf(e.ID), attachinterfaces.CreateOpts{ PortID: fi.ValueOf(changes.Port.ID), }).Extract() if err != nil { @@ -420,7 +413,7 @@ func (_ *Instance) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, change func associateFloatingIP(t *openstack.OpenstackAPITarget, e *Instance) error { client := t.Cloud.NetworkingClient() - _, err := l3floatingip.Update(client, fi.ValueOf(e.FloatingIP.ID), l3floatingip.UpdateOpts{ + _, err := l3floatingip.Update(context.TODO(), client, fi.ValueOf(e.FloatingIP.ID), l3floatingip.UpdateOpts{ PortID: e.Port.ID, }).Extract() if err != nil { @@ -429,38 +422,36 @@ func associateFloatingIP(t *openstack.OpenstackAPITarget, e *Instance) error { return nil } -func includeBootVolumeOptions(t *openstack.OpenstackAPITarget, e *Instance, opts servers.CreateOptsBuilder) (servers.CreateOptsBuilder, error) { +func includeBootVolumeOptions(t *openstack.OpenstackAPITarget, e *Instance, opts servers.CreateOpts) (servers.CreateOpts, error) { if !bootFromVolume(e.Metadata) { return opts, nil } i, err := t.Cloud.GetImage(fi.ValueOf(e.Image)) if err != nil { - return nil, fmt.Errorf("Error getting image information: %v", err) + return servers.CreateOpts{}, fmt.Errorf("Error getting image information: %v", err) } - bfv := bootfromvolume.CreateOptsExt{ - CreateOptsBuilder: opts, - BlockDevice: []bootfromvolume.BlockDevice{{ - BootIndex: 0, - DeleteOnTermination: true, - DestinationType: "volume", - SourceType: "image", - UUID: i.ID, - VolumeSize: i.MinDiskGigabytes, - }}, + blockDevice := servers.BlockDevice{ + BootIndex: 0, + DeleteOnTermination: true, + DestinationType: "volume", + SourceType: "image", + UUID: i.ID, + VolumeSize: i.MinDiskGigabytes, } if s, ok := e.Metadata[openstack.BOOT_VOLUME_SIZE]; ok { i, err := strconv.ParseInt(s, 10, 64) if err != nil { - return nil, fmt.Errorf("Invalid value for %v: %v", openstack.BOOT_VOLUME_SIZE, err) + return servers.CreateOpts{}, fmt.Errorf("Invalid value for %v: %v", openstack.BOOT_VOLUME_SIZE, err) } - bfv.BlockDevice[0].VolumeSize = int(i) + blockDevice.VolumeSize = int(i) } - return bfv, nil + opts.BlockDevice = []servers.BlockDevice{blockDevice} + return opts, nil } func bootFromVolume(m map[string]string) bool { diff --git a/upup/pkg/fi/cloudup/openstacktasks/instance_test.go b/upup/pkg/fi/cloudup/openstacktasks/instance_test.go index d28aaa4bd5c5c..728c050772408 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/instance_test.go +++ b/upup/pkg/fi/cloudup/openstacktasks/instance_test.go @@ -21,7 +21,7 @@ import ( "reflect" "testing" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "k8s.io/kops/pkg/truncate" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" ) diff --git a/upup/pkg/fi/cloudup/openstacktasks/lb.go b/upup/pkg/fi/cloudup/openstacktasks/lb.go index cb00bd421cc57..1e55fbecb3357 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lb.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lb.go @@ -17,14 +17,15 @@ limitations under the License. package openstacktasks import ( + "context" "fmt" "time" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" @@ -66,7 +67,7 @@ func waitLoadbalancerActiveProvisioningStatus(client *gophercloud.ServiceClient, var provisioningStatus string err := wait.ExponentialBackoff(backoff, func() (bool, error) { - loadbalancer, err := loadbalancers.Get(client, loadbalancerID).Extract() + loadbalancer, err := loadbalancers.Get(context.TODO(), client, loadbalancerID).Extract() if err != nil { return false, err } @@ -109,7 +110,7 @@ func (s *LB) CompareWithID() *string { func NewLBTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecycle, lb *loadbalancers.LoadBalancer, find *LB) (*LB, error) { osCloud := cloud - sub, err := subnets.Get(osCloud.NetworkingClient(), lb.VipSubnetID).Extract() + sub, err := subnets.Get(context.TODO(), osCloud.NetworkingClient(), lb.VipSubnetID).Extract() if err != nil { return nil, err } @@ -155,7 +156,7 @@ func (s *LB) Find(context *fi.CloudupContext) (*LB, error) { cloud := context.T.Cloud.(openstack.OpenstackCloud) lbPage, err := loadbalancers.List(cloud.LoadBalancerClient(), loadbalancers.ListOpts{ Name: fi.ValueOf(s.Name), - }).AllPages() + }).AllPages(context.Context()) if err != nil { return nil, fmt.Errorf("Failed to retrieve loadbalancers for name %s: %v", fi.ValueOf(s.Name), err) } @@ -228,7 +229,7 @@ func (_ *LB) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *LB) opts := ports.UpdateOpts{ SecurityGroups: &[]string{fi.ValueOf(e.SecurityGroup.ID)}, } - _, err = ports.Update(t.Cloud.NetworkingClient(), lb.VipPortID, opts).Extract() + _, err = ports.Update(context.TODO(), t.Cloud.NetworkingClient(), lb.VipPortID, opts).Extract() if err != nil { return fmt.Errorf("Failed to update security group for port %s: %v", lb.VipPortID, err) } @@ -247,7 +248,7 @@ func (_ *LB) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *LB) opts := ports.UpdateOpts{ SecurityGroups: &[]string{fi.ValueOf(e.SecurityGroup.ID)}, } - _, err = ports.Update(t.Cloud.NetworkingClient(), fi.ValueOf(a.PortID), opts).Extract() + _, err = ports.Update(context.TODO(), t.Cloud.NetworkingClient(), fi.ValueOf(a.PortID), opts).Extract() if err != nil { return fmt.Errorf("Failed to update security group for port %s: %v", fi.ValueOf(a.PortID), err) } diff --git a/upup/pkg/fi/cloudup/openstacktasks/lblistener.go b/upup/pkg/fi/cloudup/openstacktasks/lblistener.go index f6b99d501cb96..d3703270a3e8a 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lblistener.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lblistener.go @@ -17,10 +17,11 @@ limitations under the License. package openstacktasks import ( + "context" "fmt" "sort" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" @@ -172,7 +173,7 @@ func (_ *LBListener) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, chan opts := listeners.UpdateOpts{ AllowedCIDRs: &changes.AllowedCIDRs, } - _, err := listeners.Update(t.Cloud.LoadBalancerClient(), fi.ValueOf(a.ID), opts).Extract() + _, err := listeners.Update(context.TODO(), t.Cloud.LoadBalancerClient(), fi.ValueOf(a.ID), opts).Extract() if err != nil { return fmt.Errorf("error updating LB listener: %v", err) } diff --git a/upup/pkg/fi/cloudup/openstacktasks/lbpool.go b/upup/pkg/fi/cloudup/openstacktasks/lbpool.go index 5c7c8a2194465..7818464d8e306 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lbpool.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lbpool.go @@ -19,7 +19,7 @@ package openstacktasks import ( "fmt" - v2pools "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" + v2pools "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/upup/pkg/fi/cloudup/openstacktasks/network.go b/upup/pkg/fi/cloudup/openstacktasks/network.go index 7f7496d31b25d..2763cf2e58991 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/network.go +++ b/upup/pkg/fi/cloudup/openstacktasks/network.go @@ -19,7 +19,7 @@ package openstacktasks import ( "fmt" - "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go b/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go index 97bb46554293d..90cc8bb8e4333 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go +++ b/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go @@ -19,10 +19,10 @@ package openstacktasks import ( "fmt" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud" - v2pools "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2" + v2pools "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" "k8s.io/kops/util/pkg/vfs" diff --git a/upup/pkg/fi/cloudup/openstacktasks/poolmonitor.go b/upup/pkg/fi/cloudup/openstacktasks/poolmonitor.go index 3ff75d53a2866..6c1e9afbce437 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/poolmonitor.go +++ b/upup/pkg/fi/cloudup/openstacktasks/poolmonitor.go @@ -19,7 +19,7 @@ package openstacktasks import ( "fmt" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/upup/pkg/fi/cloudup/openstacktasks/port.go b/upup/pkg/fi/cloudup/openstacktasks/port.go index c190f417b3a3b..75ec9aa8cc743 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/port.go +++ b/upup/pkg/fi/cloudup/openstacktasks/port.go @@ -21,8 +21,8 @@ import ( "sort" "strings" - secgroup "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + secgroup "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "k8s.io/klog/v2" "k8s.io/kops/pkg/wellknownservices" "k8s.io/kops/upup/pkg/fi" diff --git a/upup/pkg/fi/cloudup/openstacktasks/port_test.go b/upup/pkg/fi/cloudup/openstacktasks/port_test.go index a05a9de6f9b8c..8d709d01a7e7a 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/port_test.go +++ b/upup/pkg/fi/cloudup/openstacktasks/port_test.go @@ -22,8 +22,8 @@ import ( "sort" "testing" - sg "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + sg "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/upup/pkg/fi" diff --git a/upup/pkg/fi/cloudup/openstacktasks/router.go b/upup/pkg/fi/cloudup/openstacktasks/router.go index 311d44122a94e..8f168ecb28abd 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/router.go +++ b/upup/pkg/fi/cloudup/openstacktasks/router.go @@ -19,7 +19,7 @@ package openstacktasks import ( "fmt" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go b/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go index c5ffb14ee792c..adb3be3967bba 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go +++ b/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go @@ -19,8 +19,8 @@ package openstacktasks import ( "fmt" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go b/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go index d46e464dad143..d3e800c6cbd30 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go +++ b/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go @@ -21,8 +21,8 @@ import ( "strconv" "strings" - sg "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" - sgr "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" + sg "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups" + sgr "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go b/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go index 0c0045128ee3e..0de28334a2849 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go +++ b/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go @@ -19,7 +19,7 @@ package openstacktasks import ( "fmt" - sgr "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" + sgr "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" @@ -232,7 +232,7 @@ func (o *SecurityGroupRule) FindDeletions(c *fi.CloudupContext) ([]fi.CloudupDel return nil, nil } cloud := c.T.Cloud.(openstack.OpenstackCloud) - rule, err := sgr.Get(cloud.NetworkingClient(), fi.ValueOf(o.ID)).Extract() + rule, err := sgr.Get(c.Context(), cloud.NetworkingClient(), fi.ValueOf(o.ID)).Extract() if err != nil { return nil, err } diff --git a/upup/pkg/fi/cloudup/openstacktasks/servergroup.go b/upup/pkg/fi/cloudup/openstacktasks/servergroup.go index 9a5835f49e37d..a74cd64642001 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/servergroup.go +++ b/upup/pkg/fi/cloudup/openstacktasks/servergroup.go @@ -20,8 +20,8 @@ import ( "fmt" "strings" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/upup/pkg/fi/cloudup/openstacktasks/sshkey.go b/upup/pkg/fi/cloudup/openstacktasks/sshkey.go index de6462ae5a170..d07d77bcdc951 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/sshkey.go +++ b/upup/pkg/fi/cloudup/openstacktasks/sshkey.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs" "k8s.io/klog/v2" "k8s.io/kops/pkg/pki" diff --git a/upup/pkg/fi/cloudup/openstacktasks/subnet.go b/upup/pkg/fi/cloudup/openstacktasks/subnet.go index ea84e57d3a9c8..7dcff60eec5ae 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/subnet.go +++ b/upup/pkg/fi/cloudup/openstacktasks/subnet.go @@ -17,10 +17,11 @@ limitations under the License. package openstacktasks import ( + "context" "fmt" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" @@ -190,7 +191,7 @@ func (*Subnet) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *S } opt.DNSNameservers = &dnsNameSrv } - result := subnets.Update(client, fi.ValueOf(a.ID), opt) + result := subnets.Update(context.TODO(), client, fi.ValueOf(a.ID), opt) klog.Infof("Updated %v", opt) if result.Err != nil { return fmt.Errorf("error updating subnet %v: %v", a.ID, result.Err) diff --git a/upup/pkg/fi/cloudup/openstacktasks/volume.go b/upup/pkg/fi/cloudup/openstacktasks/volume.go index 3dd266b68f4eb..1c2e170bf8813 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/volume.go +++ b/upup/pkg/fi/cloudup/openstacktasks/volume.go @@ -19,7 +19,7 @@ package openstacktasks import ( "fmt" - cinderv3 "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes" + cinderv3 "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes" "k8s.io/klog/v2" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" diff --git a/util/pkg/vfs/context.go b/util/pkg/vfs/context.go index cef1aa5dea757..7cde7aae23822 100644 --- a/util/pkg/vfs/context.go +++ b/util/pkg/vfs/context.go @@ -30,7 +30,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" awsconfig "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" "google.golang.org/api/option" storage "google.golang.org/api/storage/v1" "k8s.io/apimachinery/pkg/util/wait" diff --git a/util/pkg/vfs/swiftfs.go b/util/pkg/vfs/swiftfs.go index 37b3278ce7e22..1d56f18c2553f 100644 --- a/util/pkg/vfs/swiftfs.go +++ b/util/pkg/vfs/swiftfs.go @@ -32,11 +32,11 @@ import ( "time" "github.com/go-ini/ini" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack" - swiftcontainer "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers" - swiftobject "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack" + swiftcontainer "github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers" + swiftobject "github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects" + "github.com/gophercloud/gophercloud/v2/pagination" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/util/homedir" "k8s.io/klog/v2" @@ -70,7 +70,7 @@ func NewSwiftClient(ctx context.Context) (*gophercloud.ServiceClient, error) { klog.V(2).Info("authenticating to keystone") - err = openstack.Authenticate(pc, authOption) + err = openstack.Authenticate(context.TODO(), pc, authOption) if err != nil { return nil, fmt.Errorf("error building openstack authenticated client: %v", err) } @@ -288,7 +288,7 @@ func (p *SwiftPath) Remove(ctx context.Context) error { return false, err } opt := swiftobject.DeleteOpts{} - if _, err := swiftobject.Delete(client, p.bucket, p.key, opt).Extract(); err != nil { + if _, err := swiftobject.Delete(ctx, client, p.bucket, p.key, opt).Extract(); err != nil { if isSwiftNotFound(err) { return true, os.ErrNotExist } @@ -337,7 +337,7 @@ func (p *SwiftPath) RemoveAll(ctx context.Context) error { if err != nil { return false, err } - if _, err := swiftobject.BulkDelete(client, p.bucket, objectsToDelete).Extract(); err != nil { + if _, err := swiftobject.BulkDelete(ctx, client, p.bucket, objectsToDelete).Extract(); err != nil { if isSwiftNotFound(err) { return true, os.ErrNotExist } @@ -386,7 +386,7 @@ func (p *SwiftPath) WriteFile(ctx context.Context, data io.ReadSeeker, acl ACL) } createOpts := swiftobject.CreateOpts{Content: data} - if _, err := swiftobject.Create(client, p.bucket, p.key, createOpts).Extract(); err != nil { + if _, err := swiftobject.Create(ctx, client, p.bucket, p.key, createOpts).Extract(); err != nil { return false, fmt.Errorf("error writing %s: %v", p, err) } @@ -421,7 +421,7 @@ func (p *SwiftPath) CreateFile(ctx context.Context, data io.ReadSeeker, acl ACL) if _, err := RetryWithBackoff(swiftReadBackoff, func() (bool, error) { klog.V(4).Infof("Getting file %q", p) - _, err := swiftobject.Get(client, p.bucket, p.key, swiftobject.GetOpts{}).Extract() + _, err := swiftobject.Get(ctx, client, p.bucket, p.key, swiftobject.GetOpts{}).Extract() if err == nil { return true, nil } else if isSwiftNotFound(err) { @@ -452,12 +452,12 @@ func (p *SwiftPath) createBucket() error { return false, err } - if _, err := swiftcontainer.Get(client, p.bucket, swiftcontainer.GetOpts{}).Extract(); err == nil { + if _, err := swiftcontainer.Get(ctx, client, p.bucket, swiftcontainer.GetOpts{}).Extract(); err == nil { return true, nil } if isSwiftNotFound(err) { createOpts := swiftcontainer.CreateOpts{} - _, err = swiftcontainer.Create(client, p.bucket, createOpts).Extract() + _, err = swiftcontainer.Create(ctx, client, p.bucket, createOpts).Extract() return err == nil, err } return false, err @@ -510,7 +510,7 @@ func (p *SwiftPath) WriteTo(out io.Writer) (int64, error) { } opt := swiftobject.DownloadOpts{} - result := swiftobject.Download(client, p.bucket, p.key, opt) + result := swiftobject.Download(ctx, client, p.bucket, p.key, opt) if result.Err != nil { if isSwiftNotFound(result.Err) { return 0, os.ErrNotExist @@ -534,7 +534,7 @@ func (p *SwiftPath) readPath(opt swiftobject.ListOpts) ([]Path, error) { var paths []Path pager := swiftobject.List(client, p.bucket, opt) - if err := pager.EachPage(func(page pagination.Page) (bool, error) { + if err := pager.EachPage(context.TODO(), func(ctx context.Context, page pagination.Page) (bool, error) { objects, err1 := swiftobject.ExtractInfo(page) if err1 != nil { return false, err1 @@ -576,7 +576,6 @@ func (p *SwiftPath) ReadDir() ([]Path, error) { prefix += "/" } opt := swiftobject.ListOpts{ - Full: true, Path: prefix, } return p.readPath(opt) @@ -589,7 +588,6 @@ func (p *SwiftPath) ReadTree(ctx context.Context) ([]Path, error) { prefix += "/" } opt := swiftobject.ListOpts{ - Full: true, Prefix: prefix, } return p.readPath(opt) @@ -622,9 +620,5 @@ func (p *SwiftPath) Hash(a hashing.HashAlgorithm) (*hashing.Hash, error) { } func isSwiftNotFound(err error) bool { - if err == nil { - return false - } - _, ok := err.(gophercloud.ErrDefault404) - return ok + return gophercloud.ResponseCodeIs(err, http.StatusNotFound) } diff --git a/vendor/github.com/gophercloud/gophercloud/README.md b/vendor/github.com/gophercloud/gophercloud/README.md deleted file mode 100644 index 4e6e57dadb273..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/README.md +++ /dev/null @@ -1,172 +0,0 @@ -# Gophercloud: an OpenStack SDK for Go -[![Coverage Status](https://coveralls.io/repos/github/gophercloud/gophercloud/badge.svg?branch=v1)](https://coveralls.io/github/gophercloud/gophercloud?branch=v1) - -Gophercloud is an OpenStack Go SDK. - -## Useful links - -* [Reference documentation](http://godoc.org/github.com/gophercloud/gophercloud) -* [Effective Go](https://golang.org/doc/effective_go.html) - -## How to install - -Reference a Gophercloud package in your code: - -```go -import "github.com/gophercloud/gophercloud" -``` - -Then update your `go.mod`: - -```shell -go mod tidy -``` - -## Getting started - -### Credentials - -Because you'll be hitting an API, you will need to retrieve your OpenStack -credentials and either store them in a `clouds.yaml` file, as environment -variables, or in your local Go files. The first method is recommended because -it decouples credential information from source code, allowing you to push the -latter to your version control system without any security risk. - -You will need to retrieve the following: - -* A valid Keystone identity URL -* Credentials. These can be a username/password combo, a set of Application - Credentials, a pre-generated token, or any other supported authentication - mechanism. - -For users who have the OpenStack dashboard installed, there's a shortcut. If -you visit the `project/api_access` path in Horizon and click on the -"Download OpenStack RC File" button at the top right hand corner, you can -download either a `clouds.yaml` file or an `openrc` bash file that exports all -of your access details to environment variables. To use the `clouds.yaml` file, -place it at `~/.config/openstack/clouds.yaml`. To use the `openrc` file, run -`source openrc` and you will be prompted for your password. - -### Authentication - -Once you have access to your credentials, you can begin plugging them into -Gophercloud. The next step is authentication, which is handled by a base -"Provider" struct. There are number of ways to construct such a struct. - -**With `gophercloud/utils`** - -The [github.com/gophercloud/utils](https://github.com/gophercloud/utils) -library provides the `clientconfig` package to simplify authentication. It -provides additional functionality, such as the ability to read `clouds.yaml` -files. To generate a "Provider" struct using the `clientconfig` package: - -```go -import ( - "github.com/gophercloud/utils/openstack/clientconfig" -) - -// You can also skip configuring this and instead set 'OS_CLOUD' in your -// environment -opts := new(clientconfig.ClientOpts) -opts.Cloud = "devstack-admin" - -provider, err := clientconfig.AuthenticatedClient(opts) -``` - -A provider client is a top-level client that all of your OpenStack service -clients derive from. The provider contains all of the authentication details -that allow your Go code to access the API - such as the base URL and token ID. - -Once we have a base Provider, we inject it as a dependency into each OpenStack -service. For example, in order to work with the Compute API, we need a Compute -service client. This can be created like so: - -```go -client, err := clientconfig.NewServiceClient("compute", opts) -``` - -**Without `gophercloud/utils`** - -> *Note* -> gophercloud doesn't provide support for `clouds.yaml` file so you need to -> implement this functionality yourself if you don't wish to use -> `gophercloud/utils`. - -You can also generate a "Provider" struct without using the `clientconfig` -package from `gophercloud/utils`. To do this, you can either pass in your -credentials explicitly or tell Gophercloud to use environment variables: - -```go -import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack" -) - -// Option 1: Pass in the values yourself -opts := gophercloud.AuthOptions{ - IdentityEndpoint: "https://openstack.example.com:5000/v2.0", - Username: "{username}", - Password: "{password}", -} - -// Option 2: Use a utility function to retrieve all your environment variables -opts, err := openstack.AuthOptionsFromEnv() -``` - -Once you have the `opts` variable, you can pass it in and get back a -`ProviderClient` struct: - -```go -provider, err := openstack.AuthenticatedClient(opts) -``` - -As above, you can then use this provider client to generate a service client -for a particular OpenStack service: - -```go -client, err := openstack.NewComputeV2(provider, gophercloud.EndpointOpts{ - Region: os.Getenv("OS_REGION_NAME"), -}) -``` - -### Provision a server - -We can use the Compute service client generated above for any Compute API -operation we want. In our case, we want to provision a new server. To do this, -we invoke the `Create` method and pass in the flavor ID (hardware -specification) and image ID (operating system) we're interested in: - -```go -import "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - -server, err := servers.Create(client, servers.CreateOpts{ - Name: "My new server!", - FlavorRef: "flavor_id", - ImageRef: "image_id", -}).Extract() -``` - -The above code sample creates a new server with the parameters, and embodies the -new resource in the `server` variable (a -[`servers.Server`](http://godoc.org/github.com/gophercloud/gophercloud) struct). - -## Advanced Usage - -Have a look at the [FAQ](./docs/FAQ.md) for some tips on customizing the way Gophercloud works. - -## Backwards-Compatibility Guarantees - -Gophercloud versioning follows [semver](https://semver.org/spec/v2.0.0.html). - -Before `v1.0.0`, there were no guarantees. Starting with v1, there will be no breaking changes within a major release. - -See the [Release instructions](./RELEASE.md). - -## Contributing - -See the [contributing guide](./.github/CONTRIBUTING.md). - -## Help and feedback - -If you're struggling with something or have spotted a potential bug, feel free -to submit an issue to our [bug tracker](https://github.com/gophercloud/gophercloud/issues). diff --git a/vendor/github.com/gophercloud/gophercloud/doc.go b/vendor/github.com/gophercloud/gophercloud/doc.go deleted file mode 100644 index 19b64d6508c00..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/doc.go +++ /dev/null @@ -1,148 +0,0 @@ -/* -Package gophercloud provides a multi-vendor interface to OpenStack-compatible -clouds. The library has a three-level hierarchy: providers, services, and -resources. - -# Authenticating with Providers - -Provider structs represent the cloud providers that offer and manage a -collection of services. You will generally want to create one Provider -client per OpenStack cloud. - - It is now recommended to use the `clientconfig` package found at - https://github.com/gophercloud/utils/tree/master/openstack/clientconfig - for all authentication purposes. - - The below documentation is still relevant. clientconfig simply implements - the below and presents it in an easier and more flexible way. - -Use your OpenStack credentials to create a Provider client. The -IdentityEndpoint is typically refered to as "auth_url" or "OS_AUTH_URL" in -information provided by the cloud operator. Additionally, the cloud may refer to -TenantID or TenantName as project_id and project_name. Credentials are -specified like so: - - opts := gophercloud.AuthOptions{ - IdentityEndpoint: "https://openstack.example.com:5000/v2.0", - Username: "{username}", - Password: "{password}", - TenantID: "{tenant_id}", - } - - provider, err := openstack.AuthenticatedClient(opts) - -You can authenticate with a token by doing: - - opts := gophercloud.AuthOptions{ - IdentityEndpoint: "https://openstack.example.com:5000/v2.0", - TokenID: "{token_id}", - TenantID: "{tenant_id}", - } - - provider, err := openstack.AuthenticatedClient(opts) - -You may also use the openstack.AuthOptionsFromEnv() helper function. This -function reads in standard environment variables frequently found in an -OpenStack `openrc` file. Again note that Gophercloud currently uses "tenant" -instead of "project". - - opts, err := openstack.AuthOptionsFromEnv() - provider, err := openstack.AuthenticatedClient(opts) - -# Service Clients - -Service structs are specific to a provider and handle all of the logic and -operations for a particular OpenStack service. Examples of services include: -Compute, Object Storage, Block Storage. In order to define one, you need to -pass in the parent provider, like so: - - opts := gophercloud.EndpointOpts{Region: "RegionOne"} - - client, err := openstack.NewComputeV2(provider, opts) - -# Resources - -Resource structs are the domain models that services make use of in order -to work with and represent the state of API resources: - - server, err := servers.Get(client, "{serverId}").Extract() - -Intermediate Result structs are returned for API operations, which allow -generic access to the HTTP headers, response body, and any errors associated -with the network transaction. To turn a result into a usable resource struct, -you must call the Extract method which is chained to the response, or an -Extract function from an applicable extension: - - result := servers.Get(client, "{serverId}") - - // Attempt to extract the disk configuration from the OS-DCF disk config - // extension: - config, err := diskconfig.ExtractGet(result) - -All requests that enumerate a collection return a Pager struct that is used to -iterate through the results one page at a time. Use the EachPage method on that -Pager to handle each successive Page in a closure, then use the appropriate -extraction method from that request's package to interpret that Page as a slice -of results: - - err := servers.List(client, nil).EachPage(func (page pagination.Page) (bool, error) { - s, err := servers.ExtractServers(page) - if err != nil { - return false, err - } - - // Handle the []servers.Server slice. - - // Return "false" or an error to prematurely stop fetching new pages. - return true, nil - }) - -If you want to obtain the entire collection of pages without doing any -intermediary processing on each page, you can use the AllPages method: - - allPages, err := servers.List(client, nil).AllPages() - allServers, err := servers.ExtractServers(allPages) - -This top-level package contains utility functions and data types that are used -throughout the provider and service packages. Of particular note for end users -are the AuthOptions and EndpointOpts structs. - -An example retry backoff function, which respects the 429 HTTP response code and a "Retry-After" header: - - endpoint := "http://localhost:5000" - provider, err := openstack.NewClient(endpoint) - if err != nil { - panic(err) - } - provider.MaxBackoffRetries = 3 // max three retries - provider.RetryBackoffFunc = func(ctx context.Context, respErr *ErrUnexpectedResponseCode, e error, retries uint) error { - retryAfter := respErr.ResponseHeader.Get("Retry-After") - if retryAfter == "" { - return e - } - - var sleep time.Duration - - // Parse delay seconds or HTTP date - if v, err := strconv.ParseUint(retryAfter, 10, 32); err == nil { - sleep = time.Duration(v) * time.Second - } else if v, err := time.Parse(http.TimeFormat, retryAfter); err == nil { - sleep = time.Until(v) - } else { - return e - } - - if ctx != nil { - select { - case <-time.After(sleep): - case <-ctx.Done(): - return e - } - } else { - time.Sleep(sleep) - } - - return nil - } -*/ -package gophercloud diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/doc.go b/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/doc.go deleted file mode 100644 index 0b834852dda2f..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/doc.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -Package volumes provides information and interaction with volumes in the -OpenStack Block Storage service. A volume is a detachable block storage -device, akin to a USB hard drive. It can only be attached to one instance at -a time. - -Example to create a Volume from a Backup - - backupID := "20c792f0-bb03-434f-b653-06ef238e337e" - options := volumes.CreateOpts{ - Name: "vol-001", - BackupID: &backupID, - } - - client.Microversion = "3.47" - volume, err := volumes.Create(client, options).Extract() - if err != nil { - panic(err) - } - - fmt.Println(volume) -*/ -package volumes diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/requests.go b/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/requests.go deleted file mode 100644 index f6063c5954c6c..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/requests.go +++ /dev/null @@ -1,208 +0,0 @@ -package volumes - -import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" -) - -// CreateOptsBuilder allows extensions to add additional parameters to the -// Create request. -type CreateOptsBuilder interface { - ToVolumeCreateMap() (map[string]interface{}, error) -} - -// CreateOpts contains options for creating a Volume. This object is passed to -// the volumes.Create function. For more information about these parameters, -// see the Volume object. -type CreateOpts struct { - // The size of the volume, in GB - Size int `json:"size,omitempty"` - // The availability zone - AvailabilityZone string `json:"availability_zone,omitempty"` - // ConsistencyGroupID is the ID of a consistency group - ConsistencyGroupID string `json:"consistencygroup_id,omitempty"` - // The volume description - Description string `json:"description,omitempty"` - // One or more metadata key and value pairs to associate with the volume - Metadata map[string]string `json:"metadata,omitempty"` - // The volume name - Name string `json:"name,omitempty"` - // the ID of the existing volume snapshot - SnapshotID string `json:"snapshot_id,omitempty"` - // SourceReplica is a UUID of an existing volume to replicate with - SourceReplica string `json:"source_replica,omitempty"` - // the ID of the existing volume - SourceVolID string `json:"source_volid,omitempty"` - // The ID of the image from which you want to create the volume. - // Required to create a bootable volume. - ImageID string `json:"imageRef,omitempty"` - // Specifies the backup ID, from which you want to create the volume. - // Create a volume from a backup is supported since 3.47 microversion - BackupID string `json:"backup_id,omitempty"` - // The associated volume type - VolumeType string `json:"volume_type,omitempty"` - // Multiattach denotes if the volume is multi-attach capable. - Multiattach bool `json:"multiattach,omitempty"` -} - -// ToVolumeCreateMap assembles a request body based on the contents of a -// CreateOpts. -func (opts CreateOpts) ToVolumeCreateMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "volume") -} - -// Create will create a new Volume based on the values in CreateOpts. To extract -// the Volume object from the response, call the Extract method on the -// CreateResult. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { - b, err := opts.ToVolumeCreateMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{202}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// DeleteOptsBuilder allows extensions to add additional parameters to the -// Delete request. -type DeleteOptsBuilder interface { - ToVolumeDeleteQuery() (string, error) -} - -// DeleteOpts contains options for deleting a Volume. This object is passed to -// the volumes.Delete function. -type DeleteOpts struct { - // Delete all snapshots of this volume as well. - Cascade bool `q:"cascade"` -} - -// ToLoadBalancerDeleteQuery formats a DeleteOpts into a query string. -func (opts DeleteOpts) ToVolumeDeleteQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - return q.String(), err -} - -// Delete will delete the existing Volume with the provided ID. -func Delete(client *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult) { - url := deleteURL(client, id) - if opts != nil { - query, err := opts.ToVolumeDeleteQuery() - if err != nil { - r.Err = err - return - } - url += query - } - resp, err := client.Delete(url, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// Get retrieves the Volume with the provided ID. To extract the Volume object -// from the response, call the Extract method on the GetResult. -func Get(client *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := client.Get(getURL(client, id), &r.Body, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// ListOptsBuilder allows extensions to add additional parameters to the List -// request. -type ListOptsBuilder interface { - ToVolumeListQuery() (string, error) -} - -// ListOpts holds options for listing Volumes. It is passed to the volumes.List -// function. -type ListOpts struct { - // AllTenants will retrieve volumes of all tenants/projects. - AllTenants bool `q:"all_tenants"` - - // Metadata will filter results based on specified metadata. - Metadata map[string]string `q:"metadata"` - - // Name will filter by the specified volume name. - Name string `q:"name"` - - // Status will filter by the specified status. - Status string `q:"status"` - - // TenantID will filter by a specific tenant/project ID. - // Setting AllTenants is required for this. - TenantID string `q:"project_id"` - - // Comma-separated list of sort keys and optional sort directions in the - // form of [:]. - Sort string `q:"sort"` - - // Requests a page size of items. - Limit int `q:"limit"` - - // Used in conjunction with limit to return a slice of items. - Offset int `q:"offset"` - - // The ID of the last-seen item. - Marker string `q:"marker"` -} - -// ToVolumeListQuery formats a ListOpts into a query string. -func (opts ListOpts) ToVolumeListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - return q.String(), err -} - -// List returns Volumes optionally limited by the conditions provided in ListOpts. -func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := listURL(client) - if opts != nil { - query, err := opts.ToVolumeListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return VolumePage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// UpdateOptsBuilder allows extensions to add additional parameters to the -// Update request. -type UpdateOptsBuilder interface { - ToVolumeUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts contain options for updating an existing Volume. This object is passed -// to the volumes.Update function. For more information about the parameters, see -// the Volume object. -type UpdateOpts struct { - Name *string `json:"name,omitempty"` - Description *string `json:"description,omitempty"` - Metadata map[string]string `json:"metadata,omitempty"` -} - -// ToVolumeUpdateMap assembles a request body based on the contents of an -// UpdateOpts. -func (opts UpdateOpts) ToVolumeUpdateMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "volume") -} - -// Update will update the Volume with provided information. To extract the updated -// Volume from the response, call the Extract method on the UpdateResult. -func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { - b, err := opts.ToVolumeUpdateMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Put(updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/results.go b/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/results.go deleted file mode 100644 index df97e66947c41..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/results.go +++ /dev/null @@ -1,179 +0,0 @@ -package volumes - -import ( - "encoding/json" - "time" - - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" -) - -// Attachment represents a Volume Attachment record -type Attachment struct { - AttachedAt time.Time `json:"-"` - AttachmentID string `json:"attachment_id"` - Device string `json:"device"` - HostName string `json:"host_name"` - ID string `json:"id"` - ServerID string `json:"server_id"` - VolumeID string `json:"volume_id"` -} - -// UnmarshalJSON is our unmarshalling helper -func (r *Attachment) UnmarshalJSON(b []byte) error { - type tmp Attachment - var s struct { - tmp - AttachedAt gophercloud.JSONRFC3339MilliNoZ `json:"attached_at"` - } - err := json.Unmarshal(b, &s) - if err != nil { - return err - } - *r = Attachment(s.tmp) - - r.AttachedAt = time.Time(s.AttachedAt) - - return err -} - -// Volume contains all the information associated with an OpenStack Volume. -type Volume struct { - // Unique identifier for the volume. - ID string `json:"id"` - // Current status of the volume. - Status string `json:"status"` - // Size of the volume in GB. - Size int `json:"size"` - // AvailabilityZone is which availability zone the volume is in. - AvailabilityZone string `json:"availability_zone"` - // The date when this volume was created. - CreatedAt time.Time `json:"-"` - // The date when this volume was last updated - UpdatedAt time.Time `json:"-"` - // Instances onto which the volume is attached. - Attachments []Attachment `json:"attachments"` - // Human-readable display name for the volume. - Name string `json:"name"` - // Human-readable description for the volume. - Description string `json:"description"` - // The type of volume to create, either SATA or SSD. - VolumeType string `json:"volume_type"` - // The ID of the snapshot from which the volume was created - SnapshotID string `json:"snapshot_id"` - // The ID of another block storage volume from which the current volume was created - SourceVolID string `json:"source_volid"` - // The backup ID, from which the volume was restored - // This field is supported since 3.47 microversion - BackupID *string `json:"backup_id"` - // Arbitrary key-value pairs defined by the user. - Metadata map[string]string `json:"metadata"` - // UserID is the id of the user who created the volume. - UserID string `json:"user_id"` - // Indicates whether this is a bootable volume. - Bootable string `json:"bootable"` - // Encrypted denotes if the volume is encrypted. - Encrypted bool `json:"encrypted"` - // ReplicationStatus is the status of replication. - ReplicationStatus string `json:"replication_status"` - // ConsistencyGroupID is the consistency group ID. - ConsistencyGroupID string `json:"consistencygroup_id"` - // Multiattach denotes if the volume is multi-attach capable. - Multiattach bool `json:"multiattach"` - // Image metadata entries, only included for volumes that were created from an image, or from a snapshot of a volume originally created from an image. - VolumeImageMetadata map[string]string `json:"volume_image_metadata"` -} - -// UnmarshalJSON another unmarshalling function -func (r *Volume) UnmarshalJSON(b []byte) error { - type tmp Volume - var s struct { - tmp - CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"` - UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"` - } - err := json.Unmarshal(b, &s) - if err != nil { - return err - } - *r = Volume(s.tmp) - - r.CreatedAt = time.Time(s.CreatedAt) - r.UpdatedAt = time.Time(s.UpdatedAt) - - return err -} - -// VolumePage is a pagination.pager that is returned from a call to the List function. -type VolumePage struct { - pagination.LinkedPageBase -} - -// IsEmpty returns true if a ListResult contains no Volumes. -func (r VolumePage) IsEmpty() (bool, error) { - if r.StatusCode == 204 { - return true, nil - } - - volumes, err := ExtractVolumes(r) - return len(volumes) == 0, err -} - -func (page VolumePage) NextPageURL() (string, error) { - var s struct { - Links []gophercloud.Link `json:"volumes_links"` - } - err := page.ExtractInto(&s) - if err != nil { - return "", err - } - return gophercloud.ExtractNextURL(s.Links) -} - -// ExtractVolumes extracts and returns Volumes. It is used while iterating over a volumes.List call. -func ExtractVolumes(r pagination.Page) ([]Volume, error) { - var s []Volume - err := ExtractVolumesInto(r, &s) - return s, err -} - -type commonResult struct { - gophercloud.Result -} - -// Extract will get the Volume object out of the commonResult object. -func (r commonResult) Extract() (*Volume, error) { - var s Volume - err := r.ExtractInto(&s) - return &s, err -} - -// ExtractInto converts our response data into a volume struct -func (r commonResult) ExtractInto(v interface{}) error { - return r.Result.ExtractIntoStructPtr(v, "volume") -} - -// ExtractVolumesInto similar to ExtractInto but operates on a `list` of volumes -func ExtractVolumesInto(r pagination.Page, v interface{}) error { - return r.(VolumePage).Result.ExtractIntoSlicePtr(v, "volumes") -} - -// CreateResult contains the response body and error from a Create request. -type CreateResult struct { - commonResult -} - -// GetResult contains the response body and error from a Get request. -type GetResult struct { - commonResult -} - -// UpdateResult contains the response body and error from an Update request. -type UpdateResult struct { - commonResult -} - -// DeleteResult contains the response body and error from a Delete request. -type DeleteResult struct { - gophercloud.ErrResult -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/util.go b/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/util.go deleted file mode 100644 index e86c1b4b4ee58..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package volumes - -import ( - "github.com/gophercloud/gophercloud" -) - -// WaitForStatus will continually poll the resource, checking for a particular -// status. It will do this for the amount of seconds defined. -func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error { - return gophercloud.WaitFor(secs, func() (bool, error) { - current, err := Get(c, id).Extract() - if err != nil { - return false, err - } - - if current.Status == status { - return true, nil - } - - return false, nil - }) -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/doc.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/doc.go deleted file mode 100644 index 79a09b33cf129..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/doc.go +++ /dev/null @@ -1,152 +0,0 @@ -/* -Package bootfromvolume extends a server create request with the ability to -specify block device options. This can be used to boot a server from a block -storage volume as well as specify multiple ephemeral disks upon creation. - -It is recommended to refer to the Block Device Mapping documentation to see -all possible ways to configure a server's block devices at creation time: - -https://docs.openstack.org/nova/latest/user/block-device-mapping.html - -Note that this package implements `block_device_mapping_v2`. - -# Example of Creating a Server From an Image - -This example will boot a server from an image and use a standard ephemeral -disk as the server's root disk. This is virtually no different than creating -a server without using block device mappings. - - blockDevices := []bootfromvolume.BlockDevice{ - bootfromvolume.BlockDevice{ - BootIndex: 0, - DeleteOnTermination: true, - DestinationType: bootfromvolume.DestinationLocal, - SourceType: bootfromvolume.SourceImage, - UUID: "image-uuid", - }, - } - - serverCreateOpts := servers.CreateOpts{ - Name: "server_name", - FlavorRef: "flavor-uuid", - ImageRef: "image-uuid", - } - - createOpts := bootfromvolume.CreateOptsExt{ - CreateOptsBuilder: serverCreateOpts, - BlockDevice: blockDevices, - } - - server, err := bootfromvolume.Create(client, createOpts).Extract() - if err != nil { - panic(err) - } - -# Example of Creating a Server From a New Volume - -This example will create a block storage volume based on the given Image. The -server will use this volume as its root disk. - - blockDevices := []bootfromvolume.BlockDevice{ - bootfromvolume.BlockDevice{ - DeleteOnTermination: true, - DestinationType: bootfromvolume.DestinationVolume, - SourceType: bootfromvolume.SourceImage, - UUID: "image-uuid", - VolumeSize: 2, - }, - } - - serverCreateOpts := servers.CreateOpts{ - Name: "server_name", - FlavorRef: "flavor-uuid", - } - - createOpts := bootfromvolume.CreateOptsExt{ - CreateOptsBuilder: serverCreateOpts, - BlockDevice: blockDevices, - } - - server, err := bootfromvolume.Create(client, createOpts).Extract() - if err != nil { - panic(err) - } - -# Example of Creating a Server From an Existing Volume - -This example will create a server with an existing volume as its root disk. - - blockDevices := []bootfromvolume.BlockDevice{ - bootfromvolume.BlockDevice{ - DeleteOnTermination: true, - DestinationType: bootfromvolume.DestinationVolume, - SourceType: bootfromvolume.SourceVolume, - UUID: "volume-uuid", - }, - } - - serverCreateOpts := servers.CreateOpts{ - Name: "server_name", - FlavorRef: "flavor-uuid", - } - - createOpts := bootfromvolume.CreateOptsExt{ - CreateOptsBuilder: serverCreateOpts, - BlockDevice: blockDevices, - } - - server, err := bootfromvolume.Create(client, createOpts).Extract() - if err != nil { - panic(err) - } - -# Example of Creating a Server with Multiple Ephemeral Disks - -This example will create a server with multiple ephemeral disks. The first -block device will be based off of an existing Image. Each additional -ephemeral disks must have an index of -1. - - blockDevices := []bootfromvolume.BlockDevice{ - bootfromvolume.BlockDevice{ - BootIndex: 0, - DestinationType: bootfromvolume.DestinationLocal, - DeleteOnTermination: true, - SourceType: bootfromvolume.SourceImage, - UUID: "image-uuid", - VolumeSize: 5, - }, - bootfromvolume.BlockDevice{ - BootIndex: -1, - DestinationType: bootfromvolume.DestinationLocal, - DeleteOnTermination: true, - GuestFormat: "ext4", - SourceType: bootfromvolume.SourceBlank, - VolumeSize: 1, - }, - bootfromvolume.BlockDevice{ - BootIndex: -1, - DestinationType: bootfromvolume.DestinationLocal, - DeleteOnTermination: true, - GuestFormat: "ext4", - SourceType: bootfromvolume.SourceBlank, - VolumeSize: 1, - }, - } - - serverCreateOpts := servers.CreateOpts{ - Name: "server_name", - FlavorRef: "flavor-uuid", - ImageRef: "image-uuid", - } - - createOpts := bootfromvolume.CreateOptsExt{ - CreateOptsBuilder: serverCreateOpts, - BlockDevice: blockDevices, - } - - server, err := bootfromvolume.Create(client, createOpts).Extract() - if err != nil { - panic(err) - } -*/ -package bootfromvolume diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/requests.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/requests.go deleted file mode 100644 index 05f45aeceb160..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/requests.go +++ /dev/null @@ -1,142 +0,0 @@ -package bootfromvolume - -import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" -) - -type ( - // DestinationType represents the type of medium being used as the - // destination of the bootable device. - DestinationType string - - // SourceType represents the type of medium being used as the source of the - // bootable device. - SourceType string -) - -const ( - // DestinationLocal DestinationType is for using an ephemeral disk as the - // destination. - DestinationLocal DestinationType = "local" - - // DestinationVolume DestinationType is for using a volume as the destination. - DestinationVolume DestinationType = "volume" - - // SourceBlank SourceType is for a "blank" or empty source. - SourceBlank SourceType = "blank" - - // SourceImage SourceType is for using images as the source of a block device. - SourceImage SourceType = "image" - - // SourceSnapshot SourceType is for using a volume snapshot as the source of - // a block device. - SourceSnapshot SourceType = "snapshot" - - // SourceVolume SourceType is for using a volume as the source of block - // device. - SourceVolume SourceType = "volume" -) - -// BlockDevice is a structure with options for creating block devices in a -// server. The block device may be created from an image, snapshot, new volume, -// or existing volume. The destination may be a new volume, existing volume -// which will be attached to the instance, ephemeral disk, or boot device. -type BlockDevice struct { - // SourceType must be one of: "volume", "snapshot", "image", or "blank". - SourceType SourceType `json:"source_type" required:"true"` - - // UUID is the unique identifier for the existing volume, snapshot, or - // image (see above). - UUID string `json:"uuid,omitempty"` - - // BootIndex is the boot index. It defaults to 0. - BootIndex int `json:"boot_index"` - - // DeleteOnTermination specifies whether or not to delete the attached volume - // when the server is deleted. Defaults to `false`. - DeleteOnTermination bool `json:"delete_on_termination"` - - // DestinationType is the type that gets created. Possible values are "volume" - // and "local". - DestinationType DestinationType `json:"destination_type,omitempty"` - - // GuestFormat specifies the format of the block device. - // Not specifying this will cause the device to be formatted to the default in Nova - // which is currently vfat. - // https://opendev.org/openstack/nova/src/commit/d0b459423dd81644e8d9382b6c87fabaa4f03ad4/nova/privsep/fs.py#L257 - GuestFormat string `json:"guest_format,omitempty"` - - // VolumeSize is the size of the volume to create (in gigabytes). This can be - // omitted for existing volumes. - VolumeSize int `json:"volume_size,omitempty"` - - // DeviceType specifies the device type of the block devices. - // Examples of this are disk, cdrom, floppy, lun, etc. - DeviceType string `json:"device_type,omitempty"` - - // DiskBus is the bus type of the block devices. - // Examples of this are ide, usb, virtio, scsi, etc. - DiskBus string `json:"disk_bus,omitempty"` - - // VolumeType is the volume type of the block device. - // This requires Compute API microversion 2.67 or later. - VolumeType string `json:"volume_type,omitempty"` - - // Tag is an arbitrary string that can be applied to a block device. - // Information about the device tags can be obtained from the metadata API - // and the config drive, allowing devices to be easily identified. - // This requires Compute API microversion 2.42 or later. - Tag string `json:"tag,omitempty"` -} - -// CreateOptsExt is a structure that extends the server `CreateOpts` structure -// by allowing for a block device mapping. -type CreateOptsExt struct { - servers.CreateOptsBuilder - BlockDevice []BlockDevice `json:"block_device_mapping_v2,omitempty"` -} - -// ToServerCreateMap adds the block device mapping option to the base server -// creation options. -func (opts CreateOptsExt) ToServerCreateMap() (map[string]interface{}, error) { - base, err := opts.CreateOptsBuilder.ToServerCreateMap() - if err != nil { - return nil, err - } - - if len(opts.BlockDevice) == 0 { - err := gophercloud.ErrMissingInput{} - err.Argument = "bootfromvolume.CreateOptsExt.BlockDevice" - return nil, err - } - - serverMap := base["server"].(map[string]interface{}) - - blockDevice := make([]map[string]interface{}, len(opts.BlockDevice)) - - for i, bd := range opts.BlockDevice { - b, err := gophercloud.BuildRequestBody(bd, "") - if err != nil { - return nil, err - } - blockDevice[i] = b - } - serverMap["block_device_mapping_v2"] = blockDevice - - return base, nil -} - -// Create requests the creation of a server from the given block device mapping. -func Create(client *gophercloud.ServiceClient, opts servers.CreateOptsBuilder) (r servers.CreateResult) { - b, err := opts.ToServerCreateMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 202}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/results.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/results.go deleted file mode 100644 index ba1eafabcd093..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/results.go +++ /dev/null @@ -1,12 +0,0 @@ -package bootfromvolume - -import ( - os "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" -) - -// CreateResult temporarily contains the response from a Create call. -// It embeds the standard servers.CreateResults type and so can be used the -// same way as a standard server request result. -type CreateResult struct { - os.CreateResult -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/urls.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/urls.go deleted file mode 100644 index e74422d0c1a6c..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume/urls.go +++ /dev/null @@ -1,7 +0,0 @@ -package bootfromvolume - -import "github.com/gophercloud/gophercloud" - -func createURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL("servers") -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints/doc.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints/doc.go deleted file mode 100644 index 2d9d3acdecad8..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints/doc.go +++ /dev/null @@ -1,76 +0,0 @@ -/* -Package schedulerhints extends the server create request with the ability to -specify additional parameters which determine where the server will be -created in the OpenStack cloud. - -Example to Add a Server to a Server Group - - schedulerHints := schedulerhints.SchedulerHints{ - Group: "servergroup-uuid", - } - - serverCreateOpts := servers.CreateOpts{ - Name: "server_name", - ImageRef: "image-uuid", - FlavorRef: "flavor-uuid", - } - - createOpts := schedulerhints.CreateOptsExt{ - CreateOptsBuilder: serverCreateOpts, - SchedulerHints: schedulerHints, - } - - server, err := servers.Create(computeClient, createOpts).Extract() - if err != nil { - panic(err) - } - -Example to Place Server B on a Different Host than Server A - - schedulerHints := schedulerhints.SchedulerHints{ - DifferentHost: []string{ - "server-a-uuid", - } - } - - serverCreateOpts := servers.CreateOpts{ - Name: "server_b", - ImageRef: "image-uuid", - FlavorRef: "flavor-uuid", - } - - createOpts := schedulerhints.CreateOptsExt{ - CreateOptsBuilder: serverCreateOpts, - SchedulerHints: schedulerHints, - } - - server, err := servers.Create(computeClient, createOpts).Extract() - if err != nil { - panic(err) - } - -Example to Place Server B on the Same Host as Server A - - schedulerHints := schedulerhints.SchedulerHints{ - SameHost: []string{ - "server-a-uuid", - } - } - - serverCreateOpts := servers.CreateOpts{ - Name: "server_b", - ImageRef: "image-uuid", - FlavorRef: "flavor-uuid", - } - - createOpts := schedulerhints.CreateOptsExt{ - CreateOptsBuilder: serverCreateOpts, - SchedulerHints: schedulerHints, - } - - server, err := servers.Create(computeClient, createOpts).Extract() - if err != nil { - panic(err) - } -*/ -package schedulerhints diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints/requests.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints/requests.go deleted file mode 100644 index 9a6324cf1d72b..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints/requests.go +++ /dev/null @@ -1,183 +0,0 @@ -package schedulerhints - -import ( - "encoding/json" - "net" - "regexp" - "strings" - - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" -) - -// SchedulerHints represents a set of scheduling hints that are passed to the -// OpenStack scheduler. -type SchedulerHints struct { - // Group specifies a Server Group to place the instance in. - Group string - - // DifferentHost will place the instance on a compute node that does not - // host the given instances. - DifferentHost []string - - // SameHost will place the instance on a compute node that hosts the given - // instances. - SameHost []string - - // Query is a conditional statement that results in compute nodes able to - // host the instance. - Query []interface{} - - // TargetCell specifies a cell name where the instance will be placed. - TargetCell string `json:"target_cell,omitempty"` - - // DifferentCell specifies cells names where an instance should not be placed. - DifferentCell []string `json:"different_cell,omitempty"` - - // BuildNearHostIP specifies a subnet of compute nodes to host the instance. - BuildNearHostIP string - - // AdditionalProperies are arbitrary key/values that are not validated by nova. - AdditionalProperties map[string]interface{} -} - -// CreateOptsBuilder builds the scheduler hints into a serializable format. -type CreateOptsBuilder interface { - ToServerSchedulerHintsCreateMap() (map[string]interface{}, error) -} - -// ToServerSchedulerHintsMap builds the scheduler hints into a serializable format. -func (opts SchedulerHints) ToServerSchedulerHintsCreateMap() (map[string]interface{}, error) { - sh := make(map[string]interface{}) - - uuidRegex, _ := regexp.Compile("^[a-z0-9]{8}-[a-z0-9]{4}-[1-5][a-z0-9]{3}-[a-z0-9]{4}-[a-z0-9]{12}$") - - if opts.Group != "" { - if !uuidRegex.MatchString(opts.Group) { - err := gophercloud.ErrInvalidInput{} - err.Argument = "schedulerhints.SchedulerHints.Group" - err.Value = opts.Group - err.Info = "Group must be a UUID" - return nil, err - } - sh["group"] = opts.Group - } - - if len(opts.DifferentHost) > 0 { - for _, diffHost := range opts.DifferentHost { - if !uuidRegex.MatchString(diffHost) { - err := gophercloud.ErrInvalidInput{} - err.Argument = "schedulerhints.SchedulerHints.DifferentHost" - err.Value = opts.DifferentHost - err.Info = "The hosts must be in UUID format." - return nil, err - } - } - sh["different_host"] = opts.DifferentHost - } - - if len(opts.SameHost) > 0 { - for _, sameHost := range opts.SameHost { - if !uuidRegex.MatchString(sameHost) { - err := gophercloud.ErrInvalidInput{} - err.Argument = "schedulerhints.SchedulerHints.SameHost" - err.Value = opts.SameHost - err.Info = "The hosts must be in UUID format." - return nil, err - } - } - sh["same_host"] = opts.SameHost - } - - /* - Query can be something simple like: - [">=", "$free_ram_mb", 1024] - - Or more complex like: - ['and', - ['>=', '$free_ram_mb', 1024], - ['>=', '$free_disk_mb', 200 * 1024] - ] - - Because of the possible complexity, just make sure the length is a minimum of 3. - */ - if len(opts.Query) > 0 { - if len(opts.Query) < 3 { - err := gophercloud.ErrInvalidInput{} - err.Argument = "schedulerhints.SchedulerHints.Query" - err.Value = opts.Query - err.Info = "Must be a conditional statement in the format of [op,variable,value]" - return nil, err - } - - // The query needs to be sent as a marshalled string. - b, err := json.Marshal(opts.Query) - if err != nil { - err := gophercloud.ErrInvalidInput{} - err.Argument = "schedulerhints.SchedulerHints.Query" - err.Value = opts.Query - err.Info = "Must be a conditional statement in the format of [op,variable,value]" - return nil, err - } - - sh["query"] = string(b) - } - - if opts.TargetCell != "" { - sh["target_cell"] = opts.TargetCell - } - - if len(opts.DifferentCell) > 0 { - sh["different_cell"] = opts.DifferentCell - } - - if opts.BuildNearHostIP != "" { - if _, _, err := net.ParseCIDR(opts.BuildNearHostIP); err != nil { - err := gophercloud.ErrInvalidInput{} - err.Argument = "schedulerhints.SchedulerHints.BuildNearHostIP" - err.Value = opts.BuildNearHostIP - err.Info = "Must be a valid subnet in the form 192.168.1.1/24" - return nil, err - } - ipParts := strings.Split(opts.BuildNearHostIP, "/") - sh["build_near_host_ip"] = ipParts[0] - sh["cidr"] = "/" + ipParts[1] - } - - if opts.AdditionalProperties != nil { - for k, v := range opts.AdditionalProperties { - sh[k] = v - } - } - - return sh, nil -} - -// CreateOptsExt adds a SchedulerHints option to the base CreateOpts. -type CreateOptsExt struct { - servers.CreateOptsBuilder - - // SchedulerHints provides a set of hints to the scheduler. - SchedulerHints CreateOptsBuilder -} - -// ToServerCreateMap adds the SchedulerHints option to the base server creation options. -func (opts CreateOptsExt) ToServerCreateMap() (map[string]interface{}, error) { - base, err := opts.CreateOptsBuilder.ToServerCreateMap() - if err != nil { - return nil, err - } - - schedulerHints, err := opts.SchedulerHints.ToServerSchedulerHintsCreateMap() - if err != nil { - return nil, err - } - - if len(schedulerHints) == 0 { - return base, nil - } - - base["os:scheduler_hints"] = schedulerHints - - return base, nil -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/doc.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/doc.go deleted file mode 100644 index bab72c1524eb5..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/doc.go +++ /dev/null @@ -1,135 +0,0 @@ -/* -Package servers provides information and interaction with the server API -resource in the OpenStack Compute service. - -A server is a virtual machine instance in the compute system. In order for -one to be provisioned, a valid flavor and image are required. - -Example to List Servers - - listOpts := servers.ListOpts{ - AllTenants: true, - } - - allPages, err := servers.ListSimple(computeClient, listOpts).AllPages() - if err != nil { - panic(err) - } - - allServers, err := servers.ExtractServers(allPages) - if err != nil { - panic(err) - } - - for _, server := range allServers { - fmt.Printf("%+v\n", server) - } - -Example to List Detail Servers - - listOpts := servers.ListOpts{ - AllTenants: true, - } - - allPages, err := servers.List(computeClient, listOpts).AllPages() - if err != nil { - panic(err) - } - - allServers, err := servers.ExtractServers(allPages) - if err != nil { - panic(err) - } - - for _, server := range allServers { - fmt.Printf("%+v\n", server) - } - -Example to Create a Server - - createOpts := servers.CreateOpts{ - Name: "server_name", - ImageRef: "image-uuid", - FlavorRef: "flavor-uuid", - } - - server, err := servers.Create(computeClient, createOpts).Extract() - if err != nil { - panic(err) - } - -Example to Delete a Server - - serverID := "d9072956-1560-487c-97f2-18bdf65ec749" - err := servers.Delete(computeClient, serverID).ExtractErr() - if err != nil { - panic(err) - } - -Example to Force Delete a Server - - serverID := "d9072956-1560-487c-97f2-18bdf65ec749" - err := servers.ForceDelete(computeClient, serverID).ExtractErr() - if err != nil { - panic(err) - } - -Example to Reboot a Server - - rebootOpts := servers.RebootOpts{ - Type: servers.SoftReboot, - } - - serverID := "d9072956-1560-487c-97f2-18bdf65ec749" - - err := servers.Reboot(computeClient, serverID, rebootOpts).ExtractErr() - if err != nil { - panic(err) - } - -Example to Rebuild a Server - - rebuildOpts := servers.RebuildOpts{ - Name: "new_name", - ImageID: "image-uuid", - } - - serverID := "d9072956-1560-487c-97f2-18bdf65ec749" - - server, err := servers.Rebuilt(computeClient, serverID, rebuildOpts).Extract() - if err != nil { - panic(err) - } - -Example to Resize a Server - - resizeOpts := servers.ResizeOpts{ - FlavorRef: "flavor-uuid", - } - - serverID := "d9072956-1560-487c-97f2-18bdf65ec749" - - err := servers.Resize(computeClient, serverID, resizeOpts).ExtractErr() - if err != nil { - panic(err) - } - - err = servers.ConfirmResize(computeClient, serverID).ExtractErr() - if err != nil { - panic(err) - } - -Example to Snapshot a Server - - snapshotOpts := servers.CreateImageOpts{ - Name: "snapshot_name", - } - - serverID := "d9072956-1560-487c-97f2-18bdf65ec749" - - image, err := servers.CreateImage(computeClient, serverID, snapshotOpts).ExtractImageID() - if err != nil { - panic(err) - } -*/ -package servers 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 deleted file mode 100644 index d6a903aab9a7b..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go +++ /dev/null @@ -1,784 +0,0 @@ -package servers - -import ( - "encoding/base64" - "encoding/json" - "fmt" - - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" -) - -// ListOptsBuilder allows extensions to add additional parameters to the -// List request. -type ListOptsBuilder interface { - ToServerListQuery() (string, error) -} - -// ListOpts allows the filtering and sorting of paginated collections through -// the API. Filtering is achieved by passing in struct field values that map to -// the server attributes you want to see returned. Marker and Limit are used -// for pagination. -type ListOpts struct { - // ChangesSince is a time/date stamp for when the server last changed status. - ChangesSince string `q:"changes-since"` - - // Image is the name of the image in URL format. - Image string `q:"image"` - - // Flavor is the name of the flavor in URL format. - Flavor string `q:"flavor"` - - // IP is a regular expression to match the IPv4 address of the server. - IP string `q:"ip"` - - // This requires the client to be set to microversion 2.5 or later, unless - // the user is an admin. - // IP is a regular expression to match the IPv6 address of the server. - IP6 string `q:"ip6"` - - // Name of the server as a string; can be queried with regular expressions. - // Realize that ?name=bob returns both bob and bobb. If you need to match bob - // only, you can use a regular expression matching the syntax of the - // underlying database server implemented for Compute. - Name string `q:"name"` - - // Status is the value of the status of the server so that you can filter on - // "ACTIVE" for example. - Status string `q:"status"` - - // Host is the name of the host as a string. - Host string `q:"host"` - - // Marker is a UUID of the server at which you want to set a marker. - Marker string `q:"marker"` - - // Limit is an integer value for the limit of values to return. - Limit int `q:"limit"` - - // AllTenants is a bool to show all tenants. - AllTenants bool `q:"all_tenants"` - - // TenantID lists servers for a particular tenant. - // Setting "AllTenants = true" is required. - TenantID string `q:"tenant_id"` - - // This requires the client to be set to microversion 2.83 or later, unless - // the user is an admin. - // UserID lists servers for a particular user. - UserID string `q:"user_id"` - - // This requires the client to be set to microversion 2.26 or later. - // Tags filters on specific server tags. All tags must be present for the server. - Tags string `q:"tags"` - - // This requires the client to be set to microversion 2.26 or later. - // TagsAny filters on specific server tags. At least one of the tags must be present for the server. - TagsAny string `q:"tags-any"` - - // This requires the client to be set to microversion 2.26 or later. - // NotTags filters on specific server tags. All tags must be absent for the server. - NotTags string `q:"not-tags"` - - // 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. -func (opts ListOpts) ToServerListQuery() (string, error) { - q, err := gophercloud.BuildQueryString(opts) - return q.String(), err -} - -// ListSimple makes a request against the API to list servers accessible to you. -func ListSimple(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := listURL(client) - if opts != nil { - query, err := opts.ToServerListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return ServerPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// List makes a request against the API to list servers details accessible to you. -func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - url := listDetailURL(client) - if opts != nil { - query, err := opts.ToServerListQuery() - if err != nil { - return pagination.Pager{Err: err} - } - url += query - } - return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { - return ServerPage{pagination.LinkedPageBase{PageResult: r}} - }) -} - -// CreateOptsBuilder allows extensions to add additional parameters to the -// Create request. -type CreateOptsBuilder interface { - ToServerCreateMap() (map[string]interface{}, error) -} - -// Network is used within CreateOpts to control a new server's network -// attachments. -type Network struct { - // UUID of a network to attach to the newly provisioned server. - // Required unless Port is provided. - UUID string - - // Port of a neutron network to attach to the newly provisioned server. - // Required unless UUID is provided. - Port string - - // 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. -type Personality []*File - -// File is used within CreateOpts and RebuildOpts to inject a file into the -// server at launch. -// File implements the json.Marshaler interface, so when a Create or Rebuild -// operation is requested, json.Marshal will call File's MarshalJSON method. -type File struct { - // Path of the file. - Path string - - // Contents of the file. Maximum content size is 255 bytes. - Contents []byte -} - -// MarshalJSON marshals the escaped file, base64 encoding the contents. -func (f *File) MarshalJSON() ([]byte, error) { - file := struct { - Path string `json:"path"` - Contents string `json:"contents"` - }{ - Path: f.Path, - Contents: base64.StdEncoding.EncodeToString(f.Contents), - } - return json.Marshal(file) -} - -// CreateOpts specifies server creation parameters. -type CreateOpts struct { - // Name is the name to assign to the newly launched server. - Name string `json:"name" required:"true"` - - // ImageRef is the ID or full URL to the image that contains the - // server's OS and initial state. - // Also optional if using the boot-from-volume extension. - ImageRef string `json:"imageRef"` - - // FlavorRef is the ID or full URL to the flavor that describes the server's specs. - FlavorRef string `json:"flavorRef"` - - // SecurityGroups lists the names of the security groups to which this server - // should belong. - SecurityGroups []string `json:"-"` - - // UserData contains configuration information or scripts to use upon launch. - // Create will base64-encode it for you, if it isn't already. - UserData []byte `json:"-"` - - // AvailabilityZone in which to launch the server. - AvailabilityZone string `json:"availability_zone,omitempty"` - - // Networks dictates how this server will be attached to available networks. - // By default, the server will be attached to all isolated networks for the - // tenant. - // Starting with microversion 2.37 networks can also be an "auto" or "none" - // string. - Networks interface{} `json:"-"` - - // Metadata contains key-value pairs (up to 255 bytes each) to attach to the - // server. - Metadata map[string]string `json:"metadata,omitempty"` - - // Personality includes files to inject into the server at launch. - // Create will base64-encode file contents for you. - Personality Personality `json:"personality,omitempty"` - - // ConfigDrive enables metadata injection through a configuration drive. - ConfigDrive *bool `json:"config_drive,omitempty"` - - // AdminPass sets the root user password. If not set, a randomly-generated - // password will be created and returned in the response. - AdminPass string `json:"adminPass,omitempty"` - - // AccessIPv4 specifies an IPv4 address for the instance. - AccessIPv4 string `json:"accessIPv4,omitempty"` - - // AccessIPv6 specifies an IPv6 address for the instance. - AccessIPv6 string `json:"accessIPv6,omitempty"` - - // Min specifies Minimum number of servers to launch. - Min int `json:"min_count,omitempty"` - - // Max specifies Maximum number of servers to launch. - Max int `json:"max_count,omitempty"` - - // Tags allows a server to be tagged with single-word metadata. - // Requires microversion 2.52 or later. - Tags []string `json:"tags,omitempty"` -} - -// ToServerCreateMap assembles a request body based on the contents of a -// CreateOpts. -func (opts CreateOpts) ToServerCreateMap() (map[string]interface{}, error) { - b, err := gophercloud.BuildRequestBody(opts, "") - if err != nil { - return nil, err - } - - if opts.UserData != nil { - var userData string - if _, err := base64.StdEncoding.DecodeString(string(opts.UserData)); err != nil { - userData = base64.StdEncoding.EncodeToString(opts.UserData) - } else { - userData = string(opts.UserData) - } - b["user_data"] = &userData - } - - if len(opts.SecurityGroups) > 0 { - securityGroups := make([]map[string]interface{}, len(opts.SecurityGroups)) - for i, groupName := range opts.SecurityGroups { - securityGroups[i] = map[string]interface{}{"name": groupName} - } - b["security_groups"] = securityGroups - } - - switch v := opts.Networks.(type) { - case []Network: - if len(v) > 0 { - networks := make([]map[string]interface{}, len(v)) - for i, net := range v { - networks[i] = make(map[string]interface{}) - if net.UUID != "" { - networks[i]["uuid"] = net.UUID - } - if net.Port != "" { - networks[i]["port"] = net.Port - } - if net.FixedIP != "" { - networks[i]["fixed_ip"] = net.FixedIP - } - if net.Tag != "" { - networks[i]["tag"] = net.Tag - } - } - b["networks"] = networks - } - case string: - if v == "auto" || v == "none" { - b["networks"] = v - } else { - return nil, fmt.Errorf(`networks must be a slice of Network struct or a string with "auto" or "none" values, current value is %q`, v) - } - } - - if opts.Min != 0 { - b["min_count"] = opts.Min - } - - if opts.Max != 0 { - b["max_count"] = opts.Max - } - - return map[string]interface{}{"server": b}, nil -} - -// Create requests a server to be provisioned to the user in the current tenant. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { - reqBody, err := opts.ToServerCreateMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Post(listURL(client), reqBody, &r.Body, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// Delete requests that a server previously provisioned be removed from your -// account. -func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := client.Delete(deleteURL(client, id), nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// ForceDelete forces the deletion of a server. -func ForceDelete(client *gophercloud.ServiceClient, id string) (r ActionResult) { - resp, err := client.Post(actionURL(client, id), map[string]interface{}{"forceDelete": ""}, nil, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// Get requests details on a single server, by ID. -func Get(client *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := client.Get(getURL(client, id), &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200, 203}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// UpdateOptsBuilder allows extensions to add additional attributes to the -// Update request. -type UpdateOptsBuilder interface { - ToServerUpdateMap() (map[string]interface{}, error) -} - -// UpdateOpts specifies the base attributes that may be updated on an existing -// server. -type UpdateOpts struct { - // Name changes the displayed name of the server. - // The server host name will *not* change. - // Server names are not constrained to be unique, even within the same tenant. - Name string `json:"name,omitempty"` - - // AccessIPv4 provides a new IPv4 address for the instance. - AccessIPv4 string `json:"accessIPv4,omitempty"` - - // AccessIPv6 provides a new IPv6 address for the instance. - AccessIPv6 string `json:"accessIPv6,omitempty"` -} - -// ToServerUpdateMap formats an UpdateOpts structure into a request body. -func (opts UpdateOpts) ToServerUpdateMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "server") -} - -// Update requests that various attributes of the indicated server be changed. -func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { - b, err := opts.ToServerUpdateMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Put(updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// ChangeAdminPassword alters the administrator or root password for a specified -// server. -func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword string) (r ActionResult) { - b := map[string]interface{}{ - "changePassword": map[string]string{ - "adminPass": newPassword, - }, - } - resp, err := client.Post(actionURL(client, id), b, nil, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// RebootMethod describes the mechanisms by which a server reboot can be requested. -type RebootMethod string - -// These constants determine how a server should be rebooted. -// See the Reboot() function for further details. -const ( - SoftReboot RebootMethod = "SOFT" - HardReboot RebootMethod = "HARD" - OSReboot = SoftReboot - PowerCycle = HardReboot -) - -// RebootOptsBuilder allows extensions to add additional parameters to the -// reboot request. -type RebootOptsBuilder interface { - ToServerRebootMap() (map[string]interface{}, error) -} - -// RebootOpts provides options to the reboot request. -type RebootOpts struct { - // Type is the type of reboot to perform on the server. - Type RebootMethod `json:"type" required:"true"` -} - -// ToServerRebootMap builds a body for the reboot request. -func (opts RebootOpts) ToServerRebootMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "reboot") -} - -/* -Reboot requests that a given server reboot. - -Two methods exist for rebooting a server: - -HardReboot (aka PowerCycle) starts the server instance by physically cutting -power to the machine, or if a VM, terminating it at the hypervisor level. -It's done. Caput. Full stop. -Then, after a brief while, power is restored or the VM instance restarted. - -SoftReboot (aka OSReboot) simply tells the OS to restart under its own -procedure. -E.g., in Linux, asking it to enter runlevel 6, or executing -"sudo shutdown -r now", or by asking Windows to rtart the machine. -*/ -func Reboot(client *gophercloud.ServiceClient, id string, opts RebootOptsBuilder) (r ActionResult) { - b, err := opts.ToServerRebootMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Post(actionURL(client, id), b, nil, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// RebuildOptsBuilder allows extensions to provide additional parameters to the -// rebuild request. -type RebuildOptsBuilder interface { - ToServerRebuildMap() (map[string]interface{}, error) -} - -// RebuildOpts represents the configuration options used in a server rebuild -// operation. -type RebuildOpts struct { - // AdminPass is the server's admin password - AdminPass string `json:"adminPass,omitempty"` - - // ImageRef is the ID of the image you want your server to be provisioned on. - ImageRef string `json:"imageRef"` - - // Name to set the server to - Name string `json:"name,omitempty"` - - // AccessIPv4 [optional] provides a new IPv4 address for the instance. - AccessIPv4 string `json:"accessIPv4,omitempty"` - - // AccessIPv6 [optional] provides a new IPv6 address for the instance. - AccessIPv6 string `json:"accessIPv6,omitempty"` - - // Metadata [optional] contains key-value pairs (up to 255 bytes each) - // to attach to the server. - Metadata map[string]string `json:"metadata,omitempty"` - - // Personality [optional] includes files to inject into the server at launch. - // Rebuild will base64-encode file contents for you. - Personality Personality `json:"personality,omitempty"` -} - -// ToServerRebuildMap formats a RebuildOpts struct into a map for use in JSON -func (opts RebuildOpts) ToServerRebuildMap() (map[string]interface{}, error) { - b, err := gophercloud.BuildRequestBody(opts, "") - if err != nil { - return nil, err - } - - return map[string]interface{}{"rebuild": b}, nil -} - -// Rebuild will reprovision the server according to the configuration options -// provided in the RebuildOpts struct. -func Rebuild(client *gophercloud.ServiceClient, id string, opts RebuildOptsBuilder) (r RebuildResult) { - b, err := opts.ToServerRebuildMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Post(actionURL(client, id), b, &r.Body, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// ResizeOptsBuilder allows extensions to add additional parameters to the -// resize request. -type ResizeOptsBuilder interface { - ToServerResizeMap() (map[string]interface{}, error) -} - -// ResizeOpts represents the configuration options used to control a Resize -// operation. -type ResizeOpts struct { - // FlavorRef is the ID of the flavor you wish your server to become. - FlavorRef string `json:"flavorRef" required:"true"` -} - -// ToServerResizeMap formats a ResizeOpts as a map that can be used as a JSON -// request body for the Resize request. -func (opts ResizeOpts) ToServerResizeMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "resize") -} - -// Resize instructs the provider to change the flavor of the server. -// -// Note that this implies rebuilding it. -// -// Unfortunately, one cannot pass rebuild parameters to the resize function. -// When the resize completes, the server will be in VERIFY_RESIZE state. -// While in this state, you can explore the use of the new server's -// configuration. If you like it, call ConfirmResize() to commit the resize -// permanently. Otherwise, call RevertResize() to restore the old configuration. -func Resize(client *gophercloud.ServiceClient, id string, opts ResizeOptsBuilder) (r ActionResult) { - b, err := opts.ToServerResizeMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Post(actionURL(client, id), b, nil, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// ConfirmResize confirms a previous resize operation on a server. -// See Resize() for more details. -func ConfirmResize(client *gophercloud.ServiceClient, id string) (r ActionResult) { - resp, err := client.Post(actionURL(client, id), map[string]interface{}{"confirmResize": nil}, nil, &gophercloud.RequestOpts{ - OkCodes: []int{201, 202, 204}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// RevertResize cancels a previous resize operation on a server. -// See Resize() for more details. -func RevertResize(client *gophercloud.ServiceClient, id string) (r ActionResult) { - resp, err := client.Post(actionURL(client, id), map[string]interface{}{"revertResize": nil}, nil, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// ResetMetadataOptsBuilder allows extensions to add additional parameters to -// the Reset request. -type ResetMetadataOptsBuilder interface { - ToMetadataResetMap() (map[string]interface{}, error) -} - -// MetadataOpts is a map that contains key-value pairs. -type MetadataOpts map[string]string - -// ToMetadataResetMap assembles a body for a Reset request based on the contents -// of a MetadataOpts. -func (opts MetadataOpts) ToMetadataResetMap() (map[string]interface{}, error) { - return map[string]interface{}{"metadata": opts}, nil -} - -// ToMetadataUpdateMap assembles a body for an Update request based on the -// contents of a MetadataOpts. -func (opts MetadataOpts) ToMetadataUpdateMap() (map[string]interface{}, error) { - return map[string]interface{}{"metadata": opts}, nil -} - -// ResetMetadata will create multiple new key-value pairs for the given server -// ID. -// Note: Using this operation will erase any already-existing metadata and -// create the new metadata provided. To keep any already-existing metadata, -// use the UpdateMetadatas or UpdateMetadata function. -func ResetMetadata(client *gophercloud.ServiceClient, id string, opts ResetMetadataOptsBuilder) (r ResetMetadataResult) { - b, err := opts.ToMetadataResetMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Put(metadataURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// Metadata requests all the metadata for the given server ID. -func Metadata(client *gophercloud.ServiceClient, id string) (r GetMetadataResult) { - resp, err := client.Get(metadataURL(client, id), &r.Body, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// UpdateMetadataOptsBuilder allows extensions to add additional parameters to -// the Create request. -type UpdateMetadataOptsBuilder interface { - ToMetadataUpdateMap() (map[string]interface{}, error) -} - -// UpdateMetadata updates (or creates) all the metadata specified by opts for -// the given server ID. This operation does not affect already-existing metadata -// that is not specified by opts. -func UpdateMetadata(client *gophercloud.ServiceClient, id string, opts UpdateMetadataOptsBuilder) (r UpdateMetadataResult) { - b, err := opts.ToMetadataUpdateMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Post(metadataURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// MetadatumOptsBuilder allows extensions to add additional parameters to the -// Create request. -type MetadatumOptsBuilder interface { - ToMetadatumCreateMap() (map[string]interface{}, string, error) -} - -// MetadatumOpts is a map of length one that contains a key-value pair. -type MetadatumOpts map[string]string - -// ToMetadatumCreateMap assembles a body for a Create request based on the -// contents of a MetadataumOpts. -func (opts MetadatumOpts) ToMetadatumCreateMap() (map[string]interface{}, string, error) { - if len(opts) != 1 { - err := gophercloud.ErrInvalidInput{} - err.Argument = "servers.MetadatumOpts" - err.Info = "Must have 1 and only 1 key-value pair" - return nil, "", err - } - metadatum := map[string]interface{}{"meta": opts} - var key string - for k := range metadatum["meta"].(MetadatumOpts) { - key = k - } - return metadatum, key, nil -} - -// CreateMetadatum will create or update the key-value pair with the given key -// for the given server ID. -func CreateMetadatum(client *gophercloud.ServiceClient, id string, opts MetadatumOptsBuilder) (r CreateMetadatumResult) { - b, key, err := opts.ToMetadatumCreateMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Put(metadatumURL(client, id, key), b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// Metadatum requests the key-value pair with the given key for the given -// server ID. -func Metadatum(client *gophercloud.ServiceClient, id, key string) (r GetMetadatumResult) { - resp, err := client.Get(metadatumURL(client, id, key), &r.Body, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// DeleteMetadatum will delete the key-value pair with the given key for the -// given server ID. -func DeleteMetadatum(client *gophercloud.ServiceClient, id, key string) (r DeleteMetadatumResult) { - resp, err := client.Delete(metadatumURL(client, id, key), nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// ListAddresses makes a request against the API to list the servers IP -// addresses. -func ListAddresses(client *gophercloud.ServiceClient, id string) pagination.Pager { - return pagination.NewPager(client, listAddressesURL(client, id), func(r pagination.PageResult) pagination.Page { - return AddressPage{pagination.SinglePageBase(r)} - }) -} - -// ListAddressesByNetwork makes a request against the API to list the servers IP -// addresses for the given network. -func ListAddressesByNetwork(client *gophercloud.ServiceClient, id, network string) pagination.Pager { - return pagination.NewPager(client, listAddressesByNetworkURL(client, id, network), func(r pagination.PageResult) pagination.Page { - return NetworkAddressPage{pagination.SinglePageBase(r)} - }) -} - -// CreateImageOptsBuilder allows extensions to add additional parameters to the -// CreateImage request. -type CreateImageOptsBuilder interface { - ToServerCreateImageMap() (map[string]interface{}, error) -} - -// CreateImageOpts provides options to pass to the CreateImage request. -type CreateImageOpts struct { - // Name of the image/snapshot. - Name string `json:"name" required:"true"` - - // Metadata contains key-value pairs (up to 255 bytes each) to attach to - // the created image. - Metadata map[string]string `json:"metadata,omitempty"` -} - -// ToServerCreateImageMap formats a CreateImageOpts structure into a request -// body. -func (opts CreateImageOpts) ToServerCreateImageMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "createImage") -} - -// CreateImage makes a request against the nova API to schedule an image to be -// created of the server -func CreateImage(client *gophercloud.ServiceClient, id string, opts CreateImageOptsBuilder) (r CreateImageResult) { - b, err := opts.ToServerCreateImageMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Post(actionURL(client, id), b, nil, &gophercloud.RequestOpts{ - OkCodes: []int{202}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// GetPassword makes a request against the nova API to get the encrypted -// administrative password. -func GetPassword(client *gophercloud.ServiceClient, serverId string) (r GetPasswordResult) { - resp, err := client.Get(passwordURL(client, serverId), &r.Body, nil) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} - -// ShowConsoleOutputOptsBuilder is the interface types must satisfy in order to be -// used as ShowConsoleOutput options -type ShowConsoleOutputOptsBuilder interface { - ToServerShowConsoleOutputMap() (map[string]interface{}, error) -} - -// ShowConsoleOutputOpts satisfies the ShowConsoleOutputOptsBuilder -type ShowConsoleOutputOpts struct { - // The number of lines to fetch from the end of console log. - // All lines will be returned if this is not specified. - Length int `json:"length,omitempty"` -} - -// ToServerShowConsoleOutputMap formats a ShowConsoleOutputOpts structure into a request body. -func (opts ShowConsoleOutputOpts) ToServerShowConsoleOutputMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "os-getConsoleOutput") -} - -// ShowConsoleOutput makes a request against the nova API to get console log from the server -func ShowConsoleOutput(client *gophercloud.ServiceClient, id string, opts ShowConsoleOutputOptsBuilder) (r ShowConsoleOutputResult) { - b, err := opts.ToServerShowConsoleOutputMap() - if err != nil { - r.Err = err - return - } - resp, err := client.Post(actionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ - OkCodes: []int{200}, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/util.go b/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/util.go deleted file mode 100644 index cadef054506a9..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/util.go +++ /dev/null @@ -1,21 +0,0 @@ -package servers - -import "github.com/gophercloud/gophercloud" - -// WaitForStatus will continually poll a server until it successfully -// transitions to a specified status. It will do this for at most the number -// of seconds specified. -func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error { - return gophercloud.WaitFor(secs, func() (bool, error) { - current, err := Get(c, id).Extract() - if err != nil { - return false, err - } - - if current.Status == status { - return true, nil - } - - return false, nil - }) -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/errors.go b/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/errors.go deleted file mode 100644 index 2b99a516df2f9..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/errors.go +++ /dev/null @@ -1,13 +0,0 @@ -package containers - -import "github.com/gophercloud/gophercloud" - -// ErrInvalidContainerName signals a container name containing an illegal -// character. -type ErrInvalidContainerName struct { - gophercloud.BaseError -} - -func (e ErrInvalidContainerName) Error() string { - return "A container name must not contain: " + forbiddenContainerRunes -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/urls.go b/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/urls.go deleted file mode 100644 index 0f11a97b7fa9f..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/urls.go +++ /dev/null @@ -1,54 +0,0 @@ -package containers - -import ( - "fmt" - "strings" - - "github.com/gophercloud/gophercloud" -) - -const forbiddenContainerRunes = "/" - -func CheckContainerName(s string) error { - if strings.ContainsAny(s, forbiddenContainerRunes) { - return ErrInvalidContainerName{} - } - - // The input could (and should) already have been escaped. This cycle - // checks for the escaped versions of the forbidden characters. Note - // that a simple "contains" is sufficient, because Go's http library - // won't accept invalid escape sequences (e.g. "%%2F"). - for _, r := range forbiddenContainerRunes { - if strings.Contains(strings.ToLower(s), fmt.Sprintf("%%%x", r)) { - return ErrInvalidContainerName{} - } - } - return nil -} - -func listURL(c *gophercloud.ServiceClient) string { - return c.Endpoint -} - -func createURL(c *gophercloud.ServiceClient, container string) (string, error) { - if err := CheckContainerName(container); err != nil { - return "", err - } - return c.ServiceURL(container), nil -} - -func getURL(c *gophercloud.ServiceClient, container string) (string, error) { - return createURL(c, container) -} - -func deleteURL(c *gophercloud.ServiceClient, container string) (string, error) { - return createURL(c, container) -} - -func updateURL(c *gophercloud.ServiceClient, container string) (string, error) { - return createURL(c, container) -} - -func bulkDeleteURL(c *gophercloud.ServiceClient) string { - return c.Endpoint + "?bulk-delete=true" -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/errors.go b/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/errors.go deleted file mode 100644 index 5c4ae44d31764..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/errors.go +++ /dev/null @@ -1,13 +0,0 @@ -package objects - -import "github.com/gophercloud/gophercloud" - -// ErrWrongChecksum is the error when the checksum generated for an object -// doesn't match the ETAG header. -type ErrWrongChecksum struct { - gophercloud.BaseError -} - -func (e ErrWrongChecksum) Error() string { - return "Local checksum does not match API ETag header" -} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/utils/choose_version.go b/vendor/github.com/gophercloud/gophercloud/openstack/utils/choose_version.go deleted file mode 100644 index 27da19f91a8d5..0000000000000 --- a/vendor/github.com/gophercloud/gophercloud/openstack/utils/choose_version.go +++ /dev/null @@ -1,111 +0,0 @@ -package utils - -import ( - "fmt" - "strings" - - "github.com/gophercloud/gophercloud" -) - -// Version is a supported API version, corresponding to a vN package within the appropriate service. -type Version struct { - ID string - Suffix string - Priority int -} - -var goodStatus = map[string]bool{ - "current": true, - "supported": true, - "stable": true, -} - -// ChooseVersion queries the base endpoint of an API to choose the most recent non-experimental alternative from a service's -// published versions. -// It returns the highest-Priority Version among the alternatives that are provided, as well as its corresponding endpoint. -func ChooseVersion(client *gophercloud.ProviderClient, recognized []*Version) (*Version, string, error) { - type linkResp struct { - Href string `json:"href"` - Rel string `json:"rel"` - } - - type valueResp struct { - ID string `json:"id"` - Status string `json:"status"` - Links []linkResp `json:"links"` - } - - type versionsResp struct { - Values []valueResp `json:"values"` - } - - type response struct { - Versions versionsResp `json:"versions"` - } - - normalize := func(endpoint string) string { - if !strings.HasSuffix(endpoint, "/") { - return endpoint + "/" - } - return endpoint - } - identityEndpoint := normalize(client.IdentityEndpoint) - - // If a full endpoint is specified, check version suffixes for a match first. - for _, v := range recognized { - if strings.HasSuffix(identityEndpoint, v.Suffix) { - return v, identityEndpoint, nil - } - } - - var resp response - _, err := client.Request("GET", client.IdentityBase, &gophercloud.RequestOpts{ - JSONResponse: &resp, - OkCodes: []int{200, 300}, - }) - - if err != nil { - return nil, "", err - } - - var highest *Version - var endpoint string - - for _, value := range resp.Versions.Values { - href := "" - for _, link := range value.Links { - if link.Rel == "self" { - href = normalize(link.Href) - } - } - - for _, version := range recognized { - if strings.Contains(value.ID, version.ID) { - // Prefer a version that exactly matches the provided endpoint. - if href == identityEndpoint { - if href == "" { - return nil, "", fmt.Errorf("Endpoint missing in version %s response from %s", value.ID, client.IdentityBase) - } - return version, href, nil - } - - // Otherwise, find the highest-priority version with a whitelisted status. - if goodStatus[strings.ToLower(value.Status)] { - if highest == nil || version.Priority > highest.Priority { - highest = version - endpoint = href - } - } - } - } - } - - if highest == nil { - return nil, "", fmt.Errorf("No supported version available from endpoint %s", client.IdentityBase) - } - if endpoint == "" { - return nil, "", fmt.Errorf("Endpoint missing in version %s response from %s", highest.ID, client.IdentityBase) - } - - return highest, endpoint, nil -} diff --git a/vendor/github.com/gophercloud/gophercloud/.gitignore b/vendor/github.com/gophercloud/gophercloud/v2/.gitignore similarity index 80% rename from vendor/github.com/gophercloud/gophercloud/.gitignore rename to vendor/github.com/gophercloud/gophercloud/v2/.gitignore index d7a5e5293a980..8b1b79e617a41 100644 --- a/vendor/github.com/gophercloud/gophercloud/.gitignore +++ b/vendor/github.com/gophercloud/gophercloud/v2/.gitignore @@ -2,3 +2,4 @@ .idea .vscode testing_*.coverprofile +/cover.out diff --git a/vendor/github.com/gophercloud/gophercloud/v2/.golangci.yaml b/vendor/github.com/gophercloud/gophercloud/v2/.golangci.yaml new file mode 100644 index 0000000000000..828a099a40cc3 --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/.golangci.yaml @@ -0,0 +1,19 @@ +--- +linters: + disable-all: true + enable: + - errcheck + - gofmt + - goimports + - govet + - staticcheck + - unparam + - unused + +issues: + exclude: + - SA1006 # printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck) + exclude-rules: + - linters: + - staticcheck + text: 'SA1019: (x509.EncryptPEMBlock|strings.Title)' diff --git a/vendor/github.com/gophercloud/gophercloud/CHANGELOG.md b/vendor/github.com/gophercloud/gophercloud/v2/CHANGELOG.md similarity index 92% rename from vendor/github.com/gophercloud/gophercloud/CHANGELOG.md rename to vendor/github.com/gophercloud/gophercloud/v2/CHANGELOG.md index b19b5e7753266..efe2d9f6af767 100644 --- a/vendor/github.com/gophercloud/gophercloud/CHANGELOG.md +++ b/vendor/github.com/gophercloud/gophercloud/v2/CHANGELOG.md @@ -1,18 +1,73 @@ -## v1.14.1 (2024-09-18) +## v2.2.0 (2024-10-18) + +* [GH-3176](https://github.com/gophercloud/gophercloud/pull/3176) [v2] [containerinfra]: add "MasterLBEnabled" in Cluster results +* [GH-3181](https://github.com/gophercloud/gophercloud/pull/3181) [v2] octavia: add new options to health monitors +* [GH-3182](https://github.com/gophercloud/gophercloud/pull/3182) [v2] octavia: add new security options to pools and listeners +* [GH-3195](https://github.com/gophercloud/gophercloud/pull/3195) [v2] [core]: handle empty response body +* [GH-3196](https://github.com/gophercloud/gophercloud/pull/3196) [v2] [fwaas_v2]: proper ParseResponse handling +* [GH-3198](https://github.com/gophercloud/gophercloud/pull/3198) [v2] compute: Fix expected and actual test results +* [GH-3199](https://github.com/gophercloud/gophercloud/pull/3199) [v2] [octavia] add an ability to filter flavors and flavorprofiles +* [GH-3214](https://github.com/gophercloud/gophercloud/pull/3214) [v2] [manila] add scheduler_hints to the shares CreateOpts +* [GH-3215](https://github.com/gophercloud/gophercloud/pull/3215) [v2] [manila] add share_group_id to share's CreateOpts +* [GH-3219](https://github.com/gophercloud/gophercloud/pull/3219) [v2] docs: Remove outdated godoc + +## v2.1.1 (2024-09-18) + +* [GH-3161](https://github.com/gophercloud/gophercloud/pull/3161) [v2] fix: create security group rule with any protocol + +## v2.1.0 (2024-07-24) + +* [GH-3078](https://github.com/gophercloud/gophercloud/pull/3078) [networking]: add BGP VPNs support +* [GH-3086](https://github.com/gophercloud/gophercloud/pull/3086) build(deps): bump golang.org/x/crypto from 0.24.0 to 0.25.0 +* [GH-3090](https://github.com/gophercloud/gophercloud/pull/3090) Adding support for field dns_publish_fixed_ip in a subnet +* [GH-3092](https://github.com/gophercloud/gophercloud/pull/3092) [neutron]: introduce Stateful argument for the security groups +* [GH-3094](https://github.com/gophercloud/gophercloud/pull/3094) [neutron]: introduce Description argument for the portforwarding +* [GH-3106](https://github.com/gophercloud/gophercloud/pull/3106) clouds: Parse trust_id from clouds.yaml +* [GH-3131](https://github.com/gophercloud/gophercloud/pull/3131) Align ServiceFail provisioning state value with Ironic +* [GH-3136](https://github.com/gophercloud/gophercloud/pull/3136) Added node.Retired + +## v2.0.0 (2024-05-27) + +MAIN BREAKING CHANGES: + +* **Gophercloud now requires Go v1.22.** +* [GH-2821](https://github.com/gophercloud/gophercloud/pull/2821) Gophercloud now escapes container and object names in all `objects` and `containers` functions. If you were previously escaping names (with, for example: `url.PathEscape` or `url.QueryEscape`), then you should REMOVE that and pass the intended names to Gophercloud directly. +* [GH-2821](https://github.com/gophercloud/gophercloud/pull/2821) The `containers.ListOpts#Full` and `objects.ListOpts#Full` properties are REMOVED from the Gophercloud API. The reason for that is: plaintext listing is unfixably wrong and won't handle special characters reliably (i.e. `\n`). +* [GH-2821](https://github.com/gophercloud/gophercloud/pull/2821) Empty container names, container names containing a slash (`/`), and empty object names are now rejected in Gophercloud before any call to Swift. +* [GH-2821](https://github.com/gophercloud/gophercloud/pull/2821) In `objectstorage`: `containers.ErrInvalidContainerName` is now `v1.ErrInvalidContainerName`. +* [GH-2821](https://github.com/gophercloud/gophercloud/pull/2821) New name validation errors in `objectstorage`: + * `v1.ErrEmptyContainerName` + * `v1.ErrEmptyObjectName` +* [GH-2821](https://github.com/gophercloud/gophercloud/pull/2821) In `objects.Copy`: the `destination` field (e.g. `objects.CopyOpts#Destination`) must be in the form `/container/object`: the function will reject a destination path if it doesn't start with a slash (`/`). +* [GH-2560](https://github.com/gophercloud/gophercloud/pull/2560) loadbalancer: Use CreateMemberOpts instead of BatchUpdateMemberOpts in PoolCreateOpts +* [GH-2886](https://github.com/gophercloud/gophercloud/pull/2886) ports: Fix value_specs implementation +* [GH-2665](https://github.com/gophercloud/gophercloud/pull/2665) Cinder: Remove multiatttach request parameter +* [GH-2936](https://github.com/gophercloud/gophercloud/pull/2936) Make Gophercloud context-aware: all function signatures triggering an HTTP call now accept a context.Context for tracing and cancellation +* [GH-2970](https://github.com/gophercloud/gophercloud/pull/2970) Remove context from the Provider client +* [GH-2904](https://github.com/gophercloud/gophercloud/pull/2904) Remove error code types -* [GH-3162](https://github.com/gophercloud/gophercloud/pull/3162) Fix security group rule "any protocol" - -## v1.14.0 (2024-07-24) - -* [GH-3095](https://github.com/gophercloud/gophercloud/pull/3095) [neutron]: introduce Description argument for the portforwarding -* [GH-3098](https://github.com/gophercloud/gophercloud/pull/3098) [neutron]: introduce Stateful argument for the security groups -* [GH-3099](https://github.com/gophercloud/gophercloud/pull/3099) [networking]: subnet add field dns_publish_fixed_ip - -## v1.13.0 (2024-07-08) +New features and improvements: -* [GH-3044](https://github.com/gophercloud/gophercloud/pull/3044) [v1] Add ci jobs for openstack caracal -* [GH-3073](https://github.com/gophercloud/gophercloud/pull/3073) [v1] Adding missing QoS field for router -* [GH-3080](https://github.com/gophercloud/gophercloud/pull/3080) [networking]: add BGP VPNs support (backport to 1.x) +* [GH-2486](https://github.com/gophercloud/gophercloud/pull/2486) Fix BareMetalV1 version +* [GH-2492](https://github.com/gophercloud/gophercloud/pull/2492) Add tags for loadbalancer l7policy and l7rule +* [GH-2560](https://github.com/gophercloud/gophercloud/pull/2560) loadbalancer: Use CreateMemberOpts instead of BatchUpdateMemberOpts in PoolCreateOpts +* [GH-2561](https://github.com/gophercloud/gophercloud/pull/2561) compute: add ext_specs to flavor +* [GH-2613](https://github.com/gophercloud/gophercloud/pull/2613) Migrate baremetal inventory to a common location +* [GH-2724](https://github.com/gophercloud/gophercloud/pull/2724) baremetal: introduce Node Inventory API +* [GH-2725](https://github.com/gophercloud/gophercloud/pull/2725) baremetal: finish moving common inventory bits +* [GH-2736](https://github.com/gophercloud/gophercloud/pull/2736) Composable templates +* [GH-2781](https://github.com/gophercloud/gophercloud/pull/2781) baremetal: support ironic native PluginData +* [GH-2791](https://github.com/gophercloud/gophercloud/pull/2791) Add microversion utilities +* [GH-2806](https://github.com/gophercloud/gophercloud/pull/2806) Fix list ports with multiple fixedip parameters +* [GH-2809](https://github.com/gophercloud/gophercloud/pull/2809) Remove code for CDN (poppy) +* [GH-2812](https://github.com/gophercloud/gophercloud/pull/2812) Revert "Fix baremetal jobs on Ubuntu 20.04" +* [GH-2821](https://github.com/gophercloud/gophercloud/pull/2821) objects: Escape names in Gophercloud +* [GH-2828](https://github.com/gophercloud/gophercloud/pull/2828) Octavia: Add tags to resources missing them +* [GH-2834](https://github.com/gophercloud/gophercloud/pull/2834) baremetal: implemented ParsedLLDP in the standard PluginData +* [GH-2866](https://github.com/gophercloud/gophercloud/pull/2866) loadbalancer additional_vips by snigle +* [GH-2881](https://github.com/gophercloud/gophercloud/pull/2881) Adding missing QoS field for router +* [GH-2883](https://github.com/gophercloud/gophercloud/pull/2883) Context-aware methods to ProviderClient and ServiceClient +* [GH-2892](https://github.com/gophercloud/gophercloud/pull/2892) Authenticate with a clouds.yaml ## v1.12.0 (2024-05-27) diff --git a/vendor/github.com/gophercloud/gophercloud/LICENSE b/vendor/github.com/gophercloud/gophercloud/v2/LICENSE similarity index 100% rename from vendor/github.com/gophercloud/gophercloud/LICENSE rename to vendor/github.com/gophercloud/gophercloud/v2/LICENSE diff --git a/vendor/github.com/gophercloud/gophercloud/v2/Makefile b/vendor/github.com/gophercloud/gophercloud/v2/Makefile new file mode 100644 index 0000000000000..128beec005875 --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/Makefile @@ -0,0 +1,109 @@ +undefine GOFLAGS + +GOLANGCI_LINT_VERSION?=v1.57.1 + +ifeq ($(shell command -v podman 2> /dev/null),) + RUNNER=docker +else + RUNNER=podman +endif + +# if the golangci-lint steps fails with the following error message: +# +# directory prefix . does not contain main module or its selected dependencies +# +# you probably have to fix the SELinux security context for root directory plus your cache +# +# chcon -Rt svirt_sandbox_file_t . +# chcon -Rt svirt_sandbox_file_t ~/.cache/golangci-lint +lint: + $(RUNNER) run -t --rm \ + -v $(shell pwd):/app \ + -v ~/.cache/golangci-lint/$(GOLANGCI_LINT_VERSION):/root/.cache \ + -w /app \ + -e GOFLAGS="-tags=acceptance" \ + golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) golangci-lint run +.PHONY: lint + +unit: + go test ./... +.PHONY: unit + +coverage: + go test -covermode count -coverprofile cover.out -coverpkg=./... ./... +.PHONY: coverage + +acceptance: acceptance-baremetal acceptance-blockstorage acceptance-compute acceptance-container acceptance-containerinfra acceptance-db acceptance-dns acceptance-identity acceptance-imageservice acceptance-keymanager acceptance-loadbalancer acceptance-messaging acceptance-networking acceptance-objectstorage acceptance-orchestration acceptance-placement acceptance-sharedfilesystems acceptance-workflow +.PHONY: acceptance + +acceptance-baremetal: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/baremetal/... +.PHONY: acceptance-baremetal + +acceptance-blockstorage: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/blockstorage/... +.PHONY: acceptance-blockstorage + +acceptance-compute: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/compute/... +.PHONY: acceptance-compute + +acceptance-container: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/container/... +.PHONY: acceptance-container + +acceptance-containerinfra: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/containerinfra/... +.PHONY: acceptance-containerinfra + +acceptance-db: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/db/... +.PHONY: acceptance-db + +acceptance-dns: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/dns/... +.PHONY: acceptance-dns + +acceptance-identity: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/identity/... +.PHONY: acceptance-identity + +acceptance-image: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/imageservice/... +.PHONY: acceptance-image + +acceptance-keymanager: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/keymanager/... +.PHONY: acceptance-keymanager + +acceptance-loadbalancer: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/loadbalancer/... +.PHONY: acceptance-loadbalancer + +acceptance-messaging: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/messaging/... +.PHONY: acceptance-messaging + +acceptance-networking: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/networking/... +.PHONY: acceptance-networking + +acceptance-objectstorage: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/objectstorage/... +.PHONY: acceptance-objectstorage + +acceptance-orchestration: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/orchestration/... +.PHONY: acceptance-orchestration + +acceptance-placement: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/placement/... +.PHONY: acceptance-placement + +acceptance-sharedfilesystems: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/sharedfilesystems/... +.PHONY: acceptance-sharefilesystems + +acceptance-workflow: + go test -tags "fixtures acceptance" ./internal/acceptance/openstack/workflow/... +.PHONY: acceptance-workflow diff --git a/vendor/github.com/gophercloud/gophercloud/v2/README.md b/vendor/github.com/gophercloud/gophercloud/v2/README.md new file mode 100644 index 0000000000000..ca47f5b0ba5ce --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/README.md @@ -0,0 +1,252 @@ +# Gophercloud: an OpenStack SDK for Go +[![Coverage Status](https://coveralls.io/repos/github/gophercloud/gophercloud/badge.svg?branch=master)](https://coveralls.io/github/gophercloud/gophercloud?branch=master) + +Gophercloud is a Go SDK for OpenStack. + +Join us on kubernetes slack, on [#gophercloud](https://kubernetes.slack.com/archives/C05G4NJ6P6X). Visit [slack.k8s.io](https://slack.k8s.io) for an invitation. + +> **Note** +> This branch contains the current stable branch of Gophercloud: `v2`. +> The legacy stable version can be found in the `v1` branch. + +## How to install + +Reference a Gophercloud package in your code: + +```go +import "github.com/gophercloud/gophercloud/v2" +``` + +Then update your `go.mod`: + +```shell +go mod tidy +``` + +## Getting started + +### Credentials + +Because you'll be hitting an API, you will need to retrieve your OpenStack +credentials and either store them in a `clouds.yaml` file, as environment +variables, or in your local Go files. The first method is recommended because +it decouples credential information from source code, allowing you to push the +latter to your version control system without any security risk. + +You will need to retrieve the following: + +* A valid Keystone identity URL +* Credentials. These can be a username/password combo, a set of Application + Credentials, a pre-generated token, or any other supported authentication + mechanism. + +For users who have the OpenStack dashboard installed, there's a shortcut. If +you visit the `project/api_access` path in Horizon and click on the +"Download OpenStack RC File" button at the top right hand corner, you can +download either a `clouds.yaml` file or an `openrc` bash file that exports all +of your access details to environment variables. To use the `clouds.yaml` file, +place it at `~/.config/openstack/clouds.yaml`. To use the `openrc` file, run +`source openrc` and you will be prompted for your password. + +### Gophercloud authentication + +Gophercloud authentication is organized into two layered abstractions: +* `ProviderClient` holds the authentication token and can be used to build a + `ServiceClient`. +* `ServiceClient` specializes against one specific OpenStack module and can + directly be used to make API calls. + +A provider client is a top-level client that all of your OpenStack service +clients derive from. The provider contains all of the authentication details +that allow your Go code to access the API - such as the base URL and token ID. + +One single Provider client can be used to build as many Service clients as needed. + +**With `clouds.yaml`** + +```go +package main + +import ( + "context" + + "github.com/gophercloud/gophercloud/v2/openstack" + "github.com/gophercloud/gophercloud/v2/openstack/config" + "github.com/gophercloud/gophercloud/v2/openstack/config/clouds" +) + +func main() { + ctx := context.Background() + + // Fetch coordinates from a `cloud.yaml` in the current directory, or + // in the well-known config directories (different for each operating + // system). + authOptions, endpointOptions, tlsConfig, err := clouds.Parse() + if err != nil { + panic(err) + } + + // Call Keystone to get an authentication token, and use it to + // construct a ProviderClient. All functions hitting the OpenStack API + // accept a `context.Context` to enable tracing and cancellation. + providerClient, err := config.NewProviderClient(ctx, authOptions, config.WithTLSConfig(tlsConfig)) + if err != nil { + panic(err) + } + + // Use the ProviderClient and the endpoint options fetched from + // `clouds.yaml` to build a service client: a compute client in this + // case. Note that the contructor does not accept a `context.Context`: + // no further call to the OpenStack API is needed at this stage. + computeClient, err := openstack.NewComputeV2(providerClient, endpointOptions) + if err != nil { + panic(err) + } + + // use the computeClient +} +``` + +**With environment variables (`openrc`)** + +Gophercloud can parse the environment variables set by running `source openrc`: + +```go +package main + +import ( + "context" + "os" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack" +) + +func main() { + ctx := context.Background() + + opts, err := openstack.AuthOptionsFromEnv() + if err != nil { + panic(err) + } + + providerClient, err := openstack.AuthenticatedClient(ctx, opts) + if err != nil { + panic(err) + } + + computeClient, err := openstack.NewComputeV2(providerClient, gophercloud.EndpointOpts{ + Region: os.Getenv("OS_REGION_NAME"), + }) + if err != nil { + panic(err) + } + + // use the computeClient +} +``` + +**Manually** + +You can also generate a "Provider" by passing in your credentials +explicitly: + +```go +package main + +import ( + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack" +) + +func main() { + ctx := context.Background() + + providerClient, err := openstack.AuthenticatedClient(ctx, gophercloud.AuthOptions{ + IdentityEndpoint: "https://openstack.example.com:5000/v2.0", + Username: "username", + Password: "password", + }) + if err != nil { + panic(err) + } + + computeClient, err := openstack.NewComputeV2(providerClient, gophercloud.EndpointOpts{ + Region: "RegionName", + }) + if err != nil { + panic(err) + } + + // use the computeClient +} +``` + +### Provision a server + +We can use the Compute service client generated above for any Compute API +operation we want. In our case, we want to provision a new server. To do this, +we invoke the `Create` method and pass in the flavor ID (hardware +specification) and image ID (operating system) we're interested in: + +```go +import "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + +func main() { + // [...] + + server, err := servers.Create(context.TODO(), computeClient, servers.CreateOpts{ + Name: "My new server!", + FlavorRef: "flavor_id", + ImageRef: "image_id", + }).Extract() + + // [...] +``` + +The above code sample creates a new server with the parameters, and returns a +[`servers.Server`](https://pkg.go.dev/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers#Server). + +## Supported Services + +| **Service** | **Name** | **Module** | **1.x** | **2.x** | +|:------------------------:|------------------|:----------------------------------:|:-------:|:-------:| +| Baremetal | Ironic | `openstack/baremetal` | ✔ | ✔ | +| Baremetal Introspection | Ironic Inspector | `openstack/baremetalintrospection` | ✔ | ✔ | +| Block Storage | Cinder | `openstack/blockstorage` | ✔ | ✔ | +| Clustering | Senlin | `openstack/clustering` | ✔ | ✘ | +| Compute | Nova | `openstack/compute` | ✔ | ✔ | +| Container | Zun | `openstack/container` | ✔ | ✔ | +| Container Infrastructure | Magnum | `openstack/containerinfra` | ✔ | ✔ | +| Database | Trove | `openstack/db` | ✔ | ✔ | +| DNS | Designate | `openstack/dns` | ✔ | ✔ | +| Identity | Keystone | `openstack/identity` | ✔ | ✔ | +| Image | Glance | `openstack/image` | ✔ | ✔ | +| Key Management | Barbican | `openstack/keymanager` | ✔ | ✔ | +| Load Balancing | Octavia | `openstack/loadbalancer` | ✔ | ✔ | +| Messaging | Zaqar | `openstack/messaging` | ✔ | ✔ | +| Networking | Neutron | `openstack/networking` | ✔ | ✔ | +| Object Storage | Swift | `openstack/objectstorage` | ✔ | ✔ | + +## Advanced Usage + +Have a look at the [FAQ](./docs/FAQ.md) for some tips on customizing the way Gophercloud works. + +## Backwards-Compatibility Guarantees + +Gophercloud versioning follows [semver](https://semver.org/spec/v2.0.0.html). + +Before `v1.0.0`, there were no guarantees. Starting with v1, there will be no breaking changes within a major release. + +See the [Release instructions](./RELEASE.md). + +## Contributing + +See the [contributing guide](./.github/CONTRIBUTING.md). + +## Help and feedback + +If you're struggling with something or have spotted a potential bug, feel free +to submit an issue to our [bug tracker](https://github.com/gophercloud/gophercloud/issues). diff --git a/vendor/github.com/gophercloud/gophercloud/RELEASE.md b/vendor/github.com/gophercloud/gophercloud/v2/RELEASE.md similarity index 100% rename from vendor/github.com/gophercloud/gophercloud/RELEASE.md rename to vendor/github.com/gophercloud/gophercloud/v2/RELEASE.md diff --git a/vendor/github.com/gophercloud/gophercloud/auth_options.go b/vendor/github.com/gophercloud/gophercloud/v2/auth_options.go similarity index 90% rename from vendor/github.com/gophercloud/gophercloud/auth_options.go rename to vendor/github.com/gophercloud/gophercloud/v2/auth_options.go index 335ce87957d5a..616919d00086c 100644 --- a/vendor/github.com/gophercloud/gophercloud/auth_options.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/auth_options.go @@ -19,13 +19,13 @@ An example of manually providing authentication information: TenantID: "{tenant_id}", } - provider, err := openstack.AuthenticatedClient(opts) + provider, err := openstack.AuthenticatedClient(context.TODO(), opts) An example of using AuthOptionsFromEnv(), where the environment variables can be read from a file, such as a standard openrc file: opts, err := openstack.AuthOptionsFromEnv() - provider, err := openstack.AuthenticatedClient(opts) + provider, err := openstack.AuthenticatedClient(context.TODO(), opts) */ type AuthOptions struct { // IdentityEndpoint specifies the HTTP endpoint that is required to work with @@ -102,17 +102,18 @@ type AuthScope struct { DomainID string DomainName string System bool + TrustID string } // ToTokenV2CreateMap allows AuthOptions to satisfy the AuthOptionsBuilder // interface in the v2 tokens package -func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error) { +func (opts AuthOptions) ToTokenV2CreateMap() (map[string]any, error) { // Populate the request map. - authMap := make(map[string]interface{}) + authMap := make(map[string]any) if opts.Username != "" { if opts.Password != "" { - authMap["passwordCredentials"] = map[string]interface{}{ + authMap["passwordCredentials"] = map[string]any{ "username": opts.Username, "password": opts.Password, } @@ -120,7 +121,7 @@ func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error) { return nil, ErrMissingInput{Argument: "Password"} } } else if opts.TokenID != "" { - authMap["token"] = map[string]interface{}{ + authMap["token"] = map[string]any{ "id": opts.TokenID, } } else { @@ -134,23 +135,17 @@ func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error) { authMap["tenantName"] = opts.TenantName } - return map[string]interface{}{"auth": authMap}, nil + return map[string]any{"auth": authMap}, nil } // ToTokenV3CreateMap allows AuthOptions to satisfy the AuthOptionsBuilder // interface in the v3 tokens package -func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]interface{}) (map[string]interface{}, error) { +func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]any) (map[string]any, error) { type domainReq struct { ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` } - type projectReq struct { - Domain *domainReq `json:"domain,omitempty"` - Name *string `json:"name,omitempty"` - ID *string `json:"id,omitempty"` - } - type userReq struct { ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` @@ -397,7 +392,7 @@ func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]interface{}) (map[s } if len(scope) != 0 { - b["auth"].(map[string]interface{})["scope"] = scope + b["auth"].(map[string]any)["scope"] = scope } return b, nil @@ -405,7 +400,7 @@ func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]interface{}) (map[s // ToTokenV3ScopeMap builds a scope from AuthOptions and satisfies interface in // the v3 tokens package. -func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) { +func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]any, error) { // For backwards compatibility. // If AuthOptions.Scope was not set, try to determine it. // This works well for common scenarios. @@ -423,13 +418,21 @@ func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) { } if opts.Scope.System { - return map[string]interface{}{ - "system": map[string]interface{}{ + return map[string]any{ + "system": map[string]any{ "all": true, }, }, nil } + if opts.Scope.TrustID != "" { + return map[string]any{ + "OS-TRUST:trust": map[string]string{ + "id": opts.Scope.TrustID, + }, + }, nil + } + if opts.Scope.ProjectName != "" { // ProjectName provided: either DomainID or DomainName must also be supplied. // ProjectID may not be supplied. @@ -442,20 +445,20 @@ func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) { if opts.Scope.DomainID != "" { // ProjectName + DomainID - return map[string]interface{}{ - "project": map[string]interface{}{ + return map[string]any{ + "project": map[string]any{ "name": &opts.Scope.ProjectName, - "domain": map[string]interface{}{"id": &opts.Scope.DomainID}, + "domain": map[string]any{"id": &opts.Scope.DomainID}, }, }, nil } if opts.Scope.DomainName != "" { // ProjectName + DomainName - return map[string]interface{}{ - "project": map[string]interface{}{ + return map[string]any{ + "project": map[string]any{ "name": &opts.Scope.ProjectName, - "domain": map[string]interface{}{"name": &opts.Scope.DomainName}, + "domain": map[string]any{"name": &opts.Scope.DomainName}, }, }, nil } @@ -469,8 +472,8 @@ func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) { } // ProjectID - return map[string]interface{}{ - "project": map[string]interface{}{ + return map[string]any{ + "project": map[string]any{ "id": &opts.Scope.ProjectID, }, }, nil @@ -481,15 +484,15 @@ func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) { } // DomainID - return map[string]interface{}{ - "domain": map[string]interface{}{ + return map[string]any{ + "domain": map[string]any{ "id": &opts.Scope.DomainID, }, }, nil } else if opts.Scope.DomainName != "" { // DomainName - return map[string]interface{}{ - "domain": map[string]interface{}{ + return map[string]any{ + "domain": map[string]any{ "name": &opts.Scope.DomainName, }, }, nil @@ -509,6 +512,6 @@ func (opts AuthOptions) CanReauth() bool { // ToTokenV3HeadersMap allows AuthOptions to satisfy the AuthOptionsBuilder // interface in the v3 tokens package. -func (opts *AuthOptions) ToTokenV3HeadersMap(map[string]interface{}) (map[string]string, error) { +func (opts *AuthOptions) ToTokenV3HeadersMap(map[string]any) (map[string]string, error) { return nil, nil } diff --git a/vendor/github.com/gophercloud/gophercloud/auth_result.go b/vendor/github.com/gophercloud/gophercloud/v2/auth_result.go similarity index 87% rename from vendor/github.com/gophercloud/gophercloud/auth_result.go rename to vendor/github.com/gophercloud/gophercloud/v2/auth_result.go index 2e4699b978ce4..9a49cce8e57c1 100644 --- a/vendor/github.com/gophercloud/gophercloud/auth_result.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/auth_result.go @@ -12,9 +12,9 @@ The following types satisfy this interface: Usage example: import ( - "github.com/gophercloud/gophercloud" - tokens2 "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens" - tokens3 "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" + "github.com/gophercloud/gophercloud/v2" + tokens2 "github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens" + tokens3 "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens" ) func GetAuthenticatedUserID(providerClient *gophercloud.ProviderClient) (string, error) { diff --git a/vendor/github.com/gophercloud/gophercloud/endpoint_search.go b/vendor/github.com/gophercloud/gophercloud/v2/endpoint_search.go similarity index 100% rename from vendor/github.com/gophercloud/gophercloud/endpoint_search.go rename to vendor/github.com/gophercloud/gophercloud/v2/endpoint_search.go diff --git a/vendor/github.com/gophercloud/gophercloud/errors.go b/vendor/github.com/gophercloud/gophercloud/v2/errors.go similarity index 61% rename from vendor/github.com/gophercloud/gophercloud/errors.go rename to vendor/github.com/gophercloud/gophercloud/v2/errors.go index 8ab592ca4914e..2698c20395619 100644 --- a/vendor/github.com/gophercloud/gophercloud/errors.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/errors.go @@ -1,6 +1,8 @@ package gophercloud import ( + "bytes" + "errors" "fmt" "net/http" "strings" @@ -39,7 +41,7 @@ func (e ErrMissingInput) Error() string { // ErrInvalidInput is an error type used for most non-HTTP Gophercloud errors. type ErrInvalidInput struct { ErrMissingInput - Value interface{} + Value any } func (e ErrInvalidInput) Error() string { @@ -88,8 +90,8 @@ type ErrUnexpectedResponseCode struct { func (e ErrUnexpectedResponseCode) Error() string { e.DefaultErrString = fmt.Sprintf( - "Expected HTTP response code %v when accessing [%s %s], but got %d instead\n%s", - e.Expected, e.Method, e.URL, e.Actual, e.Body, + "Expected HTTP response code %v when accessing [%s %s], but got %d instead: %s", + e.Expected, e.Method, e.URL, e.Actual, bytes.TrimSpace(e.Body), ) return e.choseErrString() } @@ -99,244 +101,22 @@ func (e ErrUnexpectedResponseCode) GetStatusCode() int { return e.Actual } -// StatusCodeError is a convenience interface to easily allow access to the -// status code field of the various ErrDefault* types. +// ResponseCodeIs returns true if this error is or contains an ErrUnexpectedResponseCode reporting +// that the request failed with the given response code. For example, this checks if a request +// failed because of a 404 error: // -// By using this interface, you only have to make a single type cast of -// the returned error to err.(StatusCodeError) and then call GetStatusCode() -// instead of having a large switch statement checking for each of the -// ErrDefault* types. -type StatusCodeError interface { - Error() string - GetStatusCode() int -} - -// ErrDefault400 is the default error type returned on a 400 HTTP response code. -type ErrDefault400 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault400) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault401 is the default error type returned on a 401 HTTP response code. -type ErrDefault401 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault401) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault403 is the default error type returned on a 403 HTTP response code. -type ErrDefault403 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault403) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault404 is the default error type returned on a 404 HTTP response code. -type ErrDefault404 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault404) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault405 is the default error type returned on a 405 HTTP response code. -type ErrDefault405 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault405) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault408 is the default error type returned on a 408 HTTP response code. -type ErrDefault408 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault408) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault409 is the default error type returned on a 409 HTTP response code. -type ErrDefault409 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault409) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault429 is the default error type returned on a 429 HTTP response code. -type ErrDefault429 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault429) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault500 is the default error type returned on a 500 HTTP response code. -type ErrDefault500 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault500) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault502 is the default error type returned on a 502 HTTP response code. -type ErrDefault502 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault502) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault503 is the default error type returned on a 503 HTTP response code. -type ErrDefault503 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault503) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -// ErrDefault504 is the default error type returned on a 504 HTTP response code. -type ErrDefault504 struct { - ErrUnexpectedResponseCode -} - -func (e ErrDefault504) Unwrap() error { - return e.ErrUnexpectedResponseCode -} - -func (e ErrDefault400) Error() string { - e.DefaultErrString = fmt.Sprintf( - "Bad request with: [%s %s], error message: %s", - e.Method, e.URL, e.Body, - ) - return e.choseErrString() -} -func (e ErrDefault401) Error() string { - return "Authentication failed" -} -func (e ErrDefault403) Error() string { - e.DefaultErrString = fmt.Sprintf( - "Request forbidden: [%s %s], error message: %s", - e.Method, e.URL, e.Body, - ) - return e.choseErrString() -} -func (e ErrDefault404) Error() string { - 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" -} -func (e ErrDefault408) Error() string { - return "The server timed out waiting for the request" -} -func (e ErrDefault429) Error() string { - return "Too many requests have been sent in a given amount of time. Pause" + - " requests, wait up to one minute, and try again." -} -func (e ErrDefault500) Error() string { - return "Internal Server Error" -} -func (e ErrDefault502) Error() string { - return "Bad Gateway" -} -func (e ErrDefault503) Error() string { - return "The service is currently unable to handle the request due to a temporary" + - " overloading or maintenance. This is a temporary condition. Try again later." -} -func (e ErrDefault504) Error() string { - return "Gateway Timeout" -} - -// Err400er is the interface resource error types implement to override the error message -// from a 400 error. -type Err400er interface { - Error400(ErrUnexpectedResponseCode) error -} - -// Err401er is the interface resource error types implement to override the error message -// from a 401 error. -type Err401er interface { - Error401(ErrUnexpectedResponseCode) error -} - -// Err403er is the interface resource error types implement to override the error message -// from a 403 error. -type Err403er interface { - Error403(ErrUnexpectedResponseCode) error -} - -// Err404er is the interface resource error types implement to override the error message -// from a 404 error. -type Err404er interface { - Error404(ErrUnexpectedResponseCode) error -} - -// Err405er is the interface resource error types implement to override the error message -// from a 405 error. -type Err405er interface { - Error405(ErrUnexpectedResponseCode) error -} - -// Err408er is the interface resource error types implement to override the error message -// from a 408 error. -type Err408er interface { - Error408(ErrUnexpectedResponseCode) error -} - -// Err409er is the interface resource error types implement to override the error message -// from a 409 error. -type Err409er interface { - Error409(ErrUnexpectedResponseCode) error -} - -// Err429er is the interface resource error types implement to override the error message -// from a 429 error. -type Err429er interface { - Error429(ErrUnexpectedResponseCode) error -} - -// Err500er is the interface resource error types implement to override the error message -// from a 500 error. -type Err500er interface { - Error500(ErrUnexpectedResponseCode) error -} - -// Err502er is the interface resource error types implement to override the error message -// from a 502 error. -type Err502er interface { - Error502(ErrUnexpectedResponseCode) error -} - -// Err503er is the interface resource error types implement to override the error message -// from a 503 error. -type Err503er interface { - Error503(ErrUnexpectedResponseCode) error -} - -// Err504er is the interface resource error types implement to override the error message -// from a 504 error. -type Err504er interface { - Error504(ErrUnexpectedResponseCode) error +// allServers, err := servers.List(client, servers.ListOpts{}) +// if gophercloud.ResponseCodeIs(err, http.StatusNotFound) { +// handleNotFound() +// } +// +// It is safe to pass a nil error, in which case this function always returns false. +func ResponseCodeIs(err error, status int) bool { + var codeError ErrUnexpectedResponseCode + if errors.As(err, &codeError) { + return codeError.Actual == status + } + return false } // ErrTimeOut is the error type returned when an operations times out. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/auth_env.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/auth_env.go similarity index 97% rename from vendor/github.com/gophercloud/gophercloud/openstack/auth_env.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/auth_env.go index 7c6d06f0c3e29..893787b7874a7 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/auth_env.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/auth_env.go @@ -3,7 +3,7 @@ package openstack import ( "os" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) var nilOptions = gophercloud.AuthOptions{} @@ -31,7 +31,7 @@ To use this function, first set the OS_* environment variables (for example, by sourcing an `openrc` file), then: opts, err := openstack.AuthOptionsFromEnv() - provider, err := openstack.AuthenticatedClient(opts) + provider, err := openstack.AuthenticatedClient(context.TODO(), opts) */ func AuthOptionsFromEnv() (gophercloud.AuthOptions, error) { authURL := os.Getenv("OS_AUTH_URL") diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/doc.go new file mode 100644 index 0000000000000..2ab4af93ee3af --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/doc.go @@ -0,0 +1,161 @@ +/* +Package volumes provides information and interaction with volumes in the +OpenStack Block Storage service. A volume is a detachable block storage +device, akin to a USB hard drive. It can only be attached to one instance at +a time. + +Example of creating Volume B on a Different Host than Volume A + + schedulerHintOpts := volumes.SchedulerHintCreateOpts{ + DifferentHost: []string{ + "volume-a-uuid", + } + } + + createOpts := volumes.CreateOpts{ + Name: "volume_b", + Size: 10, + } + + volume, err := volumes.Create(context.TODO(), computeClient, createOpts, schedulerHintOpts).Extract() + if err != nil { + panic(err) + } + +Example of creating Volume B on the Same Host as Volume A + + schedulerHintOpts := volumes.SchedulerHintCreateOpts{ + SameHost: []string{ + "volume-a-uuid", + } + } + + createOpts := volumes.CreateOpts{ + Name: "volume_b", + Size: 10 + } + + volume, err := volumes.Create(context.TODO(), computeClient, createOpts, schedulerHintOpts).Extract() + if err != nil { + panic(err) + } + +Example of creating a Volume from a Backup + + backupID := "20c792f0-bb03-434f-b653-06ef238e337e" + options := volumes.CreateOpts{ + Name: "vol-001", + BackupID: &backupID, + } + + client.Microversion = "3.47" + volume, err := volumes.Create(context.TODO(), client, options, nil).Extract() + if err != nil { + panic(err) + } + + fmt.Println(volume) + +Example of Creating an Image from a Volume + + uploadImageOpts := volumes.UploadImageOpts{ + ImageName: "my_vol", + Force: true, + } + + volumeImage, err := volumes.UploadImage(context.TODO(), client, volume.ID, uploadImageOpts).Extract() + if err != nil { + panic(err) + } + + fmt.Printf("%+v\n", volumeImage) + +Example of Extending a Volume's Size + + extendOpts := volumes.ExtendSizeOpts{ + NewSize: 100, + } + + err := volumes.ExtendSize(context.TODO(), client, volume.ID, extendOpts).ExtractErr() + if err != nil { + panic(err) + } + +Example of Initializing a Volume Connection + + connectOpts := &volumes.InitializeConnectionOpts{ + IP: "127.0.0.1", + Host: "stack", + Initiator: "iqn.1994-05.com.redhat:17cf566367d2", + Multipath: gophercloud.Disabled, + Platform: "x86_64", + OSType: "linux2", + } + + connectionInfo, err := volumes.InitializeConnection(context.TODO(), client, volume.ID, connectOpts).Extract() + if err != nil { + panic(err) + } + + fmt.Printf("%+v\n", connectionInfo["data"]) + + terminateOpts := &volumes.InitializeConnectionOpts{ + IP: "127.0.0.1", + Host: "stack", + Initiator: "iqn.1994-05.com.redhat:17cf566367d2", + Multipath: gophercloud.Disabled, + Platform: "x86_64", + OSType: "linux2", + } + + err = volumes.TerminateConnection(context.TODO(), client, volume.ID, terminateOpts).ExtractErr() + if err != nil { + panic(err) + } + +Example of Setting a Volume's Bootable status + + options := volumes.BootableOpts{ + Bootable: true, + } + + err := volumes.SetBootable(context.TODO(), client, volume.ID, options).ExtractErr() + if err != nil { + panic(err) + } + +Example of Changing Type of a Volume + + changeTypeOpts := volumes.ChangeTypeOpts{ + NewType: "ssd", + MigrationPolicy: volumes.MigrationPolicyOnDemand, + } + + err = volumes.ChangeType(context.TODO(), client, volumeID, changeTypeOpts).ExtractErr() + if err != nil { + panic(err) + } + +Example of Attaching a Volume to an Instance + + attachOpts := volumes.AttachOpts{ + MountPoint: "/mnt", + Mode: "rw", + InstanceUUID: server.ID, + } + + err := volumes.Attach(context.TODO(), client, volume.ID, attachOpts).ExtractErr() + if err != nil { + panic(err) + } + + detachOpts := volumes.DetachOpts{ + AttachmentID: volume.Attachments[0].AttachmentID, + } + + err = volumes.Detach(context.TODO(), client, volume.ID, detachOpts).ExtractErr() + if err != nil { + panic(err) + } +*/ +package volumes diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/requests.go new file mode 100644 index 0000000000000..77210943b5377 --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/requests.go @@ -0,0 +1,765 @@ +package volumes + +import ( + "context" + "maps" + "regexp" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" +) + +// SchedulerHintOptsBuilder builds the scheduler hints into a serializable format. +type SchedulerHintOptsBuilder interface { + ToSchedulerHintsMap() (map[string]any, error) +} + +// SchedulerHintOpts contains options for providing scheduler hints +// when creating a Volume. This object is passed to the volumes.Create function. +// For more information about these parameters, see the Volume object. +type SchedulerHintOpts struct { + // DifferentHost will place the volume on a different back-end that does not + // host the given volumes. + DifferentHost []string + + // SameHost will place the volume on a back-end that hosts the given volumes. + SameHost []string + + // LocalToInstance will place volume on same host on a given instance + LocalToInstance string + + // Query is a conditional statement that results in back-ends able to + // host the volume. + Query string + + // AdditionalProperies are arbitrary key/values that are not validated by nova. + AdditionalProperties map[string]any +} + +// ToSchedulerHintsMap assembles a request body for scheduler hints +func (opts SchedulerHintOpts) ToSchedulerHintsMap() (map[string]any, error) { + sh := make(map[string]any) + + uuidRegex, _ := regexp.Compile("^[a-z0-9]{8}-[a-z0-9]{4}-[1-5][a-z0-9]{3}-[a-z0-9]{4}-[a-z0-9]{12}$") + + if len(opts.DifferentHost) > 0 { + for _, diffHost := range opts.DifferentHost { + if !uuidRegex.MatchString(diffHost) { + err := gophercloud.ErrInvalidInput{} + err.Argument = "volumes.SchedulerHintOpts.DifferentHost" + err.Value = opts.DifferentHost + err.Info = "The hosts must be in UUID format." + return nil, err + } + } + sh["different_host"] = opts.DifferentHost + } + + if len(opts.SameHost) > 0 { + for _, sameHost := range opts.SameHost { + if !uuidRegex.MatchString(sameHost) { + err := gophercloud.ErrInvalidInput{} + err.Argument = "volumes.SchedulerHintOpts.SameHost" + err.Value = opts.SameHost + err.Info = "The hosts must be in UUID format." + return nil, err + } + } + sh["same_host"] = opts.SameHost + } + + if opts.LocalToInstance != "" { + if !uuidRegex.MatchString(opts.LocalToInstance) { + err := gophercloud.ErrInvalidInput{} + err.Argument = "volumes.SchedulerHintOpts.LocalToInstance" + err.Value = opts.LocalToInstance + err.Info = "The instance must be in UUID format." + return nil, err + } + sh["local_to_instance"] = opts.LocalToInstance + } + + if opts.Query != "" { + sh["query"] = opts.Query + } + + if opts.AdditionalProperties != nil { + for k, v := range opts.AdditionalProperties { + sh[k] = v + } + } + + if len(sh) == 0 { + return sh, nil + } + + return map[string]any{"OS-SCH-HNT:scheduler_hints": sh}, nil +} + +// CreateOptsBuilder allows extensions to add additional parameters to the +// Create request. +type CreateOptsBuilder interface { + ToVolumeCreateMap() (map[string]any, error) +} + +// CreateOpts contains options for creating a Volume. This object is passed to +// the volumes.Create function. For more information about these parameters, +// see the Volume object. +type CreateOpts struct { + // The size of the volume, in GB + Size int `json:"size,omitempty"` + // The availability zone + AvailabilityZone string `json:"availability_zone,omitempty"` + // ConsistencyGroupID is the ID of a consistency group + ConsistencyGroupID string `json:"consistencygroup_id,omitempty"` + // The volume description + Description string `json:"description,omitempty"` + // One or more metadata key and value pairs to associate with the volume + Metadata map[string]string `json:"metadata,omitempty"` + // The volume name + Name string `json:"name,omitempty"` + // the ID of the existing volume snapshot + SnapshotID string `json:"snapshot_id,omitempty"` + // SourceReplica is a UUID of an existing volume to replicate with + SourceReplica string `json:"source_replica,omitempty"` + // the ID of the existing volume + SourceVolID string `json:"source_volid,omitempty"` + // The ID of the image from which you want to create the volume. + // Required to create a bootable volume. + ImageID string `json:"imageRef,omitempty"` + // Specifies the backup ID, from which you want to create the volume. + // Create a volume from a backup is supported since 3.47 microversion + BackupID string `json:"backup_id,omitempty"` + // The associated volume type + VolumeType string `json:"volume_type,omitempty"` +} + +// ToVolumeCreateMap assembles a request body based on the contents of a +// CreateOpts. +func (opts CreateOpts) ToVolumeCreateMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "volume") +} + +// Create will create a new Volume based on the values in CreateOpts. To extract +// the Volume object from the response, call the Extract method on the +// CreateResult. +func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder, hintOpts SchedulerHintOptsBuilder) (r CreateResult) { + b, err := opts.ToVolumeCreateMap() + if err != nil { + r.Err = err + return + } + + if hintOpts != nil { + sh, err := hintOpts.ToSchedulerHintsMap() + if err != nil { + r.Err = err + return + } + maps.Copy(b, sh) + } + + resp, err := client.Post(ctx, createURL(client), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// DeleteOptsBuilder allows extensions to add additional parameters to the +// Delete request. +type DeleteOptsBuilder interface { + ToVolumeDeleteQuery() (string, error) +} + +// DeleteOpts contains options for deleting a Volume. This object is passed to +// the volumes.Delete function. +type DeleteOpts struct { + // Delete all snapshots of this volume as well. + Cascade bool `q:"cascade"` +} + +// ToLoadBalancerDeleteQuery formats a DeleteOpts into a query string. +func (opts DeleteOpts) ToVolumeDeleteQuery() (string, error) { + q, err := gophercloud.BuildQueryString(opts) + return q.String(), err +} + +// Delete will delete the existing Volume with the provided ID. +func Delete(ctx context.Context, client *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult) { + url := deleteURL(client, id) + if opts != nil { + query, err := opts.ToVolumeDeleteQuery() + if err != nil { + r.Err = err + return + } + url += query + } + resp, err := client.Delete(ctx, url, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Get retrieves the Volume with the provided ID. To extract the Volume object +// from the response, call the Extract method on the GetResult. +func Get(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := client.Get(ctx, getURL(client, id), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ListOptsBuilder allows extensions to add additional parameters to the List +// request. +type ListOptsBuilder interface { + ToVolumeListQuery() (string, error) +} + +// ListOpts holds options for listing Volumes. It is passed to the volumes.List +// function. +type ListOpts struct { + // AllTenants will retrieve volumes of all tenants/projects. + AllTenants bool `q:"all_tenants"` + + // Metadata will filter results based on specified metadata. + Metadata map[string]string `q:"metadata"` + + // Name will filter by the specified volume name. + Name string `q:"name"` + + // Status will filter by the specified status. + Status string `q:"status"` + + // TenantID will filter by a specific tenant/project ID. + // Setting AllTenants is required for this. + TenantID string `q:"project_id"` + + // Comma-separated list of sort keys and optional sort directions in the + // form of [:]. + Sort string `q:"sort"` + + // Requests a page size of items. + Limit int `q:"limit"` + + // Used in conjunction with limit to return a slice of items. + Offset int `q:"offset"` + + // The ID of the last-seen item. + Marker string `q:"marker"` + + // Bootable will filter results based on whether they are bootable volumes + Bootable *bool `q:"bootable,omitempty"` +} + +// ToVolumeListQuery formats a ListOpts into a query string. +func (opts ListOpts) ToVolumeListQuery() (string, error) { + q, err := gophercloud.BuildQueryString(opts) + return q.String(), err +} + +// List returns Volumes optionally limited by the conditions provided in ListOpts. +func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { + url := listURL(client) + if opts != nil { + query, err := opts.ToVolumeListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + } + + return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { + return VolumePage{pagination.LinkedPageBase{PageResult: r}} + }) +} + +// UpdateOptsBuilder allows extensions to add additional parameters to the +// Update request. +type UpdateOptsBuilder interface { + ToVolumeUpdateMap() (map[string]any, error) +} + +// UpdateOpts contain options for updating an existing Volume. This object is passed +// to the volumes.Update function. For more information about the parameters, see +// the Volume object. +type UpdateOpts struct { + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + Metadata map[string]string `json:"metadata,omitempty"` +} + +// ToVolumeUpdateMap assembles a request body based on the contents of an +// UpdateOpts. +func (opts UpdateOpts) ToVolumeUpdateMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "volume") +} + +// Update will update the Volume with provided information. To extract the updated +// Volume from the response, call the Extract method on the UpdateResult. +func Update(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { + b, err := opts.ToVolumeUpdateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Put(ctx, updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// AttachOptsBuilder allows extensions to add additional parameters to the +// Attach request. +type AttachOptsBuilder interface { + ToVolumeAttachMap() (map[string]any, error) +} + +// AttachMode describes the attachment mode for volumes. +type AttachMode string + +// These constants determine how a volume is attached. +const ( + ReadOnly AttachMode = "ro" + ReadWrite AttachMode = "rw" +) + +// AttachOpts contains options for attaching a Volume. +type AttachOpts struct { + // The mountpoint of this volume. + MountPoint string `json:"mountpoint,omitempty"` + + // The nova instance ID, can't set simultaneously with HostName. + InstanceUUID string `json:"instance_uuid,omitempty"` + + // The hostname of baremetal host, can't set simultaneously with InstanceUUID. + HostName string `json:"host_name,omitempty"` + + // Mount mode of this volume. + Mode AttachMode `json:"mode,omitempty"` +} + +// ToVolumeAttachMap assembles a request body based on the contents of a +// AttachOpts. +func (opts AttachOpts) ToVolumeAttachMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-attach") +} + +// Attach will attach a volume based on the values in AttachOpts. +func Attach(ctx context.Context, client *gophercloud.ServiceClient, id string, opts AttachOptsBuilder) (r AttachResult) { + b, err := opts.ToVolumeAttachMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// BeginDetaching will mark the volume as detaching. +func BeginDetaching(ctx context.Context, client *gophercloud.ServiceClient, id string) (r BeginDetachingResult) { + b := map[string]any{"os-begin_detaching": make(map[string]any)} + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// DetachOptsBuilder allows extensions to add additional parameters to the +// Detach request. +type DetachOptsBuilder interface { + ToVolumeDetachMap() (map[string]any, error) +} + +// DetachOpts contains options for detaching a Volume. +type DetachOpts struct { + // AttachmentID is the ID of the attachment between a volume and instance. + AttachmentID string `json:"attachment_id,omitempty"` +} + +// ToVolumeDetachMap assembles a request body based on the contents of a +// DetachOpts. +func (opts DetachOpts) ToVolumeDetachMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-detach") +} + +// Detach will detach a volume based on volume ID. +func Detach(ctx context.Context, client *gophercloud.ServiceClient, id string, opts DetachOptsBuilder) (r DetachResult) { + b, err := opts.ToVolumeDetachMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Reserve will reserve a volume based on volume ID. +func Reserve(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ReserveResult) { + b := map[string]any{"os-reserve": make(map[string]any)} + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{200, 201, 202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Unreserve will unreserve a volume based on volume ID. +func Unreserve(ctx context.Context, client *gophercloud.ServiceClient, id string) (r UnreserveResult) { + b := map[string]any{"os-unreserve": make(map[string]any)} + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{200, 201, 202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// InitializeConnectionOptsBuilder allows extensions to add additional parameters to the +// InitializeConnection request. +type InitializeConnectionOptsBuilder interface { + ToVolumeInitializeConnectionMap() (map[string]any, error) +} + +// InitializeConnectionOpts hosts options for InitializeConnection. +// The fields are specific to the storage driver in use and the destination +// attachment. +type InitializeConnectionOpts struct { + IP string `json:"ip,omitempty"` + Host string `json:"host,omitempty"` + Initiator string `json:"initiator,omitempty"` + Wwpns []string `json:"wwpns,omitempty"` + Wwnns string `json:"wwnns,omitempty"` + Multipath *bool `json:"multipath,omitempty"` + Platform string `json:"platform,omitempty"` + OSType string `json:"os_type,omitempty"` +} + +// ToVolumeInitializeConnectionMap assembles a request body based on the contents of a +// InitializeConnectionOpts. +func (opts InitializeConnectionOpts) ToVolumeInitializeConnectionMap() (map[string]any, error) { + b, err := gophercloud.BuildRequestBody(opts, "connector") + return map[string]any{"os-initialize_connection": b}, err +} + +// InitializeConnection initializes an iSCSI connection by volume ID. +func InitializeConnection(ctx context.Context, client *gophercloud.ServiceClient, id string, opts InitializeConnectionOptsBuilder) (r InitializeConnectionResult) { + b, err := opts.ToVolumeInitializeConnectionMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200, 201, 202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// TerminateConnectionOptsBuilder allows extensions to add additional parameters to the +// TerminateConnection request. +type TerminateConnectionOptsBuilder interface { + ToVolumeTerminateConnectionMap() (map[string]any, error) +} + +// TerminateConnectionOpts hosts options for TerminateConnection. +type TerminateConnectionOpts struct { + IP string `json:"ip,omitempty"` + Host string `json:"host,omitempty"` + Initiator string `json:"initiator,omitempty"` + Wwpns []string `json:"wwpns,omitempty"` + Wwnns string `json:"wwnns,omitempty"` + Multipath *bool `json:"multipath,omitempty"` + Platform string `json:"platform,omitempty"` + OSType string `json:"os_type,omitempty"` +} + +// ToVolumeTerminateConnectionMap assembles a request body based on the contents of a +// TerminateConnectionOpts. +func (opts TerminateConnectionOpts) ToVolumeTerminateConnectionMap() (map[string]any, error) { + b, err := gophercloud.BuildRequestBody(opts, "connector") + return map[string]any{"os-terminate_connection": b}, err +} + +// TerminateConnection terminates an iSCSI connection by volume ID. +func TerminateConnection(ctx context.Context, client *gophercloud.ServiceClient, id string, opts TerminateConnectionOptsBuilder) (r TerminateConnectionResult) { + b, err := opts.ToVolumeTerminateConnectionMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ExtendSizeOptsBuilder allows extensions to add additional parameters to the +// ExtendSize request. +type ExtendSizeOptsBuilder interface { + ToVolumeExtendSizeMap() (map[string]any, error) +} + +// ExtendSizeOpts contains options for extending the size of an existing Volume. +// This object is passed to the volumes.ExtendSize function. +type ExtendSizeOpts struct { + // NewSize is the new size of the volume, in GB. + NewSize int `json:"new_size" required:"true"` +} + +// ToVolumeExtendSizeMap assembles a request body based on the contents of an +// ExtendSizeOpts. +func (opts ExtendSizeOpts) ToVolumeExtendSizeMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-extend") +} + +// ExtendSize will extend the size of the volume based on the provided information. +// This operation does not return a response body. +func ExtendSize(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ExtendSizeOptsBuilder) (r ExtendSizeResult) { + b, err := opts.ToVolumeExtendSizeMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UploadImageOptsBuilder allows extensions to add additional parameters to the +// UploadImage request. +type UploadImageOptsBuilder interface { + ToVolumeUploadImageMap() (map[string]any, error) +} + +// UploadImageOpts contains options for uploading a Volume to image storage. +type UploadImageOpts struct { + // Container format, may be bare, ofv, ova, etc. + ContainerFormat string `json:"container_format,omitempty"` + + // Disk format, may be raw, qcow2, vhd, vdi, vmdk, etc. + DiskFormat string `json:"disk_format,omitempty"` + + // The name of image that will be stored in glance. + ImageName string `json:"image_name,omitempty"` + + // Force image creation, usable if volume attached to instance. + Force bool `json:"force,omitempty"` + + // Visibility defines who can see/use the image. + // supported since 3.1 microversion + Visibility string `json:"visibility,omitempty"` + + // whether the image is not deletable. + // supported since 3.1 microversion + Protected bool `json:"protected,omitempty"` +} + +// ToVolumeUploadImageMap assembles a request body based on the contents of a +// UploadImageOpts. +func (opts UploadImageOpts) ToVolumeUploadImageMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-volume_upload_image") +} + +// UploadImage will upload an image based on the values in UploadImageOptsBuilder. +func UploadImage(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UploadImageOptsBuilder) (r UploadImageResult) { + b, err := opts.ToVolumeUploadImageMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ForceDelete will delete the volume regardless of state. +func ForceDelete(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ForceDeleteResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"os-force_delete": ""}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ImageMetadataOptsBuilder allows extensions to add additional parameters to the +// ImageMetadataRequest request. +type ImageMetadataOptsBuilder interface { + ToImageMetadataMap() (map[string]any, error) +} + +// ImageMetadataOpts contains options for setting image metadata to a volume. +type ImageMetadataOpts struct { + // The image metadata to add to the volume as a set of metadata key and value pairs. + Metadata map[string]string `json:"metadata"` +} + +// ToImageMetadataMap assembles a request body based on the contents of a +// ImageMetadataOpts. +func (opts ImageMetadataOpts) ToImageMetadataMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-set_image_metadata") +} + +// SetImageMetadata will set image metadata on a volume based on the values in ImageMetadataOptsBuilder. +func SetImageMetadata(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ImageMetadataOptsBuilder) (r SetImageMetadataResult) { + b, err := opts.ToImageMetadataMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// BootableOpts contains options for setting bootable status to a volume. +type BootableOpts struct { + // Enables or disables the bootable attribute. You can boot an instance from a bootable volume. + Bootable bool `json:"bootable"` +} + +// ToBootableMap assembles a request body based on the contents of a +// BootableOpts. +func (opts BootableOpts) ToBootableMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-set_bootable") +} + +// SetBootable will set bootable status on a volume based on the values in BootableOpts +func SetBootable(ctx context.Context, client *gophercloud.ServiceClient, id string, opts BootableOpts) (r SetBootableResult) { + b, err := opts.ToBootableMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// MigrationPolicy type represents a migration_policy when changing types. +type MigrationPolicy string + +// Supported attributes for MigrationPolicy attribute for changeType operations. +const ( + MigrationPolicyNever MigrationPolicy = "never" + MigrationPolicyOnDemand MigrationPolicy = "on-demand" +) + +// ChangeTypeOptsBuilder allows extensions to add additional parameters to the +// ChangeType request. +type ChangeTypeOptsBuilder interface { + ToVolumeChangeTypeMap() (map[string]any, error) +} + +// ChangeTypeOpts contains options for changing the type of an existing Volume. +// This object is passed to the volumes.ChangeType function. +type ChangeTypeOpts struct { + // NewType is the name of the new volume type of the volume. + NewType string `json:"new_type" required:"true"` + + // MigrationPolicy specifies if the volume should be migrated when it is + // re-typed. Possible values are "on-demand" or "never". If not specified, + // the default is "never". + MigrationPolicy MigrationPolicy `json:"migration_policy,omitempty"` +} + +// ToVolumeChangeTypeMap assembles a request body based on the contents of an +// ChangeTypeOpts. +func (opts ChangeTypeOpts) ToVolumeChangeTypeMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-retype") +} + +// ChangeType will change the volume type of the volume based on the provided information. +// This operation does not return a response body. +func ChangeType(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ChangeTypeOptsBuilder) (r ChangeTypeResult) { + b, err := opts.ToVolumeChangeTypeMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ReImageOpts contains options for Re-image a volume. +type ReImageOpts struct { + // New image id + ImageID string `json:"image_id"` + // set true to re-image volumes in reserved state + ReImageReserved bool `json:"reimage_reserved"` +} + +// ToReImageMap assembles a request body based on the contents of a ReImageOpts. +func (opts ReImageOpts) ToReImageMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-reimage") +} + +// ReImage will re-image a volume based on the values in ReImageOpts +func ReImage(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ReImageOpts) (r ReImageResult) { + b, err := opts.ToReImageMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ResetStatusOptsBuilder allows extensions to add additional parameters to the +// ResetStatus request. +type ResetStatusOptsBuilder interface { + ToResetStatusMap() (map[string]any, error) +} + +// ResetStatusOpts contains options for resetting a Volume status. +// For more information about these parameters, please, refer to the Block Storage API V3, +// Volume Actions, ResetStatus volume documentation. +type ResetStatusOpts struct { + // Status is a volume status to reset to. + Status string `json:"status"` + // MigrationStatus is a volume migration status to reset to. + MigrationStatus string `json:"migration_status,omitempty"` + // AttachStatus is a volume attach status to reset to. + AttachStatus string `json:"attach_status,omitempty"` +} + +// ToResetStatusMap assembles a request body based on the contents of a +// ResetStatusOpts. +func (opts ResetStatusOpts) ToResetStatusMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-reset_status") +} + +// ResetStatus will reset the existing volume status. ResetStatusResult contains only the error. +// To extract it, call the ExtractErr method on the ResetStatusResult. +func ResetStatus(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ResetStatusOptsBuilder) (r ResetStatusResult) { + b, err := opts.ToResetStatusMap() + if err != nil { + r.Err = err + return + } + + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/results.go new file mode 100644 index 0000000000000..3f184b398efa7 --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/results.go @@ -0,0 +1,401 @@ +package volumes + +import ( + "encoding/json" + "time" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" +) + +// Attachment represents a Volume Attachment record +type Attachment struct { + AttachedAt time.Time `json:"-"` + AttachmentID string `json:"attachment_id"` + Device string `json:"device"` + HostName string `json:"host_name"` + ID string `json:"id"` + ServerID string `json:"server_id"` + VolumeID string `json:"volume_id"` +} + +// UnmarshalJSON is our unmarshalling helper +func (r *Attachment) UnmarshalJSON(b []byte) error { + type tmp Attachment + var s struct { + tmp + AttachedAt gophercloud.JSONRFC3339MilliNoZ `json:"attached_at"` + } + err := json.Unmarshal(b, &s) + if err != nil { + return err + } + *r = Attachment(s.tmp) + + r.AttachedAt = time.Time(s.AttachedAt) + + return err +} + +// Volume contains all the information associated with an OpenStack Volume. +type Volume struct { + // Unique identifier for the volume. + ID string `json:"id"` + // Current status of the volume. + Status string `json:"status"` + // Size of the volume in GB. + Size int `json:"size"` + // AvailabilityZone is which availability zone the volume is in. + AvailabilityZone string `json:"availability_zone"` + // The date when this volume was created. + CreatedAt time.Time `json:"-"` + // The date when this volume was last updated + UpdatedAt time.Time `json:"-"` + // Instances onto which the volume is attached. + Attachments []Attachment `json:"attachments"` + // Human-readable display name for the volume. + Name string `json:"name"` + // Human-readable description for the volume. + Description string `json:"description"` + // The type of volume to create, either SATA or SSD. + VolumeType string `json:"volume_type"` + // The ID of the snapshot from which the volume was created + SnapshotID string `json:"snapshot_id"` + // The ID of another block storage volume from which the current volume was created + SourceVolID string `json:"source_volid"` + // The backup ID, from which the volume was restored + // This field is supported since 3.47 microversion + BackupID *string `json:"backup_id"` + // Arbitrary key-value pairs defined by the user. + Metadata map[string]string `json:"metadata"` + // UserID is the id of the user who created the volume. + UserID string `json:"user_id"` + // Indicates whether this is a bootable volume. + Bootable string `json:"bootable"` + // Encrypted denotes if the volume is encrypted. + Encrypted bool `json:"encrypted"` + // ReplicationStatus is the status of replication. + ReplicationStatus string `json:"replication_status"` + // ConsistencyGroupID is the consistency group ID. + ConsistencyGroupID string `json:"consistencygroup_id"` + // Multiattach denotes if the volume is multi-attach capable. + Multiattach bool `json:"multiattach"` + // Image metadata entries, only included for volumes that were created from an image, or from a snapshot of a volume originally created from an image. + VolumeImageMetadata map[string]string `json:"volume_image_metadata"` + // Host is the identifier of the host holding the volume. + Host string `json:"os-vol-host-attr:host"` + // TenantID is the id of the project that owns the volume. + TenantID string `json:"os-vol-tenant-attr:tenant_id"` +} + +// UnmarshalJSON another unmarshalling function +func (r *Volume) UnmarshalJSON(b []byte) error { + type tmp Volume + var s struct { + tmp + CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"` + UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"` + } + err := json.Unmarshal(b, &s) + if err != nil { + return err + } + *r = Volume(s.tmp) + + r.CreatedAt = time.Time(s.CreatedAt) + r.UpdatedAt = time.Time(s.UpdatedAt) + + return err +} + +// VolumePage is a pagination.pager that is returned from a call to the List function. +type VolumePage struct { + pagination.LinkedPageBase +} + +// IsEmpty returns true if a ListResult contains no Volumes. +func (r VolumePage) IsEmpty() (bool, error) { + if r.StatusCode == 204 { + return true, nil + } + + volumes, err := ExtractVolumes(r) + return len(volumes) == 0, err +} + +func (page VolumePage) NextPageURL() (string, error) { + var s struct { + Links []gophercloud.Link `json:"volumes_links"` + } + err := page.ExtractInto(&s) + if err != nil { + return "", err + } + return gophercloud.ExtractNextURL(s.Links) +} + +// ExtractVolumes extracts and returns Volumes. It is used while iterating over a volumes.List call. +func ExtractVolumes(r pagination.Page) ([]Volume, error) { + var s []Volume + err := ExtractVolumesInto(r, &s) + return s, err +} + +type commonResult struct { + gophercloud.Result +} + +// Extract will get the Volume object out of the commonResult object. +func (r commonResult) Extract() (*Volume, error) { + var s Volume + err := r.ExtractInto(&s) + return &s, err +} + +// ExtractInto converts our response data into a volume struct +func (r commonResult) ExtractInto(v any) error { + return r.Result.ExtractIntoStructPtr(v, "volume") +} + +// ExtractVolumesInto similar to ExtractInto but operates on a `list` of volumes +func ExtractVolumesInto(r pagination.Page, v any) error { + return r.(VolumePage).Result.ExtractIntoSlicePtr(v, "volumes") +} + +// CreateResult contains the response body and error from a Create request. +type CreateResult struct { + commonResult +} + +// GetResult contains the response body and error from a Get request. +type GetResult struct { + commonResult +} + +// UpdateResult contains the response body and error from an Update request. +type UpdateResult struct { + commonResult +} + +// DeleteResult contains the response body and error from a Delete request. +type DeleteResult struct { + gophercloud.ErrResult +} + +// AttachResult contains the response body and error from an Attach request. +type AttachResult struct { + gophercloud.ErrResult +} + +// BeginDetachingResult contains the response body and error from a BeginDetach +// request. +type BeginDetachingResult struct { + gophercloud.ErrResult +} + +// DetachResult contains the response body and error from a Detach request. +type DetachResult struct { + gophercloud.ErrResult +} + +// UploadImageResult contains the response body and error from an UploadImage +// request. +type UploadImageResult struct { + gophercloud.Result +} + +// SetImageMetadataResult contains the response body and error from an SetImageMetadata +// request. +type SetImageMetadataResult struct { + gophercloud.ErrResult +} + +// SetBootableResult contains the response body and error from a SetBootable +// request. +type SetBootableResult struct { + gophercloud.ErrResult +} + +// ReserveResult contains the response body and error from a Reserve request. +type ReserveResult struct { + gophercloud.ErrResult +} + +// UnreserveResult contains the response body and error from an Unreserve +// request. +type UnreserveResult struct { + gophercloud.ErrResult +} + +// TerminateConnectionResult contains the response body and error from a +// TerminateConnection request. +type TerminateConnectionResult struct { + gophercloud.ErrResult +} + +// InitializeConnectionResult contains the response body and error from an +// InitializeConnection request. +type InitializeConnectionResult struct { + gophercloud.Result +} + +// ExtendSizeResult contains the response body and error from an ExtendSize request. +type ExtendSizeResult struct { + gophercloud.ErrResult +} + +// Extract will get the connection information out of the +// InitializeConnectionResult object. +// +// This will be a generic map[string]any and the results will be +// dependent on the type of connection made. +func (r InitializeConnectionResult) Extract() (map[string]any, error) { + var s struct { + ConnectionInfo map[string]any `json:"connection_info"` + } + err := r.ExtractInto(&s) + return s.ConnectionInfo, err +} + +// ImageVolumeType contains volume type information obtained from UploadImage +// action. +type ImageVolumeType struct { + // The ID of a volume type. + ID string `json:"id"` + + // Human-readable display name for the volume type. + Name string `json:"name"` + + // Human-readable description for the volume type. + Description string `json:"display_description"` + + // Flag for public access. + IsPublic bool `json:"is_public"` + + // Extra specifications for volume type. + ExtraSpecs map[string]any `json:"extra_specs"` + + // ID of quality of service specs. + QosSpecsID string `json:"qos_specs_id"` + + // Flag for deletion status of volume type. + Deleted bool `json:"deleted"` + + // The date when volume type was deleted. + DeletedAt time.Time `json:"-"` + + // The date when volume type was created. + CreatedAt time.Time `json:"-"` + + // The date when this volume was last updated. + UpdatedAt time.Time `json:"-"` +} + +func (r *ImageVolumeType) UnmarshalJSON(b []byte) error { + type tmp ImageVolumeType + var s struct { + tmp + CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"` + UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"` + DeletedAt gophercloud.JSONRFC3339MilliNoZ `json:"deleted_at"` + } + err := json.Unmarshal(b, &s) + if err != nil { + return err + } + *r = ImageVolumeType(s.tmp) + + r.CreatedAt = time.Time(s.CreatedAt) + r.UpdatedAt = time.Time(s.UpdatedAt) + r.DeletedAt = time.Time(s.DeletedAt) + + return err +} + +// VolumeImage contains information about volume uploaded to an image service. +type VolumeImage struct { + // The ID of a volume an image is created from. + VolumeID string `json:"id"` + + // Container format, may be bare, ofv, ova, etc. + ContainerFormat string `json:"container_format"` + + // Disk format, may be raw, qcow2, vhd, vdi, vmdk, etc. + DiskFormat string `json:"disk_format"` + + // Human-readable description for the volume. + Description string `json:"display_description"` + + // The ID of the created image. + ImageID string `json:"image_id"` + + // Human-readable display name for the image. + ImageName string `json:"image_name"` + + // Size of the volume in GB. + Size int `json:"size"` + + // Current status of the volume. + Status string `json:"status"` + + // Visibility defines who can see/use the image. + // supported since 3.1 microversion + Visibility string `json:"visibility"` + + // whether the image is not deletable. + // supported since 3.1 microversion + Protected bool `json:"protected"` + + // The date when this volume was last updated. + UpdatedAt time.Time `json:"-"` + + // Volume type object of used volume. + VolumeType ImageVolumeType `json:"volume_type"` +} + +func (r *VolumeImage) UnmarshalJSON(b []byte) error { + type tmp VolumeImage + var s struct { + tmp + UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"` + } + err := json.Unmarshal(b, &s) + if err != nil { + return err + } + *r = VolumeImage(s.tmp) + + r.UpdatedAt = time.Time(s.UpdatedAt) + + return err +} + +// Extract will get an object with info about the uploaded image out of the +// UploadImageResult object. +func (r UploadImageResult) Extract() (VolumeImage, error) { + var s struct { + VolumeImage VolumeImage `json:"os-volume_upload_image"` + } + err := r.ExtractInto(&s) + return s.VolumeImage, err +} + +// ForceDeleteResult contains the response body and error from a ForceDelete request. +type ForceDeleteResult struct { + gophercloud.ErrResult +} + +// ChangeTypeResult contains the response body and error from an ChangeType request. +type ChangeTypeResult struct { + gophercloud.ErrResult +} + +// ReImageResult contains the response body and error from a ReImage request. +type ReImageResult struct { + gophercloud.ErrResult +} + +// ResetStatusResult contains the response error from a ResetStatus request. +type ResetStatusResult struct { + gophercloud.ErrResult +} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/urls.go similarity index 75% rename from vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/urls.go index 170724905abe4..a73e2d2b13c80 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/urls.go @@ -1,6 +1,6 @@ package volumes -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func createURL(c *gophercloud.ServiceClient) string { return c.ServiceURL("volumes") @@ -21,3 +21,7 @@ func getURL(c *gophercloud.ServiceClient, id string) string { func updateURL(c *gophercloud.ServiceClient, id string) string { return deleteURL(c, id) } + +func actionURL(c *gophercloud.ServiceClient, id string) string { + return c.ServiceURL("volumes", id, "action") +} diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/util.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/util.go new file mode 100644 index 0000000000000..6f8d899f5681f --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes/util.go @@ -0,0 +1,23 @@ +package volumes + +import ( + "context" + + "github.com/gophercloud/gophercloud/v2" +) + +// WaitForStatus will continually poll the resource, checking for a particular status. +func WaitForStatus(ctx context.Context, c *gophercloud.ServiceClient, id, status string) error { + return gophercloud.WaitFor(ctx, func(ctx context.Context) (bool, error) { + current, err := Get(ctx, c, id).Extract() + if err != nil { + return false, err + } + + if current.Status == status { + return true, nil + } + + return false, nil + }) +} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/client.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/client.go similarity index 73% rename from vendor/github.com/gophercloud/gophercloud/openstack/client.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/client.go index 81c907c35b9ca..43b569d3b4812 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/client.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/client.go @@ -1,16 +1,17 @@ package openstack import ( + "context" "fmt" "reflect" "strings" - "github.com/gophercloud/gophercloud" - tokens2 "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens" - "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens" - "github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1" - tokens3 "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" - "github.com/gophercloud/gophercloud/openstack/utils" + "github.com/gophercloud/gophercloud/v2" + tokens2 "github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens" + "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens" + "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1" + tokens3 "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens" + "github.com/gophercloud/gophercloud/v2/openstack/utils" ) const ( @@ -23,20 +24,18 @@ const ( v3 = "v3" ) -/* -NewClient prepares an unauthenticated ProviderClient instance. -Most users will probably prefer using the AuthenticatedClient function -instead. - -This is useful if you wish to explicitly control the version of the identity -service that's used for authentication explicitly, for example. - -A basic example of using this would be: - - ao, err := openstack.AuthOptionsFromEnv() - provider, err := openstack.NewClient(ao.IdentityEndpoint) - client, err := openstack.NewIdentityV3(provider, gophercloud.EndpointOpts{}) -*/ +// NewClient prepares an unauthenticated ProviderClient instance. +// Most users will probably prefer using the AuthenticatedClient function +// instead. +// +// This is useful if you wish to explicitly control the version of the identity +// service that's used for authentication explicitly, for example. +// +// A basic example of using this would be: +// +// ao, err := openstack.AuthOptionsFromEnv() +// provider, err := openstack.NewClient(ao.IdentityEndpoint) +// client, err := openstack.NewIdentityV3(provider, gophercloud.EndpointOpts{}) func NewClient(endpoint string) (*gophercloud.ProviderClient, error) { base, err := utils.BaseEndpoint(endpoint) if err != nil { @@ -54,57 +53,55 @@ func NewClient(endpoint string) (*gophercloud.ProviderClient, error) { return p, nil } -/* -AuthenticatedClient logs in to an OpenStack cloud found at the identity endpoint -specified by the options, acquires a token, and returns a Provider Client -instance that's ready to operate. - -If the full path to a versioned identity endpoint was specified (example: -http://example.com:5000/v3), that path will be used as the endpoint to query. - -If a versionless endpoint was specified (example: http://example.com:5000/), -the endpoint will be queried to determine which versions of the identity service -are available, then chooses the most recent or most supported version. - -Example: - - ao, err := openstack.AuthOptionsFromEnv() - provider, err := openstack.AuthenticatedClient(ao) - client, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{ - Region: os.Getenv("OS_REGION_NAME"), - }) -*/ -func AuthenticatedClient(options gophercloud.AuthOptions) (*gophercloud.ProviderClient, error) { +// AuthenticatedClient logs in to an OpenStack cloud found at the identity endpoint +// specified by the options, acquires a token, and returns a Provider Client +// instance that's ready to operate. +// +// If the full path to a versioned identity endpoint was specified (example: +// http://example.com:5000/v3), that path will be used as the endpoint to query. +// +// If a versionless endpoint was specified (example: http://example.com:5000/), +// the endpoint will be queried to determine which versions of the identity service +// are available, then chooses the most recent or most supported version. +// +// Example: +// +// ao, err := openstack.AuthOptionsFromEnv() +// provider, err := openstack.AuthenticatedClient(ctx, ao) +// client, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{ +// Region: os.Getenv("OS_REGION_NAME"), +// }) +func AuthenticatedClient(ctx context.Context, options gophercloud.AuthOptions) (*gophercloud.ProviderClient, error) { client, err := NewClient(options.IdentityEndpoint) if err != nil { return nil, err } - err = Authenticate(client, options) + err = Authenticate(ctx, client, options) if err != nil { return nil, err } return client, nil } -// Authenticate or re-authenticate against the most recent identity service -// supported at the provided endpoint. -func Authenticate(client *gophercloud.ProviderClient, options gophercloud.AuthOptions) error { +// Authenticate authenticates or re-authenticates against the most +// recent identity service supported at the provided endpoint. +func Authenticate(ctx context.Context, client *gophercloud.ProviderClient, options gophercloud.AuthOptions) error { versions := []*utils.Version{ {ID: v2, Priority: 20, Suffix: "/v2.0/"}, {ID: v3, Priority: 30, Suffix: "/v3/"}, } - chosen, endpoint, err := utils.ChooseVersion(client, versions) + chosen, endpoint, err := utils.ChooseVersion(ctx, client, versions) if err != nil { return err } switch chosen.ID { case v2: - return v2auth(client, endpoint, options, gophercloud.EndpointOpts{}) + return v2auth(ctx, client, endpoint, &options, gophercloud.EndpointOpts{}) case v3: - return v3auth(client, endpoint, &options, gophercloud.EndpointOpts{}) + return v3auth(ctx, client, endpoint, &options, gophercloud.EndpointOpts{}) default: // The switch statement must be out of date from the versions list. return fmt.Errorf("Unrecognized identity version: %s", chosen.ID) @@ -112,11 +109,17 @@ func Authenticate(client *gophercloud.ProviderClient, options gophercloud.AuthOp } // AuthenticateV2 explicitly authenticates against the identity v2 endpoint. -func AuthenticateV2(client *gophercloud.ProviderClient, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error { - return v2auth(client, "", options, eo) +func AuthenticateV2(ctx context.Context, client *gophercloud.ProviderClient, options tokens2.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error { + return v2auth(ctx, client, "", options, eo) } -func v2auth(client *gophercloud.ProviderClient, endpoint string, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error { +type v2TokenNoReauth struct { + tokens2.AuthOptionsBuilder +} + +func (v2TokenNoReauth) CanReauth() bool { return false } + +func v2auth(ctx context.Context, client *gophercloud.ProviderClient, endpoint string, options tokens2.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error { v2Client, err := NewIdentityV2(client, eo) if err != nil { return err @@ -126,17 +129,7 @@ func v2auth(client *gophercloud.ProviderClient, endpoint string, options gopherc v2Client.Endpoint = endpoint } - v2Opts := tokens2.AuthOptions{ - IdentityEndpoint: options.IdentityEndpoint, - Username: options.Username, - Password: options.Password, - TenantID: options.TenantID, - TenantName: options.TenantName, - AllowReauth: options.AllowReauth, - TokenID: options.TokenID, - } - - result := tokens2.Create(v2Client, v2Opts) + result := tokens2.Create(ctx, v2Client, options) err = client.SetTokenAndAuthResult(result) if err != nil { @@ -148,18 +141,19 @@ func v2auth(client *gophercloud.ProviderClient, endpoint string, options gopherc return err } - if options.AllowReauth { + if options.CanReauth() { // here we're creating a throw-away client (tac). it's a copy of the user's provider client, but // with the token and reauth func zeroed out. combined with setting `AllowReauth` to `false`, // this should retry authentication only once tac := *client tac.SetThrowaway(true) tac.ReauthFunc = nil - tac.SetTokenAndAuthResult(nil) - tao := options - tao.AllowReauth = false - client.ReauthFunc = func() error { - err := v2auth(&tac, endpoint, tao, eo) + err := tac.SetTokenAndAuthResult(nil) + if err != nil { + return err + } + client.ReauthFunc = func(ctx context.Context) error { + err := v2auth(ctx, &tac, endpoint, &v2TokenNoReauth{options}, eo) if err != nil { return err } @@ -175,11 +169,11 @@ func v2auth(client *gophercloud.ProviderClient, endpoint string, options gopherc } // AuthenticateV3 explicitly authenticates against the identity v3 service. -func AuthenticateV3(client *gophercloud.ProviderClient, options tokens3.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error { - return v3auth(client, "", options, eo) +func AuthenticateV3(ctx context.Context, client *gophercloud.ProviderClient, options tokens3.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error { + return v3auth(ctx, client, "", options, eo) } -func v3auth(client *gophercloud.ProviderClient, endpoint string, opts tokens3.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error { +func v3auth(ctx context.Context, client *gophercloud.ProviderClient, endpoint string, opts tokens3.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error { // Override the generated service endpoint with the one returned by the version endpoint. v3Client, err := NewIdentityV3(client, eo) if err != nil { @@ -211,7 +205,7 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, opts tokens3.Au } v3Client.SetToken(tokenID) - result := tokens3.Get(v3Client, tokenID) + result := tokens3.Get(ctx, v3Client, tokenID) if result.Err != nil { return result.Err } @@ -229,11 +223,11 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, opts tokens3.Au var result tokens3.CreateResult switch opts.(type) { case *ec2tokens.AuthOptions: - result = ec2tokens.Create(v3Client, opts) + result = ec2tokens.Create(ctx, v3Client, opts) case *oauth1.AuthOptions: - result = oauth1.Create(v3Client, opts) + result = oauth1.Create(ctx, v3Client, opts) default: - result = tokens3.Create(v3Client, opts) + result = tokens3.Create(ctx, v3Client, opts) } err = client.SetTokenAndAuthResult(result) @@ -254,7 +248,10 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, opts tokens3.Au tac := *client tac.SetThrowaway(true) tac.ReauthFunc = nil - tac.SetTokenAndAuthResult(nil) + err = tac.SetTokenAndAuthResult(nil) + if err != nil { + return err + } var tao tokens3.AuthOptionsBuilder switch ot := opts.(type) { case *gophercloud.AuthOptions: @@ -276,8 +273,8 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, opts tokens3.Au default: tao = opts } - client.ReauthFunc = func() error { - err := v3auth(&tac, endpoint, tao, eo) + client.ReauthFunc = func(ctx context.Context) error { + err := v3auth(ctx, &tac, endpoint, tao, eo) if err != nil { return err } @@ -363,7 +360,11 @@ func initClientOpts(client *gophercloud.ProviderClient, eo gophercloud.EndpointO // NewBareMetalV1 creates a ServiceClient that may be used with the v1 // bare metal package. func NewBareMetalV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) { - return initClientOpts(client, eo, "baremetal") + sc, err := initClientOpts(client, eo, "baremetal") + if !strings.HasSuffix(strings.TrimSuffix(sc.Endpoint, "/"), "v1") { + sc.ResourceBase = sc.Endpoint + "v1/" + } + return sc, err } // NewBareMetalIntrospectionV1 creates a ServiceClient that may be used with the v1 @@ -414,12 +415,6 @@ func NewSharedFileSystemV2(client *gophercloud.ProviderClient, eo gophercloud.En return initClientOpts(client, eo, "sharev2") } -// NewCDNV1 creates a ServiceClient that may be used to access the OpenStack v1 -// CDN service. -func NewCDNV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) { - return initClientOpts(client, eo, "cdn") -} - // NewOrchestrationV1 creates a ServiceClient that may be used to access the v1 // orchestration service. func NewOrchestrationV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) { @@ -439,9 +434,9 @@ func NewDNSV2(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) ( return sc, err } -// 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) { +// NewImageV2 creates a ServiceClient that may be used to access the v2 image +// service. +func NewImageV2(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) { sc, err := initClientOpts(client, eo, "image") sc.ResourceBase = sc.Endpoint + "v2/" return sc, err @@ -459,12 +454,6 @@ func NewLoadBalancerV2(client *gophercloud.ProviderClient, eo gophercloud.Endpoi return sc, err } -// NewClusteringV1 creates a ServiceClient that may be used with the v1 clustering -// package. -func NewClusteringV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) { - return initClientOpts(client, eo, "clustering") -} - // NewMessagingV2 creates a ServiceClient that may be used with the v2 messaging // service. func NewMessagingV2(client *gophercloud.ProviderClient, clientID string, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/doc.go similarity index 77% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/doc.go index 3653122bf30f9..3b1ad9fb5567d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/doc.go @@ -5,7 +5,7 @@ interfaces through Nova. Example of Listing a Server's Interfaces serverID := "b07e7a3b-d951-4efc-a4f9-ac9f001afb7f" - allPages, err := attachinterfaces.List(computeClient, serverID).AllPages() + allPages, err := attachinterfaces.List(computeClient, serverID).AllPages(context.TODO()) if err != nil { panic(err) } @@ -23,7 +23,7 @@ Example to Get a Server's Interface portID = "0dde1598-b374-474e-986f-5b8dd1df1d4e" serverID := "b07e7a3b-d951-4efc-a4f9-ac9f001afb7f" - interface, err := attachinterfaces.Get(computeClient, serverID, portID).Extract() + interface, err := attachinterfaces.Get(context.TODO(), computeClient, serverID, portID).Extract() if err != nil { panic(err) } @@ -35,7 +35,7 @@ Example to Create a new Interface attachment on the Server attachOpts := attachinterfaces.CreateOpts{ NetworkID: networkID, } - interface, err := attachinterfaces.Create(computeClient, serverID, attachOpts).Extract() + interface, err := attachinterfaces.Create(context.TODO(), computeClient, serverID, attachOpts).Extract() if err != nil { panic(err) } @@ -44,7 +44,7 @@ Example to Delete an Interface attachment from the Server portID = "0dde1598-b374-474e-986f-5b8dd1df1d4e" serverID := "b07e7a3b-d951-4efc-a4f9-ac9f001afb7f" - err := attachinterfaces.Delete(computeClient, serverID, portID).ExtractErr() + err := attachinterfaces.Delete(context.TODO(), computeClient, serverID, portID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/requests.go similarity index 74% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/requests.go index 9748ce4ac163e..9be0ac68cb6e5 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/requests.go @@ -1,8 +1,10 @@ package attachinterfaces import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // List makes a request against the nova API to list the server's interfaces. @@ -13,8 +15,8 @@ func List(client *gophercloud.ServiceClient, serverID string) pagination.Pager { } // Get requests details on a single interface attachment by the server and port IDs. -func Get(client *gophercloud.ServiceClient, serverID, portID string) (r GetResult) { - resp, err := client.Get(getInterfaceURL(client, serverID, portID), &r.Body, &gophercloud.RequestOpts{ +func Get(ctx context.Context, client *gophercloud.ServiceClient, serverID, portID string) (r GetResult) { + resp, err := client.Get(ctx, getInterfaceURL(client, serverID, portID), &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -24,7 +26,7 @@ func Get(client *gophercloud.ServiceClient, serverID, portID string) (r GetResul // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToAttachInterfacesCreateMap() (map[string]interface{}, error) + ToAttachInterfacesCreateMap() (map[string]any, error) } // CreateOpts specifies parameters of a new interface attachment. @@ -48,18 +50,18 @@ type CreateOpts struct { } // ToAttachInterfacesCreateMap constructs a request body from CreateOpts. -func (opts CreateOpts) ToAttachInterfacesCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToAttachInterfacesCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "interfaceAttachment") } // Create requests the creation of a new interface attachment on the server. -func Create(client *gophercloud.ServiceClient, serverID string, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, serverID string, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToAttachInterfacesCreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(createInterfaceURL(client, serverID), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, createInterfaceURL(client, serverID), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -68,8 +70,8 @@ func Create(client *gophercloud.ServiceClient, serverID string, opts CreateOptsB // Delete makes a request against the nova API to detach a single interface from the server. // It needs server and port IDs to make a such request. -func Delete(client *gophercloud.ServiceClient, serverID, portID string) (r DeleteResult) { - resp, err := client.Delete(deleteInterfaceURL(client, serverID, portID), nil) +func Delete(ctx context.Context, client *gophercloud.ServiceClient, serverID, portID string) (r DeleteResult) { + resp, err := client.Delete(ctx, deleteInterfaceURL(client, serverID, portID), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/results.go similarity index 96% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/results.go index e713c34e9be52..6895be69d1454 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/results.go @@ -1,8 +1,8 @@ package attachinterfaces import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type attachInterfaceResult struct { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/urls.go similarity index 93% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/urls.go index 50292e8b5a551..98f8271d2a890 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces/urls.go @@ -1,6 +1,6 @@ package attachinterfaces -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func listInterfaceURL(client *gophercloud.ServiceClient, serverID string) string { return client.ServiceURL("servers", serverID, "os-interface") diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/doc.go similarity index 63% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/doc.go index 13b6d9d424789..59278fda3286b 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/doc.go @@ -3,32 +3,9 @@ Package availabilityzones provides the ability to get lists and detailed availability zone information and to extend a server result with availability zone information. -Example of Extend server result with Availability Zone Information: - - type ServerWithAZ struct { - servers.Server - availabilityzones.ServerAvailabilityZoneExt - } - - var allServers []ServerWithAZ - - allPages, err := servers.List(client, nil).AllPages() - if err != nil { - panic("Unable to retrieve servers: %s", err) - } - - err = servers.ExtractServersInto(allPages, &allServers) - if err != nil { - panic("Unable to extract servers: %s", err) - } - - for _, server := range allServers { - fmt.Println(server.AvailabilityZone) - } - Example of Get Availability Zone Information - allPages, err := availabilityzones.List(computeClient).AllPages() + allPages, err := availabilityzones.List(computeClient).AllPages(context.TODO()) if err != nil { panic(err) } @@ -44,7 +21,7 @@ Example of Get Availability Zone Information Example of Get Detailed Availability Zone Information - allPages, err := availabilityzones.ListDetail(computeClient).AllPages() + allPages, err := availabilityzones.ListDetail(computeClient).AllPages(context.TODO()) if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/requests.go similarity index 87% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/requests.go index f9a2e86e03d42..319e61978a4da 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/requests.go @@ -1,8 +1,8 @@ package availabilityzones import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // List will return the existing availability zones. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/results.go similarity index 84% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/results.go index d48a0ea85836a..3c95a8a24be78 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/results.go @@ -4,16 +4,10 @@ import ( "encoding/json" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) -// ServerAvailabilityZoneExt is an extension to the base Server object. -type ServerAvailabilityZoneExt struct { - // AvailabilityZone is the availabilty zone the server is in. - AvailabilityZone string `json:"OS-EXT-AZ:availability_zone"` -} - // ServiceState represents the state of a service in an AvailabilityZone. type ServiceState struct { Active bool `json:"active"` diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/urls.go similarity index 83% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/urls.go index 9d99ec74b76d3..88c748275de34 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones/urls.go @@ -1,6 +1,6 @@ package availabilityzones -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func listURL(c *gophercloud.ServiceClient) string { return c.ServiceURL("os-availability-zone") diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/doc.go similarity index 75% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/doc.go index 747966d8d9949..28a5870c239b9 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/doc.go @@ -12,7 +12,7 @@ Example to List Flavors AccessType: flavors.PublicAccess, } - allPages, err := flavors.ListDetail(computeClient, listOpts).AllPages() + allPages, err := flavors.ListDetail(computeClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -37,7 +37,7 @@ Example to Create a Flavor RxTxFactor: 1.0, } - flavor, err := flavors.Create(computeClient, createOpts).Extract() + flavor, err := flavors.Create(context.TODO(), computeClient, createOpts).Extract() if err != nil { panic(err) } @@ -50,7 +50,7 @@ Example to Update a Flavor Description: "This is a good description" } - flavor, err := flavors.Update(computeClient, flavorID, updateOpts).Extract() + flavor, err := flavors.Update(context.TODO(), computeClient, flavorID, updateOpts).Extract() if err != nil { panic(err) } @@ -59,7 +59,7 @@ Example to List Flavor Access flavorID := "e91758d6-a54a-4778-ad72-0c73a1cb695b" - allPages, err := flavors.ListAccesses(computeClient, flavorID).AllPages() + allPages, err := flavors.ListAccesses(computeClient, flavorID).AllPages(context.TODO()) if err != nil { panic(err) } @@ -81,7 +81,7 @@ Example to Grant Access to a Flavor Tenant: "15153a0979884b59b0592248ef947921", } - accessList, err := flavors.AddAccess(computeClient, flavor.ID, accessOpts).Extract() + accessList, err := flavors.AddAccess(context.TODO(), computeClient, flavor.ID, accessOpts).Extract() if err != nil { panic(err) } @@ -94,7 +94,7 @@ Example to Remove/Revoke Access to a Flavor Tenant: "15153a0979884b59b0592248ef947921", } - accessList, err := flavors.RemoveAccess(computeClient, flavor.ID, accessOpts).Extract() + accessList, err := flavors.RemoveAccess(context.TODO(), computeClient, flavor.ID, accessOpts).Extract() if err != nil { panic(err) } @@ -107,7 +107,7 @@ Example to Create Extra Specs for a Flavor "hw:cpu_policy": "CPU-POLICY", "hw:cpu_thread_policy": "CPU-THREAD-POLICY", } - createdExtraSpecs, err := flavors.CreateExtraSpecs(computeClient, flavorID, createOpts).Extract() + createdExtraSpecs, err := flavors.CreateExtraSpecs(context.TODO(), computeClient, flavorID, createOpts).Extract() if err != nil { panic(err) } @@ -118,7 +118,7 @@ Example to Get Extra Specs for a Flavor flavorID := "e91758d6-a54a-4778-ad72-0c73a1cb695b" - extraSpecs, err := flavors.ListExtraSpecs(computeClient, flavorID).Extract() + extraSpecs, err := flavors.ListExtraSpecs(context.TODO(), computeClient, flavorID).Extract() if err != nil { panic(err) } @@ -132,7 +132,7 @@ Example to Update Extra Specs for a Flavor updateOpts := flavors.ExtraSpecsOpts{ "hw:cpu_thread_policy": "CPU-THREAD-POLICY-UPDATED", } - updatedExtraSpec, err := flavors.UpdateExtraSpec(computeClient, flavorID, updateOpts).Extract() + updatedExtraSpec, err := flavors.UpdateExtraSpec(context.TODO(), computeClient, flavorID, updateOpts).Extract() if err != nil { panic(err) } @@ -142,7 +142,7 @@ Example to Update Extra Specs for a Flavor 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() + err := flavors.DeleteExtraSpec(context.TODO(), computeClient, flavorID, "hw:cpu_thread_policy").ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/requests.go similarity index 75% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/requests.go index 3887cdfdca869..119f5e78e8a90 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/requests.go @@ -1,8 +1,10 @@ package flavors import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -97,7 +99,7 @@ func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) paginat } type CreateOptsBuilder interface { - ToFlavorCreateMap() (map[string]interface{}, error) + ToFlavorCreateMap() (map[string]any, error) } // CreateOpts specifies parameters used for creating a flavor. @@ -136,18 +138,18 @@ type CreateOpts struct { } // ToFlavorCreateMap constructs a request body from CreateOpts. -func (opts CreateOpts) ToFlavorCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToFlavorCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "flavor") } // Create requests the creation of a new flavor. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToFlavorCreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, createURL(client), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 201}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -155,7 +157,7 @@ func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r Create } type UpdateOptsBuilder interface { - ToFlavorUpdateMap() (map[string]interface{}, error) + ToFlavorUpdateMap() (map[string]any, error) } // UpdateOpts specifies parameters used for updating a flavor. @@ -167,18 +169,18 @@ type UpdateOpts struct { } // ToFlavorUpdateMap constructs a request body from UpdateOpts. -func (opts UpdateOpts) ToFlavorUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToFlavorUpdateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "flavor") } // Update requests the update of a new flavor. -func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToFlavorUpdateMap() if err != nil { r.Err = err return } - resp, err := client.Put(updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Put(ctx, updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -187,15 +189,15 @@ func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder // Get retrieves details of a single flavor. Use Extract to convert its // result into a Flavor. -func Get(client *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := client.Get(getURL(client, id), &r.Body, nil) +func Get(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := client.Get(ctx, getURL(client, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Delete deletes the specified flavor ID. -func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := client.Delete(deleteURL(client, id), nil) +func Delete(ctx context.Context, client *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := client.Delete(ctx, deleteURL(client, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -212,7 +214,7 @@ func ListAccesses(client *gophercloud.ServiceClient, id string) pagination.Pager // AddAccessOptsBuilder allows extensions to add additional parameters to the // AddAccess requests. type AddAccessOptsBuilder interface { - ToFlavorAddAccessMap() (map[string]interface{}, error) + ToFlavorAddAccessMap() (map[string]any, error) } // AddAccessOpts represents options for adding access to a flavor. @@ -222,18 +224,18 @@ type AddAccessOpts struct { } // ToFlavorAddAccessMap constructs a request body from AddAccessOpts. -func (opts AddAccessOpts) ToFlavorAddAccessMap() (map[string]interface{}, error) { +func (opts AddAccessOpts) ToFlavorAddAccessMap() (map[string]any, 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) { +func AddAccess(ctx context.Context, client *gophercloud.ServiceClient, id string, opts AddAccessOptsBuilder) (r AddAccessResult) { b, err := opts.ToFlavorAddAccessMap() if err != nil { r.Err = err return } - resp, err := client.Post(accessActionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, accessActionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -243,7 +245,7 @@ func AddAccess(client *gophercloud.ServiceClient, id string, opts AddAccessOptsB // RemoveAccessOptsBuilder allows extensions to add additional parameters to the // RemoveAccess requests. type RemoveAccessOptsBuilder interface { - ToFlavorRemoveAccessMap() (map[string]interface{}, error) + ToFlavorRemoveAccessMap() (map[string]any, error) } // RemoveAccessOpts represents options for removing access to a flavor. @@ -253,18 +255,18 @@ type RemoveAccessOpts struct { } // ToFlavorRemoveAccessMap constructs a request body from RemoveAccessOpts. -func (opts RemoveAccessOpts) ToFlavorRemoveAccessMap() (map[string]interface{}, error) { +func (opts RemoveAccessOpts) ToFlavorRemoveAccessMap() (map[string]any, 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) { +func RemoveAccess(ctx context.Context, client *gophercloud.ServiceClient, id string, opts RemoveAccessOptsBuilder) (r RemoveAccessResult) { b, err := opts.ToFlavorRemoveAccessMap() if err != nil { r.Err = err return } - resp, err := client.Post(accessActionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, accessActionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -272,14 +274,14 @@ func RemoveAccess(client *gophercloud.ServiceClient, id string, opts RemoveAcces } // ExtraSpecs requests all the extra-specs for the given flavor ID. -func ListExtraSpecs(client *gophercloud.ServiceClient, flavorID string) (r ListExtraSpecsResult) { - resp, err := client.Get(extraSpecsListURL(client, flavorID), &r.Body, nil) +func ListExtraSpecs(ctx context.Context, client *gophercloud.ServiceClient, flavorID string) (r ListExtraSpecsResult) { + resp, err := client.Get(ctx, extraSpecsListURL(client, flavorID), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } -func GetExtraSpec(client *gophercloud.ServiceClient, flavorID string, key string) (r GetExtraSpecResult) { - resp, err := client.Get(extraSpecsGetURL(client, flavorID, key), &r.Body, nil) +func GetExtraSpec(ctx context.Context, client *gophercloud.ServiceClient, flavorID string, key string) (r GetExtraSpecResult) { + resp, err := client.Get(ctx, extraSpecsGetURL(client, flavorID, key), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -287,7 +289,7 @@ func GetExtraSpec(client *gophercloud.ServiceClient, flavorID string, key string // CreateExtraSpecsOptsBuilder allows extensions to add additional parameters to the // CreateExtraSpecs requests. type CreateExtraSpecsOptsBuilder interface { - ToFlavorExtraSpecsCreateMap() (map[string]interface{}, error) + ToFlavorExtraSpecsCreateMap() (map[string]any, error) } // ExtraSpecsOpts is a map that contains key-value pairs. @@ -295,19 +297,19 @@ type ExtraSpecsOpts map[string]string // ToFlavorExtraSpecsCreateMap assembles a body for a Create request based on // the contents of ExtraSpecsOpts. -func (opts ExtraSpecsOpts) ToFlavorExtraSpecsCreateMap() (map[string]interface{}, error) { - return map[string]interface{}{"extra_specs": opts}, nil +func (opts ExtraSpecsOpts) ToFlavorExtraSpecsCreateMap() (map[string]any, error) { + return map[string]any{"extra_specs": opts}, nil } // CreateExtraSpecs will create or update the extra-specs key-value pairs for // the specified Flavor. -func CreateExtraSpecs(client *gophercloud.ServiceClient, flavorID string, opts CreateExtraSpecsOptsBuilder) (r CreateExtraSpecsResult) { +func CreateExtraSpecs(ctx context.Context, client *gophercloud.ServiceClient, flavorID string, opts CreateExtraSpecsOptsBuilder) (r CreateExtraSpecsResult) { b, err := opts.ToFlavorExtraSpecsCreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(extraSpecsCreateURL(client, flavorID), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, extraSpecsCreateURL(client, flavorID), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -340,13 +342,13 @@ func (opts ExtraSpecsOpts) ToFlavorExtraSpecUpdateMap() (map[string]string, stri // 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) { +func UpdateExtraSpec(ctx context.Context, client *gophercloud.ServiceClient, flavorID string, opts UpdateExtraSpecOptsBuilder) (r UpdateExtraSpecResult) { b, key, err := opts.ToFlavorExtraSpecUpdateMap() if err != nil { r.Err = err return } - resp, err := client.Put(extraSpecUpdateURL(client, flavorID, key), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Put(ctx, extraSpecUpdateURL(client, flavorID, key), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -355,8 +357,8 @@ func UpdateExtraSpec(client *gophercloud.ServiceClient, flavorID string, opts Up // 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) { - resp, err := client.Delete(extraSpecDeleteURL(client, flavorID, key), &gophercloud.RequestOpts{ +func DeleteExtraSpec(ctx context.Context, client *gophercloud.ServiceClient, flavorID, key string) (r DeleteExtraSpecResult) { + resp, err := client.Delete(ctx, extraSpecDeleteURL(client, flavorID, key), &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/results.go similarity index 94% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/results.go index 4da14118a3563..387268af855f9 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/results.go @@ -4,8 +4,8 @@ import ( "encoding/json" "strconv" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type commonResult struct { @@ -80,13 +80,19 @@ type Flavor struct { // 65535 characters in length. Only printable characters are allowed. // New in version 2.55 Description string `json:"description"` + + // Properties is a dictionary of the flavor’s extra-specs key-and-value + // pairs. This will only be included if the user is allowed by policy to + // index flavor extra_specs + // New in version 2.61 + ExtraSpecs map[string]string `json:"extra_specs"` } func (r *Flavor) UnmarshalJSON(b []byte) error { type tmp Flavor var s struct { tmp - Swap interface{} `json:"swap"` + Swap any `json:"swap"` } err := json.Unmarshal(b, &s) if err != nil { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/urls.go similarity index 97% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/urls.go index 65bbb654012d8..27ca0571f1dc1 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors/urls.go @@ -1,7 +1,7 @@ package flavors import ( - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) func getURL(client *gophercloud.ServiceClient, id string) string { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/doc.go similarity index 75% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/doc.go index 9fa914ec71d12..0e52dfc9a3b04 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/doc.go @@ -4,7 +4,7 @@ servers with a specified key pair. Example to List Key Pairs - allPages, err := keypairs.List(computeClient, nil).AllPages() + allPages, err := keypairs.List(computeClient, nil).AllPages(context.TODO()) if err != nil { panic(err) } @@ -26,7 +26,7 @@ Example to List Key Pairs using microversion 2.10 or greater UserID: "user-id", } - allPages, err := keypairs.List(computeClient, listOpts).AllPages() + allPages, err := keypairs.List(computeClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -46,7 +46,7 @@ Example to Create a Key Pair Name: "keypair-name", } - keypair, err := keypairs.Create(computeClient, createOpts).Extract() + keypair, err := keypairs.Create(context.TODO(), computeClient, createOpts).Extract() if err != nil { panic(err) } @@ -60,14 +60,14 @@ Example to Import a Key Pair PublicKey: "public-key", } - keypair, err := keypairs.Create(computeClient, createOpts).Extract() + keypair, err := keypairs.Create(context.TODO(), computeClient, createOpts).Extract() if err != nil { panic(err) } Example to Delete a Key Pair - err := keypairs.Delete(computeClient, "keypair-name", nil).ExtractErr() + err := keypairs.Delete(context.TODO(), computeClient, "keypair-name", nil).ExtractErr() if err != nil { panic(err) } @@ -80,7 +80,7 @@ Example to Delete a Key Pair owned by a certain user using microversion 2.10 or UserID: "user-id", } - err := keypairs.Delete(client, "keypair-name", deleteOpts).ExtractErr() + err := keypairs.Delete(context.TODO(), client, "keypair-name", deleteOpts).ExtractErr() if err != nil { panic(err) } @@ -98,7 +98,7 @@ Example to Create a Server With a Key Pair KeyName: "keypair-name", } - server, err := servers.Create(computeClient, createOpts).Extract() + server, err := servers.Create(context.TODO(), computeClient, createOpts).Extract() if err != nil { panic(err) } @@ -111,7 +111,7 @@ Example to Get a Key Pair owned by a certain user using microversion 2.10 or gre UserID: "user-id", } - keypair, err := keypairs.Get(computeClient, "keypair-name", getOpts).Extract() + keypair, err := keypairs.Get(context.TODO(), computeClient, "keypair-name", getOpts).Extract() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/requests.go similarity index 83% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/requests.go index aba11fb4351ea..bc4cc270f1745 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/requests.go @@ -1,9 +1,11 @@ package keypairs import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/gophercloud/v2/pagination" ) // CreateOptsExt adds a KeyPair option to the base CreateOpts. @@ -15,7 +17,7 @@ type CreateOptsExt struct { } // ToServerCreateMap adds the key_name to the base server creation options. -func (opts CreateOptsExt) ToServerCreateMap() (map[string]interface{}, error) { +func (opts CreateOptsExt) ToServerCreateMap() (map[string]any, error) { base, err := opts.CreateOptsBuilder.ToServerCreateMap() if err != nil { return nil, err @@ -25,7 +27,7 @@ func (opts CreateOptsExt) ToServerCreateMap() (map[string]interface{}, error) { return base, nil } - serverMap := base["server"].(map[string]interface{}) + serverMap := base["server"].(map[string]any) serverMap["key_name"] = opts.KeyName return base, nil @@ -68,7 +70,7 @@ func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pa // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToKeyPairCreateMap() (map[string]interface{}, error) + ToKeyPairCreateMap() (map[string]any, error) } // CreateOpts specifies KeyPair creation or import parameters. @@ -91,19 +93,19 @@ type CreateOpts struct { } // ToKeyPairCreateMap constructs a request body from CreateOpts. -func (opts CreateOpts) ToKeyPairCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToKeyPairCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "keypair") } // Create requests the creation of a new KeyPair on the server, or to import a // pre-existing keypair. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToKeyPairCreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, createURL(client), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 201}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -130,7 +132,7 @@ func (opts GetOpts) ToKeyPairGetQuery() (string, error) { } // Get returns public data about a previously uploaded KeyPair. -func Get(client *gophercloud.ServiceClient, name string, opts GetOptsBuilder) (r GetResult) { +func Get(ctx context.Context, client *gophercloud.ServiceClient, name string, opts GetOptsBuilder) (r GetResult) { url := getURL(client, name) if opts != nil { query, err := opts.ToKeyPairGetQuery() @@ -141,7 +143,7 @@ func Get(client *gophercloud.ServiceClient, name string, opts GetOptsBuilder) (r url += query } - resp, err := client.Get(url, &r.Body, nil) + resp, err := client.Get(ctx, url, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -166,7 +168,7 @@ func (opts DeleteOpts) ToKeyPairDeleteQuery() (string, error) { } // Delete requests the deletion of a previous stored KeyPair from the server. -func Delete(client *gophercloud.ServiceClient, name string, opts DeleteOptsBuilder) (r DeleteResult) { +func Delete(ctx context.Context, client *gophercloud.ServiceClient, name string, opts DeleteOptsBuilder) (r DeleteResult) { url := deleteURL(client, name) if opts != nil { query, err := opts.ToKeyPairDeleteQuery() @@ -177,7 +179,7 @@ func Delete(client *gophercloud.ServiceClient, name string, opts DeleteOptsBuild url += query } - resp, err := client.Delete(url, nil) + resp, err := client.Delete(ctx, url, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/results.go similarity index 96% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/results.go index 0ac05c361d3be..0c91fee69325e 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/results.go @@ -1,8 +1,8 @@ package keypairs import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // KeyPair is an SSH key known to the OpenStack Cloud that is available to be diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/urls.go similarity index 91% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/urls.go index fec38f36793f0..f5be5f5e3b6af 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs/urls.go @@ -1,6 +1,6 @@ package keypairs -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const resourcePath = "os-keypairs" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/doc.go similarity index 75% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/doc.go index 23fed3c8af4ed..063851ed776dd 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/doc.go @@ -3,7 +3,7 @@ Package servergroups provides the ability to manage server groups. Example to List Server Groups - allpages, err := servergroups.List(computeClient).AllPages() + allpages, err := servergroups.List(computeClient).AllPages(context.TODO()) if err != nil { panic(err) } @@ -24,7 +24,7 @@ Example to Create a Server Group Policies: []string{"anti-affinity"}, } - sg, err := servergroups.Create(computeClient, createOpts).Extract() + sg, err := servergroups.Create(context.TODO(), computeClient, createOpts).Extract() if err != nil { panic(err) } @@ -40,7 +40,7 @@ Example to Create a Server Group with additional microversion 2.64 fields } computeClient.Microversion = "2.64" - result := servergroups.Create(computeClient, createOpts) + result := servergroups.Create(context.TODO(), computeClient, createOpts) serverGroup, err := result.Extract() if err != nil { @@ -50,7 +50,7 @@ Example to Create a Server Group with additional microversion 2.64 fields Example to Delete a Server Group sgID := "7a6f29ad-e34d-4368-951a-58a08f11cfb7" - err := servergroups.Delete(computeClient, sgID).ExtractErr() + err := servergroups.Delete(context.TODO(), computeClient, sgID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/requests.go similarity index 75% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/requests.go index 9769e48debacf..c2b8400011c28 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/requests.go @@ -1,8 +1,10 @@ package servergroups import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type ListOptsBuilder interface { @@ -46,7 +48,7 @@ func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pa // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToServerGroupCreateMap() (map[string]interface{}, error) + ToServerGroupCreateMap() (map[string]any, error) } // CreateOpts specifies Server Group creation parameters. @@ -67,18 +69,18 @@ type CreateOpts struct { } // ToServerGroupCreateMap constructs a request body from CreateOpts. -func (opts CreateOpts) ToServerGroupCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToServerGroupCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "server_group") } // Create requests the creation of a new Server Group. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToServerGroupCreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, createURL(client), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -86,15 +88,15 @@ func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r Create } // Get returns data about a previously created ServerGroup. -func Get(client *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := client.Get(getURL(client, id), &r.Body, nil) +func Get(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := client.Get(ctx, getURL(client, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Delete requests the deletion of a previously allocated ServerGroup. -func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := client.Delete(deleteURL(client, id), nil) +func Delete(ctx context.Context, client *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := client.Delete(ctx, deleteURL(client, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/results.go similarity index 96% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/results.go index 03eb48d27a5f1..1d97dcc9e875c 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/results.go @@ -1,8 +1,8 @@ package servergroups import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // A ServerGroup creates a policy for instance placement in the cloud. @@ -37,7 +37,7 @@ type ServerGroup struct { // Metadata includes a list of all user-specified key-value pairs attached // to the Server Group. - Metadata map[string]interface{} + Metadata map[string]any // Policy is the policy of a server group. // This requires microversion 2.64 or later. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/urls.go similarity index 91% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/urls.go index 9a1f99b199734..bca4f320ba4c5 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups/urls.go @@ -1,6 +1,6 @@ package servergroups -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const resourcePath = "os-server-groups" diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/doc.go new file mode 100644 index 0000000000000..72381f0744fe5 --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/doc.go @@ -0,0 +1,313 @@ +/* +Package servers provides information and interaction with the server API +resource in the OpenStack Compute service. + +A server is a virtual machine instance in the compute system. In order for +one to be provisioned, a valid flavor and image are required. + +Example to List Servers + + listOpts := servers.ListOpts{ + AllTenants: true, + } + + allPages, err := servers.ListSimple(computeClient, listOpts).AllPages(context.TODO()) + if err != nil { + panic(err) + } + + allServers, err := servers.ExtractServers(allPages) + if err != nil { + panic(err) + } + + for _, server := range allServers { + fmt.Printf("%+v\n", server) + } + +Example to List Detail Servers + + listOpts := servers.ListOpts{ + AllTenants: true, + } + + allPages, err := servers.List(computeClient, listOpts).AllPages(context.TODO()) + if err != nil { + panic(err) + } + + allServers, err := servers.ExtractServers(allPages) + if err != nil { + panic(err) + } + + for _, server := range allServers { + fmt.Printf("%+v\n", server) + } + +Example to Create a Server + + createOpts := servers.CreateOpts{ + Name: "server_name", + ImageRef: "image-uuid", + FlavorRef: "flavor-uuid", + } + + server, err := servers.Create(context.TODO(), computeClient, createOpts, nil).Extract() + if err != nil { + panic(err) + } + +Example to Add a Server to a Server Group + + schedulerHintOpts := servers.SchedulerHintOpts{ + Group: "servergroup-uuid", + } + + createOpts := servers.CreateOpts{ + Name: "server_name", + ImageRef: "image-uuid", + FlavorRef: "flavor-uuid", + } + + server, err := servers.Create(context.TODO(), computeClient, createOpts, schedulerHintOpts).Extract() + if err != nil { + panic(err) + } + +Example to Place Server B on a Different Host than Server A + + schedulerHintOpts := servers.SchedulerHintOpts{ + DifferentHost: []string{ + "server-a-uuid", + } + } + + createOpts := servers.CreateOpts{ + Name: "server_b", + ImageRef: "image-uuid", + FlavorRef: "flavor-uuid", + } + + server, err := servers.Create(context.TODO(), computeClient, createOpts, schedulerHintOpts).Extract() + if err != nil { + panic(err) + } + +Example to Place Server B on the Same Host as Server A + + schedulerHintOpts := servers.SchedulerHintOpts{ + SameHost: []string{ + "server-a-uuid", + } + } + + createOpts := servers.CreateOpts{ + Name: "server_b", + ImageRef: "image-uuid", + FlavorRef: "flavor-uuid", + } + + server, err := servers.Create(context.TODO(), computeClient, createOpts, schedulerHintOpts).Extract() + if err != nil { + panic(err) + } + +# Example to Create a Server From an Image + +This example will boot a server from an image and use a standard ephemeral +disk as the server's root disk. This is virtually no different than creating +a server without using block device mappings. + + blockDevices := []servers.BlockDevice{ + servers.BlockDevice{ + BootIndex: 0, + DeleteOnTermination: true, + DestinationType: servers.DestinationLocal, + SourceType: servers.SourceImage, + UUID: "image-uuid", + }, + } + + createOpts := servers.CreateOpts{ + Name: "server_name", + FlavorRef: "flavor-uuid", + ImageRef: "image-uuid", + BlockDevice: blockDevices, + } + + server, err := servers.Create(context.TODO(), client, createOpts, nil).Extract() + if err != nil { + panic(err) + } + +# Example to Create a Server From a New Volume + +This example will create a block storage volume based on the given Image. The +server will use this volume as its root disk. + + blockDevices := []servers.BlockDevice{ + servers.BlockDevice{ + DeleteOnTermination: true, + DestinationType: servers.DestinationVolume, + SourceType: servers.SourceImage, + UUID: "image-uuid", + VolumeSize: 2, + }, + } + + createOpts := servers.CreateOpts{ + Name: "server_name", + FlavorRef: "flavor-uuid", + BlockDevice: blockDevices, + } + + server, err := servers.Create(context.TODO(), client, createOpts, nil).Extract() + if err != nil { + panic(err) + } + +# Example to Create a Server From an Existing Volume + +This example will create a server with an existing volume as its root disk. + + blockDevices := []servers.BlockDevice{ + servers.BlockDevice{ + DeleteOnTermination: true, + DestinationType: servers.DestinationVolume, + SourceType: servers.SourceVolume, + UUID: "volume-uuid", + }, + } + + createOpts := servers.CreateOpts{ + Name: "server_name", + FlavorRef: "flavor-uuid", + BlockDevice: blockDevices, + } + + server, err := servers.Create(context.TODO(), client, createOpts, nil).Extract() + if err != nil { + panic(err) + } + +# Example to Create a Server with Multiple Ephemeral Disks + +This example will create a server with multiple ephemeral disks. The first +block device will be based off of an existing Image. Each additional +ephemeral disks must have an index of -1. + + blockDevices := []servers.BlockDevice{ + servers.BlockDevice{ + BootIndex: 0, + DestinationType: servers.DestinationLocal, + DeleteOnTermination: true, + SourceType: servers.SourceImage, + UUID: "image-uuid", + VolumeSize: 5, + }, + servers.BlockDevice{ + BootIndex: -1, + DestinationType: servers.DestinationLocal, + DeleteOnTermination: true, + GuestFormat: "ext4", + SourceType: servers.SourceBlank, + VolumeSize: 1, + }, + servers.BlockDevice{ + BootIndex: -1, + DestinationType: servers.DestinationLocal, + DeleteOnTermination: true, + GuestFormat: "ext4", + SourceType: servers.SourceBlank, + VolumeSize: 1, + }, + } + + CreateOpts := servers.CreateOpts{ + Name: "server_name", + FlavorRef: "flavor-uuid", + ImageRef: "image-uuid", + BlockDevice: blockDevices, + } + + server, err := servers.Create(context.TODO(), client, createOpts, nil).Extract() + if err != nil { + panic(err) + } + +Example to Delete a Server + + serverID := "d9072956-1560-487c-97f2-18bdf65ec749" + err := servers.Delete(context.TODO(), computeClient, serverID).ExtractErr() + if err != nil { + panic(err) + } + +Example to Force Delete a Server + + serverID := "d9072956-1560-487c-97f2-18bdf65ec749" + err := servers.ForceDelete(context.TODO(), computeClient, serverID).ExtractErr() + if err != nil { + panic(err) + } + +Example to Reboot a Server + + rebootOpts := servers.RebootOpts{ + Type: servers.SoftReboot, + } + + serverID := "d9072956-1560-487c-97f2-18bdf65ec749" + + err := servers.Reboot(context.TODO(), computeClient, serverID, rebootOpts).ExtractErr() + if err != nil { + panic(err) + } + +Example to Rebuild a Server + + rebuildOpts := servers.RebuildOpts{ + Name: "new_name", + ImageID: "image-uuid", + } + + serverID := "d9072956-1560-487c-97f2-18bdf65ec749" + + server, err := servers.Rebuilt(computeClient, serverID, rebuildOpts).Extract() + if err != nil { + panic(err) + } + +Example to Resize a Server + + resizeOpts := servers.ResizeOpts{ + FlavorRef: "flavor-uuid", + } + + serverID := "d9072956-1560-487c-97f2-18bdf65ec749" + + err := servers.Resize(context.TODO(), computeClient, serverID, resizeOpts).ExtractErr() + if err != nil { + panic(err) + } + + err = servers.ConfirmResize(context.TODO(), computeClient, serverID).ExtractErr() + if err != nil { + panic(err) + } + +Example to Snapshot a Server + + snapshotOpts := servers.CreateImageOpts{ + Name: "snapshot_name", + } + + serverID := "d9072956-1560-487c-97f2-18bdf65ec749" + + image, err := servers.CreateImage(context.TODO(), computeClient, serverID, snapshotOpts).ExtractImageID() + if err != nil { + panic(err) + } +*/ +package servers diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/errors.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/errors.go similarity index 98% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/errors.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/errors.go index c9f0e3c20b5d5..a6eda38f45c48 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/errors.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/errors.go @@ -3,7 +3,7 @@ package servers import ( "fmt" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) // ErrNeitherImageIDNorImageNameProvided is the error when neither the image diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/requests.go new file mode 100644 index 0000000000000..dd3b132d1d09c --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/requests.go @@ -0,0 +1,1369 @@ +package servers + +import ( + "context" + "encoding/base64" + "encoding/json" + "fmt" + "maps" + "net" + "regexp" + "strings" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" +) + +// ListOptsBuilder allows extensions to add additional parameters to the +// List request. +type ListOptsBuilder interface { + ToServerListQuery() (string, error) +} + +// ListOpts allows the filtering and sorting of paginated collections through +// the API. Filtering is achieved by passing in struct field values that map to +// the server attributes you want to see returned. Marker and Limit are used +// for pagination. +type ListOpts struct { + // ChangesSince is a time/date stamp for when the server last changed status. + ChangesSince string `q:"changes-since"` + + // Image is the name of the image in URL format. + Image string `q:"image"` + + // Flavor is the name of the flavor in URL format. + Flavor string `q:"flavor"` + + // IP is a regular expression to match the IPv4 address of the server. + IP string `q:"ip"` + + // This requires the client to be set to microversion 2.5 or later, unless + // the user is an admin. + // IP is a regular expression to match the IPv6 address of the server. + IP6 string `q:"ip6"` + + // Name of the server as a string; can be queried with regular expressions. + // Realize that ?name=bob returns both bob and bobb. If you need to match bob + // only, you can use a regular expression matching the syntax of the + // underlying database server implemented for Compute. + Name string `q:"name"` + + // Status is the value of the status of the server so that you can filter on + // "ACTIVE" for example. + Status string `q:"status"` + + // Host is the name of the host as a string. + Host string `q:"host"` + + // Marker is a UUID of the server at which you want to set a marker. + Marker string `q:"marker"` + + // Limit is an integer value for the limit of values to return. + Limit int `q:"limit"` + + // AllTenants is a bool to show all tenants. + AllTenants bool `q:"all_tenants"` + + // TenantID lists servers for a particular tenant. + // Setting "AllTenants = true" is required. + TenantID string `q:"tenant_id"` + + // This requires the client to be set to microversion 2.83 or later, unless + // the user is an admin. + // UserID lists servers for a particular user. + UserID string `q:"user_id"` + + // This requires the client to be set to microversion 2.26 or later. + // Tags filters on specific server tags. All tags must be present for the server. + Tags string `q:"tags"` + + // This requires the client to be set to microversion 2.26 or later. + // TagsAny filters on specific server tags. At least one of the tags must be present for the server. + TagsAny string `q:"tags-any"` + + // This requires the client to be set to microversion 2.26 or later. + // NotTags filters on specific server tags. All tags must be absent for the server. + NotTags string `q:"not-tags"` + + // 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. +func (opts ListOpts) ToServerListQuery() (string, error) { + q, err := gophercloud.BuildQueryString(opts) + return q.String(), err +} + +// ListSimple makes a request against the API to list servers accessible to you. +func ListSimple(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { + url := listURL(client) + if opts != nil { + query, err := opts.ToServerListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + } + return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { + return ServerPage{pagination.LinkedPageBase{PageResult: r}} + }) +} + +// List makes a request against the API to list servers details accessible to you. +func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { + url := listDetailURL(client) + if opts != nil { + query, err := opts.ToServerListQuery() + if err != nil { + return pagination.Pager{Err: err} + } + url += query + } + return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { + return ServerPage{pagination.LinkedPageBase{PageResult: r}} + }) +} + +// SchedulerHintOptsBuilder builds the scheduler hints into a serializable format. +type SchedulerHintOptsBuilder interface { + ToSchedulerHintsMap() (map[string]any, error) +} + +// SchedulerHintOpts represents a set of scheduling hints that are passed to the +// OpenStack scheduler. +type SchedulerHintOpts struct { + // Group specifies a Server Group to place the instance in. + Group string + + // DifferentHost will place the instance on a compute node that does not + // host the given instances. + DifferentHost []string + + // SameHost will place the instance on a compute node that hosts the given + // instances. + SameHost []string + + // Query is a conditional statement that results in compute nodes able to + // host the instance. + Query []any + + // TargetCell specifies a cell name where the instance will be placed. + TargetCell string `json:"target_cell,omitempty"` + + // DifferentCell specifies cells names where an instance should not be placed. + DifferentCell []string `json:"different_cell,omitempty"` + + // BuildNearHostIP specifies a subnet of compute nodes to host the instance. + BuildNearHostIP string + + // AdditionalProperies are arbitrary key/values that are not validated by nova. + AdditionalProperties map[string]any +} + +// ToSchedulerHintsMap assembles a request body for scheduler hints. +func (opts SchedulerHintOpts) ToSchedulerHintsMap() (map[string]any, error) { + sh := make(map[string]any) + + uuidRegex, _ := regexp.Compile("^[a-z0-9]{8}-[a-z0-9]{4}-[1-5][a-z0-9]{3}-[a-z0-9]{4}-[a-z0-9]{12}$") + + if opts.Group != "" { + if !uuidRegex.MatchString(opts.Group) { + err := gophercloud.ErrInvalidInput{} + err.Argument = "servers.schedulerhints.SchedulerHintOpts.Group" + err.Value = opts.Group + err.Info = "Group must be a UUID" + return nil, err + } + sh["group"] = opts.Group + } + + if len(opts.DifferentHost) > 0 { + for _, diffHost := range opts.DifferentHost { + if !uuidRegex.MatchString(diffHost) { + err := gophercloud.ErrInvalidInput{} + err.Argument = "servers.schedulerhints.SchedulerHintOpts.DifferentHost" + err.Value = opts.DifferentHost + err.Info = "The hosts must be in UUID format." + return nil, err + } + } + sh["different_host"] = opts.DifferentHost + } + + if len(opts.SameHost) > 0 { + for _, sameHost := range opts.SameHost { + if !uuidRegex.MatchString(sameHost) { + err := gophercloud.ErrInvalidInput{} + err.Argument = "servers.schedulerhints.SchedulerHintOpts.SameHost" + err.Value = opts.SameHost + err.Info = "The hosts must be in UUID format." + return nil, err + } + } + sh["same_host"] = opts.SameHost + } + + /* + Query can be something simple like: + [">=", "$free_ram_mb", 1024] + + Or more complex like: + ['and', + ['>=', '$free_ram_mb', 1024], + ['>=', '$free_disk_mb', 200 * 1024] + ] + + Because of the possible complexity, just make sure the length is a minimum of 3. + */ + if len(opts.Query) > 0 { + if len(opts.Query) < 3 { + err := gophercloud.ErrInvalidInput{} + err.Argument = "servers.schedulerhints.SchedulerHintOpts.Query" + err.Value = opts.Query + err.Info = "Must be a conditional statement in the format of [op,variable,value]" + return nil, err + } + + // The query needs to be sent as a marshalled string. + b, err := json.Marshal(opts.Query) + if err != nil { + err := gophercloud.ErrInvalidInput{} + err.Argument = "servers.schedulerhints.SchedulerHintOpts.Query" + err.Value = opts.Query + err.Info = "Must be a conditional statement in the format of [op,variable,value]" + return nil, err + } + + sh["query"] = string(b) + } + + if opts.TargetCell != "" { + sh["target_cell"] = opts.TargetCell + } + + if len(opts.DifferentCell) > 0 { + sh["different_cell"] = opts.DifferentCell + } + + if opts.BuildNearHostIP != "" { + if _, _, err := net.ParseCIDR(opts.BuildNearHostIP); err != nil { + err := gophercloud.ErrInvalidInput{} + err.Argument = "servers.schedulerhints.SchedulerHintOpts.BuildNearHostIP" + err.Value = opts.BuildNearHostIP + err.Info = "Must be a valid subnet in the form 192.168.1.1/24" + return nil, err + } + ipParts := strings.Split(opts.BuildNearHostIP, "/") + sh["build_near_host_ip"] = ipParts[0] + sh["cidr"] = "/" + ipParts[1] + } + + if opts.AdditionalProperties != nil { + for k, v := range opts.AdditionalProperties { + sh[k] = v + } + } + + if len(sh) == 0 { + return sh, nil + } + + return map[string]any{"os:scheduler_hints": sh}, nil +} + +// Network is used within CreateOpts to control a new server's network +// attachments. +type Network struct { + // UUID of a network to attach to the newly provisioned server. + // Required unless Port is provided. + UUID string + + // Port of a neutron network to attach to the newly provisioned server. + // Required unless UUID is provided. + Port string + + // 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 +} + +type ( + // DestinationType represents the type of medium being used as the + // destination of the bootable device. + DestinationType string + + // SourceType represents the type of medium being used as the source of the + // bootable device. + SourceType string +) + +const ( + // DestinationLocal DestinationType is for using an ephemeral disk as the + // destination. + DestinationLocal DestinationType = "local" + + // DestinationVolume DestinationType is for using a volume as the destination. + DestinationVolume DestinationType = "volume" + + // SourceBlank SourceType is for a "blank" or empty source. + SourceBlank SourceType = "blank" + + // SourceImage SourceType is for using images as the source of a block device. + SourceImage SourceType = "image" + + // SourceSnapshot SourceType is for using a volume snapshot as the source of + // a block device. + SourceSnapshot SourceType = "snapshot" + + // SourceVolume SourceType is for using a volume as the source of block + // device. + SourceVolume SourceType = "volume" +) + +// BlockDevice is a structure with options for creating block devices in a +// server. The block device may be created from an image, snapshot, new volume, +// or existing volume. The destination may be a new volume, existing volume +// which will be attached to the instance, ephemeral disk, or boot device. +type BlockDevice struct { + // SourceType must be one of: "volume", "snapshot", "image", or "blank". + SourceType SourceType `json:"source_type" required:"true"` + + // UUID is the unique identifier for the existing volume, snapshot, or + // image (see above). + UUID string `json:"uuid,omitempty"` + + // BootIndex is the boot index. It defaults to 0. + BootIndex int `json:"boot_index"` + + // DeleteOnTermination specifies whether or not to delete the attached volume + // when the server is deleted. Defaults to `false`. + DeleteOnTermination bool `json:"delete_on_termination"` + + // DestinationType is the type that gets created. Possible values are "volume" + // and "local". + DestinationType DestinationType `json:"destination_type,omitempty"` + + // GuestFormat specifies the format of the block device. + // Not specifying this will cause the device to be formatted to the default in Nova + // which is currently vfat. + // https://opendev.org/openstack/nova/src/commit/d0b459423dd81644e8d9382b6c87fabaa4f03ad4/nova/privsep/fs.py#L257 + GuestFormat string `json:"guest_format,omitempty"` + + // VolumeSize is the size of the volume to create (in gigabytes). This can be + // omitted for existing volumes. + VolumeSize int `json:"volume_size,omitempty"` + + // DeviceType specifies the device type of the block devices. + // Examples of this are disk, cdrom, floppy, lun, etc. + DeviceType string `json:"device_type,omitempty"` + + // DiskBus is the bus type of the block devices. + // Examples of this are ide, usb, virtio, scsi, etc. + DiskBus string `json:"disk_bus,omitempty"` + + // VolumeType is the volume type of the block device. + // This requires Compute API microversion 2.67 or later. + VolumeType string `json:"volume_type,omitempty"` + + // Tag is an arbitrary string that can be applied to a block device. + // Information about the device tags can be obtained from the metadata API + // and the config drive, allowing devices to be easily identified. + // This requires Compute API microversion 2.42 or later. + Tag string `json:"tag,omitempty"` +} + +// Personality is an array of files that are injected into the server at launch. +type Personality []*File + +// File is used within CreateOpts and RebuildOpts to inject a file into the +// server at launch. +// File implements the json.Marshaler interface, so when a Create or Rebuild +// operation is requested, json.Marshal will call File's MarshalJSON method. +type File struct { + // Path of the file. + Path string + + // Contents of the file. Maximum content size is 255 bytes. + Contents []byte +} + +// MarshalJSON marshals the escaped file, base64 encoding the contents. +func (f *File) MarshalJSON() ([]byte, error) { + file := struct { + Path string `json:"path"` + Contents string `json:"contents"` + }{ + Path: f.Path, + Contents: base64.StdEncoding.EncodeToString(f.Contents), + } + return json.Marshal(file) +} + +// DiskConfig represents one of the two possible settings for the DiskConfig +// option when creating, rebuilding, or resizing servers: Auto or Manual. +type DiskConfig string + +const ( + // Auto builds a server with a single partition the size of the target flavor + // disk and automatically adjusts the filesystem to fit the entire partition. + // Auto may only be used with images and servers that use a single EXT3 + // partition. + Auto DiskConfig = "AUTO" + + // Manual builds a server using whatever partition scheme and filesystem are + // present in the source image. If the target flavor disk is larger, the + // remaining space is left unpartitioned. This enables images to have non-EXT3 + // filesystems, multiple partitions, and so on, and enables you to manage the + // disk configuration. It also results in slightly shorter boot times. + Manual DiskConfig = "MANUAL" +) + +// CreateOptsBuilder allows extensions to add additional parameters to the +// Create request. +type CreateOptsBuilder interface { + ToServerCreateMap() (map[string]any, error) +} + +// CreateOpts specifies server creation parameters. +type CreateOpts struct { + // Name is the name to assign to the newly launched server. + Name string `json:"name" required:"true"` + + // ImageRef is the ID or full URL to the image that contains the + // server's OS and initial state. + // Also optional if using the boot-from-volume extension. + ImageRef string `json:"imageRef"` + + // FlavorRef is the ID or full URL to the flavor that describes the server's specs. + FlavorRef string `json:"flavorRef"` + + // SecurityGroups lists the names of the security groups to which this server + // should belong. + SecurityGroups []string `json:"-"` + + // UserData contains configuration information or scripts to use upon launch. + // Create will base64-encode it for you, if it isn't already. + UserData []byte `json:"-"` + + // AvailabilityZone in which to launch the server. + AvailabilityZone string `json:"availability_zone,omitempty"` + + // Networks dictates how this server will be attached to available networks. + // By default, the server will be attached to all isolated networks for the + // tenant. + // Starting with microversion 2.37 networks can also be an "auto" or "none" + // string. + Networks any `json:"-"` + + // Metadata contains key-value pairs (up to 255 bytes each) to attach to the + // server. + Metadata map[string]string `json:"metadata,omitempty"` + + // Personality includes files to inject into the server at launch. + // Create will base64-encode file contents for you. + Personality Personality `json:"personality,omitempty"` + + // ConfigDrive enables metadata injection through a configuration drive. + ConfigDrive *bool `json:"config_drive,omitempty"` + + // AdminPass sets the root user password. If not set, a randomly-generated + // password will be created and returned in the response. + AdminPass string `json:"adminPass,omitempty"` + + // AccessIPv4 specifies an IPv4 address for the instance. + AccessIPv4 string `json:"accessIPv4,omitempty"` + + // AccessIPv6 specifies an IPv6 address for the instance. + AccessIPv6 string `json:"accessIPv6,omitempty"` + + // Min specifies Minimum number of servers to launch. + Min int `json:"min_count,omitempty"` + + // Max specifies Maximum number of servers to launch. + Max int `json:"max_count,omitempty"` + + // Tags allows a server to be tagged with single-word metadata. + // Requires microversion 2.52 or later. + Tags []string `json:"tags,omitempty"` + + // (Available from 2.90) Hostname specifies the hostname to configure for the + // instance in the metadata service. Starting with microversion 2.94, this can + // be a Fully Qualified Domain Name (FQDN) of up to 255 characters in length. + // If not set, OpenStack will derive the server's hostname from the Name field. + Hostname string `json:"hostname,omitempty"` + + // BlockDevice describes the mapping of various block devices. + BlockDevice []BlockDevice `json:"block_device_mapping_v2,omitempty"` + + // DiskConfig [optional] controls how the created server's disk is partitioned. + DiskConfig DiskConfig `json:"OS-DCF:diskConfig,omitempty"` +} + +// ToServerCreateMap assembles a request body based on the contents of a +// CreateOpts. +func (opts CreateOpts) ToServerCreateMap() (map[string]any, error) { + // We intentionally don't envelope the body here since we want to strip + // some fields out and modify others + b, err := gophercloud.BuildRequestBody(opts, "") + if err != nil { + return nil, err + } + + if opts.UserData != nil { + var userData string + if _, err := base64.StdEncoding.DecodeString(string(opts.UserData)); err != nil { + userData = base64.StdEncoding.EncodeToString(opts.UserData) + } else { + userData = string(opts.UserData) + } + b["user_data"] = &userData + } + + if len(opts.SecurityGroups) > 0 { + securityGroups := make([]map[string]any, len(opts.SecurityGroups)) + for i, groupName := range opts.SecurityGroups { + securityGroups[i] = map[string]any{"name": groupName} + } + b["security_groups"] = securityGroups + } + + switch v := opts.Networks.(type) { + case []Network: + if len(v) > 0 { + networks := make([]map[string]any, len(v)) + for i, net := range v { + networks[i] = make(map[string]any) + if net.UUID != "" { + networks[i]["uuid"] = net.UUID + } + if net.Port != "" { + networks[i]["port"] = net.Port + } + if net.FixedIP != "" { + networks[i]["fixed_ip"] = net.FixedIP + } + if net.Tag != "" { + networks[i]["tag"] = net.Tag + } + } + b["networks"] = networks + } + case string: + if v == "auto" || v == "none" { + b["networks"] = v + } else { + return nil, fmt.Errorf(`networks must be a slice of Network struct or a string with "auto" or "none" values, current value is %q`, v) + } + } + + if opts.Min != 0 { + b["min_count"] = opts.Min + } + + if opts.Max != 0 { + b["max_count"] = opts.Max + } + + // Now we do our enveloping + b = map[string]any{"server": b} + + return b, nil +} + +// Create requests a server to be provisioned to the user in the current tenant. +func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder, hintOpts SchedulerHintOptsBuilder) (r CreateResult) { + b, err := opts.ToServerCreateMap() + if err != nil { + r.Err = err + return + } + + if hintOpts != nil { + sh, err := hintOpts.ToSchedulerHintsMap() + if err != nil { + r.Err = err + return + } + maps.Copy(b, sh) + } + + resp, err := client.Post(ctx, createURL(client), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200, 202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Delete requests that a server previously provisioned be removed from your +// account. +func Delete(ctx context.Context, client *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := client.Delete(ctx, deleteURL(client, id), nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ForceDelete forces the deletion of a server. +func ForceDelete(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ActionResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"forceDelete": ""}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Get requests details on a single server, by ID. +func Get(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := client.Get(ctx, getURL(client, id), &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200, 203}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UpdateOptsBuilder allows extensions to add additional attributes to the +// Update request. +type UpdateOptsBuilder interface { + ToServerUpdateMap() (map[string]any, error) +} + +// UpdateOpts specifies the base attributes that may be updated on an existing +// server. +type UpdateOpts struct { + // Name changes the displayed name of the server. + // The server host name will *not* change. + // Server names are not constrained to be unique, even within the same tenant. + Name string `json:"name,omitempty"` + + // AccessIPv4 provides a new IPv4 address for the instance. + AccessIPv4 string `json:"accessIPv4,omitempty"` + + // AccessIPv6 provides a new IPv6 address for the instance. + AccessIPv6 string `json:"accessIPv6,omitempty"` +} + +// ToServerUpdateMap formats an UpdateOpts structure into a request body. +func (opts UpdateOpts) ToServerUpdateMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "server") +} + +// Update requests that various attributes of the indicated server be changed. +func Update(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { + b, err := opts.ToServerUpdateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Put(ctx, updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ChangeAdminPassword alters the administrator or root password for a specified +// server. +func ChangeAdminPassword(ctx context.Context, client *gophercloud.ServiceClient, id, newPassword string) (r ActionResult) { + b := map[string]any{ + "changePassword": map[string]string{ + "adminPass": newPassword, + }, + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// RebootMethod describes the mechanisms by which a server reboot can be requested. +type RebootMethod string + +// These constants determine how a server should be rebooted. +// See the Reboot() function for further details. +const ( + SoftReboot RebootMethod = "SOFT" + HardReboot RebootMethod = "HARD" + OSReboot = SoftReboot + PowerCycle = HardReboot +) + +// RebootOptsBuilder allows extensions to add additional parameters to the +// reboot request. +type RebootOptsBuilder interface { + ToServerRebootMap() (map[string]any, error) +} + +// RebootOpts provides options to the reboot request. +type RebootOpts struct { + // Type is the type of reboot to perform on the server. + Type RebootMethod `json:"type" required:"true"` +} + +// ToServerRebootMap builds a body for the reboot request. +func (opts RebootOpts) ToServerRebootMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "reboot") +} + +/* +Reboot requests that a given server reboot. + +Two methods exist for rebooting a server: + +HardReboot (aka PowerCycle) starts the server instance by physically cutting +power to the machine, or if a VM, terminating it at the hypervisor level. +It's done. Caput. Full stop. +Then, after a brief while, power is restored or the VM instance restarted. + +SoftReboot (aka OSReboot) simply tells the OS to restart under its own +procedure. +E.g., in Linux, asking it to enter runlevel 6, or executing +"sudo shutdown -r now", or by asking Windows to rtart the machine. +*/ +func Reboot(ctx context.Context, client *gophercloud.ServiceClient, id string, opts RebootOptsBuilder) (r ActionResult) { + b, err := opts.ToServerRebootMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// RebuildOptsBuilder allows extensions to provide additional parameters to the +// rebuild request. +type RebuildOptsBuilder interface { + ToServerRebuildMap() (map[string]any, error) +} + +// RebuildOpts represents the configuration options used in a server rebuild +// operation. +type RebuildOpts struct { + // AdminPass is the server's admin password + AdminPass string `json:"adminPass,omitempty"` + + // ImageRef is the ID of the image you want your server to be provisioned on. + ImageRef string `json:"imageRef"` + + // Name to set the server to + Name string `json:"name,omitempty"` + + // AccessIPv4 [optional] provides a new IPv4 address for the instance. + AccessIPv4 string `json:"accessIPv4,omitempty"` + + // AccessIPv6 [optional] provides a new IPv6 address for the instance. + AccessIPv6 string `json:"accessIPv6,omitempty"` + + // Metadata [optional] contains key-value pairs (up to 255 bytes each) + // to attach to the server. + Metadata map[string]string `json:"metadata,omitempty"` + + // Personality [optional] includes files to inject into the server at launch. + // Rebuild will base64-encode file contents for you. + Personality Personality `json:"personality,omitempty"` + + // DiskConfig controls how the rebuilt server's disk is partitioned. + DiskConfig DiskConfig `json:"OS-DCF:diskConfig,omitempty"` +} + +// ToServerRebuildMap formats a RebuildOpts struct into a map for use in JSON +func (opts RebuildOpts) ToServerRebuildMap() (map[string]any, error) { + if opts.DiskConfig != "" && opts.DiskConfig != Auto && opts.DiskConfig != Manual { + err := gophercloud.ErrInvalidInput{} + err.Argument = "servers.RebuildOpts.DiskConfig" + err.Info = "Must be either diskconfig.Auto or diskconfig.Manual" + return nil, err + } + + b, err := gophercloud.BuildRequestBody(opts, "") + if err != nil { + return nil, err + } + + return map[string]any{"rebuild": b}, nil +} + +// Rebuild will reprovision the server according to the configuration options +// provided in the RebuildOpts struct. +func Rebuild(ctx context.Context, client *gophercloud.ServiceClient, id string, opts RebuildOptsBuilder) (r RebuildResult) { + b, err := opts.ToServerRebuildMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ResizeOptsBuilder allows extensions to add additional parameters to the +// resize request. +type ResizeOptsBuilder interface { + ToServerResizeMap() (map[string]any, error) +} + +// ResizeOpts represents the configuration options used to control a Resize +// operation. +type ResizeOpts struct { + // FlavorRef is the ID of the flavor you wish your server to become. + FlavorRef string `json:"flavorRef" required:"true"` + + // DiskConfig [optional] controls how the resized server's disk is partitioned. + DiskConfig DiskConfig `json:"OS-DCF:diskConfig,omitempty"` +} + +// ToServerResizeMap formats a ResizeOpts as a map that can be used as a JSON +// request body for the Resize request. +func (opts ResizeOpts) ToServerResizeMap() (map[string]any, error) { + if opts.DiskConfig != "" && opts.DiskConfig != Auto && opts.DiskConfig != Manual { + err := gophercloud.ErrInvalidInput{} + err.Argument = "servers.ResizeOpts.DiskConfig" + err.Info = "Must be either diskconfig.Auto or diskconfig.Manual" + return nil, err + } + + return gophercloud.BuildRequestBody(opts, "resize") +} + +// Resize instructs the provider to change the flavor of the server. +// +// Note that this implies rebuilding it. +// +// Unfortunately, one cannot pass rebuild parameters to the resize function. +// When the resize completes, the server will be in VERIFY_RESIZE state. +// While in this state, you can explore the use of the new server's +// configuration. If you like it, call ConfirmResize() to commit the resize +// permanently. Otherwise, call RevertResize() to restore the old configuration. +func Resize(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ResizeOptsBuilder) (r ActionResult) { + b, err := opts.ToServerResizeMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ConfirmResize confirms a previous resize operation on a server. +// See Resize() for more details. +func ConfirmResize(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ActionResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"confirmResize": nil}, nil, &gophercloud.RequestOpts{ + OkCodes: []int{201, 202, 204}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// RevertResize cancels a previous resize operation on a server. +// See Resize() for more details. +func RevertResize(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ActionResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"revertResize": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ResetMetadataOptsBuilder allows extensions to add additional parameters to +// the Reset request. +type ResetMetadataOptsBuilder interface { + ToMetadataResetMap() (map[string]any, error) +} + +// MetadataOpts is a map that contains key-value pairs. +type MetadataOpts map[string]string + +// ToMetadataResetMap assembles a body for a Reset request based on the contents +// of a MetadataOpts. +func (opts MetadataOpts) ToMetadataResetMap() (map[string]any, error) { + return map[string]any{"metadata": opts}, nil +} + +// ToMetadataUpdateMap assembles a body for an Update request based on the +// contents of a MetadataOpts. +func (opts MetadataOpts) ToMetadataUpdateMap() (map[string]any, error) { + return map[string]any{"metadata": opts}, nil +} + +// ResetMetadata will create multiple new key-value pairs for the given server +// ID. +// Note: Using this operation will erase any already-existing metadata and +// create the new metadata provided. To keep any already-existing metadata, +// use the UpdateMetadatas or UpdateMetadata function. +func ResetMetadata(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ResetMetadataOptsBuilder) (r ResetMetadataResult) { + b, err := opts.ToMetadataResetMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Put(ctx, metadataURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Metadata requests all the metadata for the given server ID. +func Metadata(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetMetadataResult) { + resp, err := client.Get(ctx, metadataURL(client, id), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UpdateMetadataOptsBuilder allows extensions to add additional parameters to +// the Create request. +type UpdateMetadataOptsBuilder interface { + ToMetadataUpdateMap() (map[string]any, error) +} + +// UpdateMetadata updates (or creates) all the metadata specified by opts for +// the given server ID. This operation does not affect already-existing metadata +// that is not specified by opts. +func UpdateMetadata(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateMetadataOptsBuilder) (r UpdateMetadataResult) { + b, err := opts.ToMetadataUpdateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, metadataURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// MetadatumOptsBuilder allows extensions to add additional parameters to the +// Create request. +type MetadatumOptsBuilder interface { + ToMetadatumCreateMap() (map[string]any, string, error) +} + +// MetadatumOpts is a map of length one that contains a key-value pair. +type MetadatumOpts map[string]string + +// ToMetadatumCreateMap assembles a body for a Create request based on the +// contents of a MetadataumOpts. +func (opts MetadatumOpts) ToMetadatumCreateMap() (map[string]any, string, error) { + if len(opts) != 1 { + err := gophercloud.ErrInvalidInput{} + err.Argument = "servers.MetadatumOpts" + err.Info = "Must have 1 and only 1 key-value pair" + return nil, "", err + } + metadatum := map[string]any{"meta": opts} + var key string + for k := range metadatum["meta"].(MetadatumOpts) { + key = k + } + return metadatum, key, nil +} + +// CreateMetadatum will create or update the key-value pair with the given key +// for the given server ID. +func CreateMetadatum(ctx context.Context, client *gophercloud.ServiceClient, id string, opts MetadatumOptsBuilder) (r CreateMetadatumResult) { + b, key, err := opts.ToMetadatumCreateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Put(ctx, metadatumURL(client, id, key), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Metadatum requests the key-value pair with the given key for the given +// server ID. +func Metadatum(ctx context.Context, client *gophercloud.ServiceClient, id, key string) (r GetMetadatumResult) { + resp, err := client.Get(ctx, metadatumURL(client, id, key), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// DeleteMetadatum will delete the key-value pair with the given key for the +// given server ID. +func DeleteMetadatum(ctx context.Context, client *gophercloud.ServiceClient, id, key string) (r DeleteMetadatumResult) { + resp, err := client.Delete(ctx, metadatumURL(client, id, key), nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ListAddresses makes a request against the API to list the servers IP +// addresses. +func ListAddresses(client *gophercloud.ServiceClient, id string) pagination.Pager { + return pagination.NewPager(client, listAddressesURL(client, id), func(r pagination.PageResult) pagination.Page { + return AddressPage{pagination.SinglePageBase(r)} + }) +} + +// ListAddressesByNetwork makes a request against the API to list the servers IP +// addresses for the given network. +func ListAddressesByNetwork(client *gophercloud.ServiceClient, id, network string) pagination.Pager { + return pagination.NewPager(client, listAddressesByNetworkURL(client, id, network), func(r pagination.PageResult) pagination.Page { + return NetworkAddressPage{pagination.SinglePageBase(r)} + }) +} + +// CreateImageOptsBuilder allows extensions to add additional parameters to the +// CreateImage request. +type CreateImageOptsBuilder interface { + ToServerCreateImageMap() (map[string]any, error) +} + +// CreateImageOpts provides options to pass to the CreateImage request. +type CreateImageOpts struct { + // Name of the image/snapshot. + Name string `json:"name" required:"true"` + + // Metadata contains key-value pairs (up to 255 bytes each) to attach to + // the created image. + Metadata map[string]string `json:"metadata,omitempty"` +} + +// ToServerCreateImageMap formats a CreateImageOpts structure into a request +// body. +func (opts CreateImageOpts) ToServerCreateImageMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "createImage") +} + +// CreateImage makes a request against the nova API to schedule an image to be +// created of the server +func CreateImage(ctx context.Context, client *gophercloud.ServiceClient, id string, opts CreateImageOptsBuilder) (r CreateImageResult) { + b, err := opts.ToServerCreateImageMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, &gophercloud.RequestOpts{ + OkCodes: []int{202}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// GetPassword makes a request against the nova API to get the encrypted +// administrative password. +func GetPassword(ctx context.Context, client *gophercloud.ServiceClient, serverId string) (r GetPasswordResult) { + resp, err := client.Get(ctx, passwordURL(client, serverId), &r.Body, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ShowConsoleOutputOptsBuilder is the interface types must satisfy in order to be +// used as ShowConsoleOutput options +type ShowConsoleOutputOptsBuilder interface { + ToServerShowConsoleOutputMap() (map[string]any, error) +} + +// ShowConsoleOutputOpts satisfies the ShowConsoleOutputOptsBuilder +type ShowConsoleOutputOpts struct { + // The number of lines to fetch from the end of console log. + // All lines will be returned if this is not specified. + Length int `json:"length,omitempty"` +} + +// ToServerShowConsoleOutputMap formats a ShowConsoleOutputOpts structure into a request body. +func (opts ShowConsoleOutputOpts) ToServerShowConsoleOutputMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-getConsoleOutput") +} + +// ShowConsoleOutput makes a request against the nova API to get console log from the server +func ShowConsoleOutput(ctx context.Context, client *gophercloud.ServiceClient, id string, opts ShowConsoleOutputOptsBuilder) (r ShowConsoleOutputResult) { + b, err := opts.ToServerShowConsoleOutputMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// EvacuateOptsBuilder allows extensions to add additional parameters to the +// the Evacuate request. +type EvacuateOptsBuilder interface { + ToEvacuateMap() (map[string]any, error) +} + +// EvacuateOpts specifies Evacuate action parameters. +type EvacuateOpts struct { + // The name of the host to which the server is evacuated + Host string `json:"host,omitempty"` + + // Indicates whether server is on shared storage + OnSharedStorage bool `json:"onSharedStorage"` + + // An administrative password to access the evacuated server + AdminPass string `json:"adminPass,omitempty"` +} + +// ToServerGroupCreateMap constructs a request body from CreateOpts. +func (opts EvacuateOpts) ToEvacuateMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "evacuate") +} + +// Evacuate will Evacuate a failed instance to another host. +func Evacuate(ctx context.Context, client *gophercloud.ServiceClient, id string, opts EvacuateOptsBuilder) (r EvacuateResult) { + b, err := opts.ToEvacuateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// InjectNetworkInfo will inject the network info into a server +func InjectNetworkInfo(ctx context.Context, client *gophercloud.ServiceClient, id string) (r InjectNetworkResult) { + b := map[string]any{ + "injectNetworkInfo": nil, + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Lock is the operation responsible for locking a Compute server. +func Lock(ctx context.Context, client *gophercloud.ServiceClient, id string) (r LockResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"lock": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Unlock is the operation responsible for unlocking a Compute server. +func Unlock(ctx context.Context, client *gophercloud.ServiceClient, id string) (r UnlockResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"unlock": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Migrate will initiate a migration of the instance to another host. +func Migrate(ctx context.Context, client *gophercloud.ServiceClient, id string) (r MigrateResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"migrate": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// LiveMigrateOptsBuilder allows extensions to add additional parameters to the +// LiveMigrate request. +type LiveMigrateOptsBuilder interface { + ToLiveMigrateMap() (map[string]any, error) +} + +// LiveMigrateOpts specifies parameters of live migrate action. +type LiveMigrateOpts struct { + // The host to which to migrate the server. + // If this parameter is None, the scheduler chooses a host. + Host *string `json:"host"` + + // Set to True to migrate local disks by using block migration. + // If the source or destination host uses shared storage and you set + // this value to True, the live migration fails. + BlockMigration *bool `json:"block_migration,omitempty"` + + // Set to True to enable over commit when the destination host is checked + // for available disk space. Set to False to disable over commit. This setting + // affects only the libvirt virt driver. + DiskOverCommit *bool `json:"disk_over_commit,omitempty"` +} + +// ToLiveMigrateMap constructs a request body from LiveMigrateOpts. +func (opts LiveMigrateOpts) ToLiveMigrateMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "os-migrateLive") +} + +// LiveMigrate will initiate a live-migration (without rebooting) of the instance to another host. +func LiveMigrate(ctx context.Context, client *gophercloud.ServiceClient, id string, opts LiveMigrateOptsBuilder) (r MigrateResult) { + b, err := opts.ToLiveMigrateMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Pause is the operation responsible for pausing a Compute server. +func Pause(ctx context.Context, client *gophercloud.ServiceClient, id string) (r PauseResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"pause": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Unpause is the operation responsible for unpausing a Compute server. +func Unpause(ctx context.Context, client *gophercloud.ServiceClient, id string) (r UnpauseResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"unpause": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// RescueOptsBuilder is an interface that allows extensions to override the +// default structure of a Rescue request. +type RescueOptsBuilder interface { + ToServerRescueMap() (map[string]any, error) +} + +// RescueOpts represents the configuration options used to control a Rescue +// option. +type RescueOpts struct { + // AdminPass is the desired administrative password for the instance in + // RESCUE mode. + // If it's left blank, the server will generate a password. + AdminPass string `json:"adminPass,omitempty"` + + // RescueImageRef contains reference on an image that needs to be used as + // rescue image. + // If it's left blank, the server will be rescued with the default image. + RescueImageRef string `json:"rescue_image_ref,omitempty"` +} + +// ToServerRescueMap formats a RescueOpts as a map that can be used as a JSON +// request body for the Rescue request. +func (opts RescueOpts) ToServerRescueMap() (map[string]any, error) { + return gophercloud.BuildRequestBody(opts, "rescue") +} + +// Rescue instructs the provider to place the server into RESCUE mode. +func Rescue(ctx context.Context, client *gophercloud.ServiceClient, id string, opts RescueOptsBuilder) (r RescueResult) { + b, err := opts.ToServerRescueMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + OkCodes: []int{200}, + }) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Unrescue instructs the provider to return the server from RESCUE mode. +func Unrescue(ctx context.Context, client *gophercloud.ServiceClient, id string) (r UnrescueResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"unrescue": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ResetNetwork will reset the network of a server +func ResetNetwork(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ResetNetworkResult) { + b := map[string]any{ + "resetNetwork": nil, + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ServerState refers to the states usable in ResetState Action +type ServerState string + +const ( + // StateActive returns the state of the server as active + StateActive ServerState = "active" + + // StateError returns the state of the server as error + StateError ServerState = "error" +) + +// ResetState will reset the state of a server +func ResetState(ctx context.Context, client *gophercloud.ServiceClient, id string, state ServerState) (r ResetStateResult) { + stateMap := map[string]any{"state": state} + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"os-resetState": stateMap}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Shelve is the operation responsible for shelving a Compute server. +func Shelve(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ShelveResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"shelve": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// ShelveOffload is the operation responsible for Shelve-Offload a Compute server. +func ShelveOffload(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ShelveOffloadResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"shelveOffload": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// UnshelveOptsBuilder allows extensions to add additional parameters to the +// Unshelve request. +type UnshelveOptsBuilder interface { + ToUnshelveMap() (map[string]any, error) +} + +// UnshelveOpts specifies parameters of shelve-offload action. +type UnshelveOpts struct { + // Sets the availability zone to unshelve a server + // Available only after nova 2.77 + AvailabilityZone string `json:"availability_zone,omitempty"` +} + +func (opts UnshelveOpts) ToUnshelveMap() (map[string]any, error) { + // Key 'availabilty_zone' is required if the unshelve action is an object + // i.e {"unshelve": {}} will be rejected + b, err := gophercloud.BuildRequestBody(opts, "unshelve") + if err != nil { + return nil, err + } + + if _, ok := b["unshelve"].(map[string]any)["availability_zone"]; !ok { + b["unshelve"] = nil + } + + return b, err +} + +// Unshelve is the operation responsible for unshelve a Compute server. +func Unshelve(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UnshelveOptsBuilder) (r UnshelveResult) { + b, err := opts.ToUnshelveMap() + if err != nil { + r.Err = err + return + } + resp, err := client.Post(ctx, actionURL(client, id), b, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Start is the operation responsible for starting a Compute server. +func Start(ctx context.Context, client *gophercloud.ServiceClient, id string) (r StartResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"os-start": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Stop is the operation responsible for stopping a Compute server. +func Stop(ctx context.Context, client *gophercloud.ServiceClient, id string) (r StopResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"os-stop": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Suspend is the operation responsible for suspending a Compute server. +func Suspend(ctx context.Context, client *gophercloud.ServiceClient, id string) (r SuspendResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"suspend": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} + +// Resume is the operation responsible for resuming a Compute server. +func Resume(ctx context.Context, client *gophercloud.ServiceClient, id string) (r ResumeResult) { + resp, err := client.Post(ctx, actionURL(client, id), map[string]any{"resume": nil}, nil, nil) + _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) + return +} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/results.go similarity index 63% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/results.go index 2c22a3c4d1f1b..dc51564176dae 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/results.go @@ -9,8 +9,8 @@ import ( "path" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type serverResult struct { @@ -24,11 +24,11 @@ func (r serverResult) Extract() (*Server, error) { return &s, err } -func (r serverResult) ExtractInto(v interface{}) error { +func (r serverResult) ExtractInto(v any) error { return r.Result.ExtractIntoStructPtr(v, "server") } -func ExtractServersInto(r pagination.Page, v interface{}) error { +func ExtractServersInto(r pagination.Page, v any) error { return r.(ServerPage).Result.ExtractIntoSlicePtr(v, "servers") } @@ -182,15 +182,15 @@ type Server struct { // Image refers to a JSON object, which itself indicates the OS image used to // deploy the server. - Image map[string]interface{} `json:"-"` + Image map[string]any `json:"-"` // Flavor refers to a JSON object, which itself indicates the hardware // configuration of the deployed server. - Flavor map[string]interface{} `json:"flavor"` + Flavor map[string]any `json:"flavor"` // Addresses includes a list of all IP addresses assigned to the server, // keyed by pool. - Addresses map[string]interface{} `json:"addresses"` + Addresses map[string]any `json:"addresses"` // Metadata includes a list of all user-specified key-value pairs attached // to the server. @@ -198,7 +198,7 @@ type Server struct { // Links includes HTTP references to the itself, useful for passing along to // other APIs that might want a server reference. - Links []interface{} `json:"links"` + Links []any `json:"links"` // KeyName indicates which public key was injected into the server on launch. KeyName string `json:"key_name"` @@ -211,7 +211,7 @@ type Server struct { // SecurityGroups includes the security groups that this instance has applied // to it. - SecurityGroups []map[string]interface{} `json:"security_groups"` + SecurityGroups []map[string]any `json:"security_groups"` // AttachedVolumes includes the volume attachments of this instance AttachedVolumes []AttachedVolume `json:"os-extended-volumes:volumes_attached"` @@ -228,6 +228,57 @@ type Server struct { // contain at most one entry. // New in microversion 2.71 ServerGroups *[]string `json:"server_groups"` + + // Host is the host/hypervisor that the instance is hosted on. + Host string `json:"OS-EXT-SRV-ATTR:host"` + + // InstanceName is the name of the instance. + InstanceName string `json:"OS-EXT-SRV-ATTR:instance_name"` + + // HypervisorHostname is the hostname of the host/hypervisor that the + // instance is hosted on. + HypervisorHostname string `json:"OS-EXT-SRV-ATTR:hypervisor_hostname"` + + // ReservationID is the reservation ID of the instance. + // This requires microversion 2.3 or later. + ReservationID *string `json:"OS-EXT-SRV-ATTR:reservation_id"` + + // LaunchIndex is the launch index of the instance. + // This requires microversion 2.3 or later. + LaunchIndex *int `json:"OS-EXT-SRV-ATTR:launch_index"` + + // RAMDiskID is the ID of the RAM disk image of the instance. + // This requires microversion 2.3 or later. + RAMDiskID *string `json:"OS-EXT-SRV-ATTR:ramdisk_id"` + + // KernelID is the ID of the kernel image of the instance. + // This requires microversion 2.3 or later. + KernelID *string `json:"OS-EXT-SRV-ATTR:kernel_id"` + + // Hostname is the hostname of the instance. + // This requires microversion 2.3 or later. + Hostname *string `json:"OS-EXT-SRV-ATTR:hostname"` + + // RootDeviceName is the name of the root device of the instance. + // This requires microversion 2.3 or later. + RootDeviceName *string `json:"OS-EXT-SRV-ATTR:root_device_name"` + + // Userdata is the userdata of the instance. + // This requires microversion 2.3 or later. + Userdata *string `json:"OS-EXT-SRV-ATTR:user_data"` + + TaskState string `json:"OS-EXT-STS:task_state"` + VmState string `json:"OS-EXT-STS:vm_state"` + PowerState PowerState `json:"OS-EXT-STS:power_state"` + + LaunchedAt time.Time `json:"-"` + TerminatedAt time.Time `json:"-"` + + // DiskConfig is the disk configuration of the server. + DiskConfig DiskConfig `json:"OS-DCF:diskConfig"` + + // AvailabilityZone is the availabilty zone the server is in. + AvailabilityZone string `json:"OS-EXT-AZ:availability_zone"` } type AttachedVolume struct { @@ -241,11 +292,53 @@ type Fault struct { Message string `json:"message"` } +type PowerState int + +type ServerExtendedStatusExt struct { + TaskState string `json:"OS-EXT-STS:task_state"` + VmState string `json:"OS-EXT-STS:vm_state"` + PowerState PowerState `json:"OS-EXT-STS:power_state"` +} + +const ( + NOSTATE = iota + RUNNING + _UNUSED1 + PAUSED + SHUTDOWN + _UNUSED2 + CRASHED + SUSPENDED +) + +func (r PowerState) String() string { + switch r { + case NOSTATE: + return "NOSTATE" + case RUNNING: + return "RUNNING" + case PAUSED: + return "PAUSED" + case SHUTDOWN: + return "SHUTDOWN" + case CRASHED: + return "CRASHED" + case SUSPENDED: + return "SUSPENDED" + case _UNUSED1, _UNUSED2: + return "_UNUSED" + default: + return "N/A" + } +} + func (r *Server) UnmarshalJSON(b []byte) error { type tmp Server var s struct { tmp - Image interface{} `json:"image"` + Image any `json:"image"` + LaunchedAt gophercloud.JSONRFC3339MilliNoZ `json:"OS-SRV-USG:launched_at"` + TerminatedAt gophercloud.JSONRFC3339MilliNoZ `json:"OS-SRV-USG:terminated_at"` } err := json.Unmarshal(b, &s) if err != nil { @@ -255,7 +348,7 @@ func (r *Server) UnmarshalJSON(b []byte) error { *r = Server(s.tmp) switch t := s.Image.(type) { - case map[string]interface{}: + case map[string]any: r.Image = t case string: switch t { @@ -264,6 +357,9 @@ func (r *Server) UnmarshalJSON(b []byte) error { } } + r.LaunchedAt = time.Time(s.LaunchedAt) + r.TerminatedAt = time.Time(s.TerminatedAt) + return err } @@ -442,3 +538,135 @@ func ExtractNetworkAddresses(r pagination.Page) ([]Address, error) { return s[key], err } + +// EvacuateResult is the response from an Evacuate operation. +// Call its ExtractAdminPass method to retrieve the admin password of the instance. +// The admin password will be an empty string if the cloud is not configured to inject admin passwords.. +type EvacuateResult struct { + gophercloud.Result +} + +func (r EvacuateResult) ExtractAdminPass() (string, error) { + var s struct { + AdminPass string `json:"adminPass"` + } + err := r.ExtractInto(&s) + if err != nil && err.Error() == "EOF" { + return "", nil + } + return s.AdminPass, err +} + +// InjectNetworkResult is the response of a InjectNetworkInfo operation. Call +// its ExtractErr method to determine if the request suceeded or failed. +type InjectNetworkResult struct { + gophercloud.ErrResult +} + +// LockResult and UnlockResult are the responses from a Lock and Unlock +// operations respectively. Call their ExtractErr methods to determine if the +// requests suceeded or failed. +type LockResult struct { + gophercloud.ErrResult +} + +type UnlockResult struct { + gophercloud.ErrResult +} + +// MigrateResult is the response from a Migrate operation. Call its ExtractErr +// method to determine if the request suceeded or failed. +type MigrateResult struct { + gophercloud.ErrResult +} + +// PauseResult is the response from a Pause operation. Call its ExtractErr +// method to determine if the request succeeded or failed. +type PauseResult struct { + gophercloud.ErrResult +} + +// UnpauseResult is the response from an Unpause operation. Call its ExtractErr +// method to determine if the request succeeded or failed. +type UnpauseResult struct { + gophercloud.ErrResult +} + +type commonResult struct { + gophercloud.Result +} + +// RescueResult is the response from a Rescue operation. Call its Extract +// method to retrieve adminPass for a rescued server. +type RescueResult struct { + commonResult +} + +// UnrescueResult is the response from an UnRescue operation. Call its ExtractErr +// method to determine if the call succeeded or failed. +type UnrescueResult struct { + gophercloud.ErrResult +} + +// Extract interprets any RescueResult as an AdminPass, if possible. +func (r RescueResult) Extract() (string, error) { + var s struct { + AdminPass string `json:"adminPass"` + } + err := r.ExtractInto(&s) + return s.AdminPass, err +} + +// ResetResult is the response of a ResetNetwork operation. Call its ExtractErr +// method to determine if the request suceeded or failed. +type ResetNetworkResult struct { + gophercloud.ErrResult +} + +// ResetResult is the response of a ResetState operation. Call its ExtractErr +// method to determine if the request suceeded or failed. +type ResetStateResult struct { + gophercloud.ErrResult +} + +// ShelveResult is the response from a Shelve operation. Call its ExtractErr +// method to determine if the request succeeded or failed. +type ShelveResult struct { + gophercloud.ErrResult +} + +// ShelveOffloadResult is the response from a Shelve operation. Call its ExtractErr +// method to determine if the request succeeded or failed. +type ShelveOffloadResult struct { + gophercloud.ErrResult +} + +// UnshelveResult is the response from Stop operation. Call its ExtractErr +// method to determine if the request succeeded or failed. +type UnshelveResult struct { + gophercloud.ErrResult +} + +// StartResult is the response from a Start operation. Call its ExtractErr +// method to determine if the request succeeded or failed. +type StartResult struct { + gophercloud.ErrResult +} + +// StopResult is the response from Stop operation. Call its ExtractErr +// method to determine if the request succeeded or failed. +type StopResult struct { + gophercloud.ErrResult +} + +// SuspendResult is the response from a Suspend operation. Call its +// ExtractErr method to determine if the request succeeded or failed. +type SuspendResult struct { + gophercloud.ErrResult +} + +// ResumeResult is the response from an Unsuspend operation. Call +// its ExtractErr method to determine if the request succeeded or failed. +type ResumeResult struct { + gophercloud.ErrResult +} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/urls.go similarity index 96% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/urls.go index e892e8d925978..36c8c90a16f22 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/urls.go @@ -1,6 +1,6 @@ package servers -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func createURL(client *gophercloud.ServiceClient) string { return client.ServiceURL("servers") diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/util.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/util.go new file mode 100644 index 0000000000000..4f611750d61f5 --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers/util.go @@ -0,0 +1,24 @@ +package servers + +import ( + "context" + + "github.com/gophercloud/gophercloud/v2" +) + +// WaitForStatus will continually poll a server until it successfully +// transitions to a specified status. +func WaitForStatus(ctx context.Context, c *gophercloud.ServiceClient, id, status string) error { + return gophercloud.WaitFor(ctx, func(ctx context.Context) (bool, error) { + current, err := Get(ctx, c, id).Extract() + if err != nil { + return false, err + } + + if current.Status == status { + return true, nil + } + + return false, nil + }) +} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/doc.go similarity index 73% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/doc.go index 857ab19cc52ed..9ab3253ef45d5 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/doc.go @@ -12,7 +12,7 @@ Example to Attach a Volume VolumeID: volumeID, } - result, err := volumeattach.Create(computeClient, serverID, createOpts).Extract() + result, err := volumeattach.Create(context.TODO(), computeClient, serverID, createOpts).Extract() if err != nil { panic(err) } @@ -22,7 +22,7 @@ Example to Detach a Volume serverID := "7ac8686c-de71-4acb-9600-ec18b1a1ed6d" volumeID := "ed081613-1c9b-4231-aa5e-ebfd4d87f983" - err := volumeattach.Delete(computeClient, serverID, volumeID).ExtractErr() + err := volumeattach.Delete(context.TODO(), computeClient, serverID, volumeID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/requests.go similarity index 71% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/requests.go index fe0b1075d6933..60d89ad7d235f 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/requests.go @@ -1,8 +1,10 @@ package volumeattach import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // List returns a Pager that allows you to iterate over a collection of @@ -15,7 +17,7 @@ func List(client *gophercloud.ServiceClient, serverID string) pagination.Pager { // CreateOptsBuilder allows extensions to add parameters to the Create request. type CreateOptsBuilder interface { - ToVolumeAttachmentCreateMap() (map[string]interface{}, error) + ToVolumeAttachmentCreateMap() (map[string]any, error) } // CreateOpts specifies volume attachment creation or import parameters. @@ -37,18 +39,18 @@ type CreateOpts struct { } // ToVolumeAttachmentCreateMap constructs a request body from CreateOpts. -func (opts CreateOpts) ToVolumeAttachmentCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToVolumeAttachmentCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "volumeAttachment") } // Create requests the creation of a new volume attachment on the server. -func Create(client *gophercloud.ServiceClient, serverID string, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, serverID string, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToVolumeAttachmentCreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(createURL(client, serverID), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, createURL(client, serverID), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -56,16 +58,16 @@ func Create(client *gophercloud.ServiceClient, serverID string, opts CreateOptsB } // Get returns public data about a previously created VolumeAttachment. -func Get(client *gophercloud.ServiceClient, serverID, volumeID string) (r GetResult) { - resp, err := client.Get(getURL(client, serverID, volumeID), &r.Body, nil) +func Get(ctx context.Context, client *gophercloud.ServiceClient, serverID, volumeID string) (r GetResult) { + resp, err := client.Get(ctx, getURL(client, serverID, volumeID), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Delete requests the deletion of a previous stored VolumeAttachment from // the server. -func Delete(client *gophercloud.ServiceClient, serverID, volumeID string) (r DeleteResult) { - resp, err := client.Delete(deleteURL(client, serverID, volumeID), nil) +func Delete(ctx context.Context, client *gophercloud.ServiceClient, serverID, volumeID string) (r DeleteResult) { + resp, err := client.Delete(ctx, deleteURL(client, serverID, volumeID), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/results.go similarity index 96% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/results.go index e5f565a35c6e8..3b817750c135d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/results.go @@ -1,8 +1,8 @@ package volumeattach import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // VolumeAttachment contains attachment information between a volume diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/urls.go similarity index 93% rename from vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/urls.go index 083f8dc4554f8..9a274294d9f54 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach/urls.go @@ -1,6 +1,6 @@ package volumeattach -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const resourcePath = "os-volume_attachments" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/doc.go similarity index 83% rename from vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/doc.go index 617fafa63148d..c1f6f93c56a1d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/doc.go @@ -10,7 +10,7 @@ Example to List RecordSets by Zone zoneID := "fff121f5-c506-410a-a69e-2d73ef9cbdbd" - allPages, err := recordsets.ListByZone(dnsClient, zoneID, listOpts).AllPages() + allPages, err := recordsets.ListByZone(dnsClient, zoneID, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -36,7 +36,7 @@ Example to Create a RecordSet zoneID := "fff121f5-c506-410a-a69e-2d73ef9cbdbd" - rr, err := recordsets.Create(dnsClient, zoneID, createOpts).Extract() + rr, err := recordsets.Create(context.TODO(), dnsClient, zoneID, createOpts).Extract() if err != nil { panic(err) } @@ -46,7 +46,7 @@ Example to Delete a RecordSet zoneID := "fff121f5-c506-410a-a69e-2d73ef9cbdbd" recordsetID := "d96ed01a-b439-4eb8-9b90-7a9f71017f7b" - err := recordsets.Delete(dnsClient, zoneID, recordsetID).ExtractErr() + err := recordsets.Delete(context.TODO(), dnsClient, zoneID, recordsetID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/requests.go similarity index 77% rename from vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/requests.go index 58414bc0dd136..49e629b39379a 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/requests.go @@ -1,8 +1,10 @@ package recordsets import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -56,8 +58,8 @@ func ListByZone(client *gophercloud.ServiceClient, zoneID string, opts ListOptsB } // Get implements the recordset Get request. -func Get(client *gophercloud.ServiceClient, zoneID string, rrsetID string) (r GetResult) { - resp, err := client.Get(rrsetURL(client, zoneID, rrsetID), &r.Body, nil) +func Get(ctx context.Context, client *gophercloud.ServiceClient, zoneID string, rrsetID string) (r GetResult) { + resp, err := client.Get(ctx, rrsetURL(client, zoneID, rrsetID), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -65,7 +67,7 @@ func Get(client *gophercloud.ServiceClient, zoneID string, rrsetID string) (r Ge // CreateOptsBuilder allows extensions to add additional attributes to the // Create request. type CreateOptsBuilder interface { - ToRecordSetCreateMap() (map[string]interface{}, error) + ToRecordSetCreateMap() (map[string]any, error) } // CreateOpts specifies the base attributes that may be used to create a @@ -88,7 +90,7 @@ type CreateOpts struct { } // ToRecordSetCreateMap formats an CreateOpts structure into a request body. -func (opts CreateOpts) ToRecordSetCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToRecordSetCreateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "") if err != nil { return nil, err @@ -98,13 +100,13 @@ func (opts CreateOpts) ToRecordSetCreateMap() (map[string]interface{}, error) { } // Create creates a recordset in a given zone. -func Create(client *gophercloud.ServiceClient, zoneID string, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, zoneID string, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToRecordSetCreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(baseURL(client, zoneID), &b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, baseURL(client, zoneID), &b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{201, 202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -114,7 +116,7 @@ func Create(client *gophercloud.ServiceClient, zoneID string, opts CreateOptsBui // UpdateOptsBuilder allows extensions to add additional attributes to the // Update request. type UpdateOptsBuilder interface { - ToRecordSetUpdateMap() (map[string]interface{}, error) + ToRecordSetUpdateMap() (map[string]any, error) } // UpdateOpts specifies the base attributes that may be updated on an existing @@ -131,7 +133,7 @@ type UpdateOpts struct { } // ToRecordSetUpdateMap formats an UpdateOpts structure into a request body. -func (opts UpdateOpts) ToRecordSetUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToRecordSetUpdateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "") if err != nil { return nil, err @@ -154,13 +156,13 @@ func (opts UpdateOpts) ToRecordSetUpdateMap() (map[string]interface{}, error) { } // Update updates a recordset in a given zone -func Update(client *gophercloud.ServiceClient, zoneID string, rrsetID string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, client *gophercloud.ServiceClient, zoneID string, rrsetID string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToRecordSetUpdateMap() if err != nil { r.Err = err return } - resp, err := client.Put(rrsetURL(client, zoneID, rrsetID), &b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Put(ctx, rrsetURL(client, zoneID, rrsetID), &b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -168,8 +170,8 @@ func Update(client *gophercloud.ServiceClient, zoneID string, rrsetID string, op } // Delete removes an existing RecordSet. -func Delete(client *gophercloud.ServiceClient, zoneID string, rrsetID string) (r DeleteResult) { - resp, err := client.Delete(rrsetURL(client, zoneID, rrsetID), &gophercloud.RequestOpts{ +func Delete(ctx context.Context, client *gophercloud.ServiceClient, zoneID string, rrsetID string) (r DeleteResult) { + resp, err := client.Delete(ctx, rrsetURL(client, zoneID, rrsetID), &gophercloud.RequestOpts{ OkCodes: []int{202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/results.go similarity index 96% rename from vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/results.go index b8c92ccff9240..4478088c45882 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/results.go @@ -4,8 +4,8 @@ import ( "encoding/json" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type commonResult struct { @@ -129,7 +129,7 @@ func (r *RecordSet) UnmarshalJSON(b []byte) error { tmp CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"` UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"` - Links map[string]interface{} `json:"links"` + Links map[string]any `json:"links"` } err := json.Unmarshal(b, &s) if err != nil { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/urls.go similarity index 86% rename from vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/urls.go index 5ec18d1bb78ee..26d9384aa0af4 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets/urls.go @@ -1,6 +1,6 @@ package recordsets -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func baseURL(c *gophercloud.ServiceClient, zoneID string) string { return c.ServiceURL("zones", zoneID, "recordsets") diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/doc.go similarity index 77% rename from vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/doc.go index 7733155bcfafd..6bd7d98cb5e79 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/doc.go @@ -8,7 +8,7 @@ Example to List Zones Email: "jdoe@example.com", } - allPages, err := zones.List(dnsClient, listOpts).AllPages() + allPages, err := zones.List(dnsClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -32,7 +32,7 @@ Example to Create a Zone Description: "This is a zone.", } - zone, err := zones.Create(dnsClient, createOpts).Extract() + zone, err := zones.Create(context.TODO(), dnsClient, createOpts).Extract() if err != nil { panic(err) } @@ -40,7 +40,7 @@ Example to Create a Zone Example to Delete a Zone zoneID := "99d10f68-5623-4491-91a0-6daafa32b60e" - err := zones.Delete(dnsClient, zoneID).ExtractErr() + err := zones.Delete(context.TODO(), dnsClient, zoneID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/requests.go similarity index 79% rename from vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/requests.go index 7fa25359ff4e6..fba4371cedc91 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/requests.go @@ -1,8 +1,10 @@ package zones import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add parameters to the List request. @@ -54,8 +56,8 @@ func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pa } // Get returns information about a zone, given its ID. -func Get(client *gophercloud.ServiceClient, zoneID string) (r GetResult) { - resp, err := client.Get(zoneURL(client, zoneID), &r.Body, nil) +func Get(ctx context.Context, client *gophercloud.ServiceClient, zoneID string) (r GetResult) { + resp, err := client.Get(ctx, zoneURL(client, zoneID), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -63,7 +65,7 @@ func Get(client *gophercloud.ServiceClient, zoneID string) (r GetResult) { // CreateOptsBuilder allows extensions to add additional attributes to the // Create request. type CreateOptsBuilder interface { - ToZoneCreateMap() (map[string]interface{}, error) + ToZoneCreateMap() (map[string]any, error) } // CreateOpts specifies the attributes used to create a zone. @@ -91,7 +93,7 @@ type CreateOpts struct { } // ToZoneCreateMap formats an CreateOpts structure into a request body. -func (opts CreateOpts) ToZoneCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToZoneCreateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "") if err != nil { return nil, err @@ -105,13 +107,13 @@ func (opts CreateOpts) ToZoneCreateMap() (map[string]interface{}, error) { } // Create implements a zone create request. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToZoneCreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(baseURL(client), &b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, baseURL(client), &b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{201, 202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -121,7 +123,7 @@ func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r Create // UpdateOptsBuilder allows extensions to add additional attributes to the // Update request. type UpdateOptsBuilder interface { - ToZoneUpdateMap() (map[string]interface{}, error) + ToZoneUpdateMap() (map[string]any, error) } // UpdateOpts specifies the attributes to update a zone. @@ -140,7 +142,7 @@ type UpdateOpts struct { } // ToZoneUpdateMap formats an UpdateOpts structure into a request body. -func (opts UpdateOpts) ToZoneUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToZoneUpdateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "") if err != nil { return nil, err @@ -154,13 +156,13 @@ func (opts UpdateOpts) ToZoneUpdateMap() (map[string]interface{}, error) { } // Update implements a zone update request. -func Update(client *gophercloud.ServiceClient, zoneID string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, client *gophercloud.ServiceClient, zoneID string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToZoneUpdateMap() if err != nil { r.Err = err return } - resp, err := client.Patch(zoneURL(client, zoneID), &b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Patch(ctx, zoneURL(client, zoneID), &b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -168,8 +170,8 @@ func Update(client *gophercloud.ServiceClient, zoneID string, opts UpdateOptsBui } // Delete implements a zone delete request. -func Delete(client *gophercloud.ServiceClient, zoneID string) (r DeleteResult) { - resp, err := client.Delete(zoneURL(client, zoneID), &gophercloud.RequestOpts{ +func Delete(ctx context.Context, client *gophercloud.ServiceClient, zoneID string) (r DeleteResult) { + resp, err := client.Delete(ctx, zoneURL(client, zoneID), &gophercloud.RequestOpts{ OkCodes: []int{202}, JSONResponse: &r.Body, }) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/results.go similarity index 95% rename from vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/results.go index c84c722c08186..ae2f27dbc53d8 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/results.go @@ -5,8 +5,8 @@ import ( "strconv" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type commonResult struct { @@ -128,7 +128,7 @@ type Zone struct { // Links includes HTTP references to the itself, useful for passing along // to other APIs that might want a server reference. - Links map[string]interface{} `json:"links"` + Links map[string]any `json:"links"` } func (r *Zone) UnmarshalJSON(b []byte) error { @@ -138,7 +138,7 @@ func (r *Zone) UnmarshalJSON(b []byte) error { CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"` UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"` TransferredAt gophercloud.JSONRFC3339MilliNoZ `json:"transferred_at"` - Serial interface{} `json:"serial"` + Serial any `json:"serial"` } err := json.Unmarshal(b, &s) if err != nil { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/urls.go similarity index 81% rename from vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/urls.go index 9bef7058096e7..d157b30ef3819 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones/urls.go @@ -1,6 +1,6 @@ package zones -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func baseURL(c *gophercloud.ServiceClient) string { return c.ServiceURL("zones") diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/doc.go similarity index 86% rename from vendor/github.com/gophercloud/gophercloud/openstack/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/doc.go index af4bd512bf505..4d89fb5d0b77d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/doc.go @@ -6,7 +6,7 @@ OpenStack cloud and for provisioning various service-level clients. Example of Creating a Service Client ao, err := openstack.AuthOptionsFromEnv() - provider, err := openstack.AuthenticatedClient(ao) + provider, err := openstack.AuthenticatedClient(context.TODO(), ao) client, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{ Region: os.Getenv("OS_REGION_NAME"), }) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/endpoint_location.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/endpoint_location.go similarity index 95% rename from vendor/github.com/gophercloud/gophercloud/openstack/endpoint_location.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/endpoint_location.go index 509700790efe1..2cdbd3e7f700d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/endpoint_location.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/endpoint_location.go @@ -1,9 +1,9 @@ package openstack import ( - "github.com/gophercloud/gophercloud" - tokens2 "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens" - tokens3 "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" + "github.com/gophercloud/gophercloud/v2" + tokens2 "github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens" + tokens3 "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens" ) /* diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/errors.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/errors.go similarity index 97% rename from vendor/github.com/gophercloud/gophercloud/openstack/errors.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/errors.go index cba6ae5f00c7c..f5273483ec287 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/errors.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/errors.go @@ -3,7 +3,7 @@ package openstack import ( "fmt" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) // ErrEndpointNotFound is the error when no suitable endpoint can be found diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/doc.go similarity index 81% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/doc.go index 348dd20839679..b14d69a564f3a 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/doc.go @@ -12,7 +12,7 @@ Example to List Tenants Limit: 2, } - allPages, err := tenants.List(identityClient, listOpts).AllPages() + allPages, err := tenants.List(identityClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -34,7 +34,7 @@ Example to Create a Tenant Enabled: gophercloud.Enabled, } - tenant, err := tenants.Create(identityClient, createOpts).Extract() + tenant, err := tenants.Create(context.TODO(), identityClient, createOpts).Extract() if err != nil { panic(err) } @@ -48,7 +48,7 @@ Example to Update a Tenant Enabled: gophercloud.Disabled, } - tenant, err := tenants.Update(identityClient, tenantID, updateOpts).Extract() + tenant, err := tenants.Update(context.TODO(), identityClient, tenantID, updateOpts).Extract() if err != nil { panic(err) } @@ -57,7 +57,7 @@ Example to Delete a Tenant tenantID := "e6db6ed6277c461a853458589063b295" - err := tenants.Delete(identitYClient, tenantID).ExtractErr() + err := tenants.Delete(context.TODO(), identitYClient, tenantID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/requests.go similarity index 72% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/requests.go index f16df38e5ece4..a08980df2c0b5 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/requests.go @@ -1,8 +1,10 @@ package tenants import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOpts filters the Tenants that are returned by the List call. @@ -44,23 +46,23 @@ type CreateOpts struct { // CreateOptsBuilder enables extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToTenantCreateMap() (map[string]interface{}, error) + ToTenantCreateMap() (map[string]any, error) } // ToTenantCreateMap assembles a request body based on the contents of // a CreateOpts. -func (opts CreateOpts) ToTenantCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToTenantCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "tenant") } // Create is the operation responsible for creating new tenant. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToTenantCreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, createURL(client), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 201}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -68,8 +70,8 @@ func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r Create } // Get requests details on a single tenant by ID. -func Get(client *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := client.Get(getURL(client, id), &r.Body, nil) +func Get(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := client.Get(ctx, getURL(client, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -77,7 +79,7 @@ func Get(client *gophercloud.ServiceClient, id string) (r GetResult) { // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToTenantUpdateMap() (map[string]interface{}, error) + ToTenantUpdateMap() (map[string]any, error) } // UpdateOpts specifies the base attributes that may be updated on an existing @@ -94,18 +96,18 @@ type UpdateOpts struct { } // ToTenantUpdateMap formats an UpdateOpts structure into a request body. -func (opts UpdateOpts) ToTenantUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToTenantUpdateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "tenant") } // Update is the operation responsible for updating exist tenants by their TenantID. -func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToTenantUpdateMap() if err != nil { r.Err = err return } - resp, err := client.Put(updateURL(client, id), &b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Put(ctx, updateURL(client, id), &b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -113,8 +115,8 @@ func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder } // Delete is the operation responsible for permanently deleting a tenant. -func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := client.Delete(deleteURL(client, id), nil) +func Delete(ctx context.Context, client *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := client.Delete(ctx, deleteURL(client, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/results.go similarity index 96% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/results.go index 2daff984031a7..2569ffec05c48 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/results.go @@ -1,8 +1,8 @@ package tenants import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // Tenant is a grouping of users in the identity service. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/urls.go similarity index 92% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/urls.go index 0f026690790cd..4c2aaf3843b39 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants/urls.go @@ -1,6 +1,6 @@ package tenants -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func listURL(client *gophercloud.ServiceClient) string { return client.ServiceURL("tenants") diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/doc.go similarity index 76% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/doc.go index 5375eea872677..7cfc3673003f6 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/doc.go @@ -12,7 +12,7 @@ Example to Create an Unscoped Token from a Password Password: "pass" } - token, err := tokens.Create(identityClient, authOpts).ExtractToken() + token, err := tokens.Create(context.TODO(), identityClient, authOpts).ExtractToken() if err != nil { panic(err) } @@ -25,7 +25,7 @@ Example to Create a Token from a Tenant ID and Password TenantID: "fc394f2ab2df4114bde39905f800dc57" } - token, err := tokens.Create(identityClient, authOpts).ExtractToken() + token, err := tokens.Create(context.TODO(), identityClient, authOpts).ExtractToken() if err != nil { panic(err) } @@ -38,7 +38,7 @@ Example to Create a Token from a Tenant Name and Password TenantName: "tenantname" } - token, err := tokens.Create(identityClient, authOpts).ExtractToken() + token, err := tokens.Create(context.TODO(), identityClient, authOpts).ExtractToken() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/requests.go similarity index 82% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/requests.go index 84f16c3fc28b6..5afa8fd26c563 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/requests.go @@ -1,6 +1,10 @@ package tokens -import "github.com/gophercloud/gophercloud" +import ( + "context" + + "github.com/gophercloud/gophercloud/v2" +) // PasswordCredentialsV2 represents the required options to authenticate // with a username and password. @@ -37,7 +41,8 @@ type AuthOptionsV2 struct { type AuthOptionsBuilder interface { // ToTokenCreateMap assembles the Create request body, returning an error // if parameters are missing or inconsistent. - ToTokenV2CreateMap() (map[string]interface{}, error) + ToTokenV2CreateMap() (map[string]any, error) + CanReauth() bool } // AuthOptions are the valid options for Openstack Identity v2 authentication. @@ -53,7 +58,7 @@ type AuthOptions struct { } // ToTokenV2CreateMap builds a token request body from the given AuthOptions. -func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error) { +func (opts AuthOptions) ToTokenV2CreateMap() (map[string]any, error) { v2Opts := AuthOptionsV2{ TenantID: opts.TenantID, TenantName: opts.TenantName, @@ -77,17 +82,21 @@ func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error) { return b, nil } +func (opts AuthOptions) CanReauth() bool { + return opts.AllowReauth +} + // Create authenticates to the identity service and attempts to acquire a Token. // Generally, rather than interact with this call directly, end users should // call openstack.AuthenticatedClient(), which abstracts all of the gory details // about navigating service catalogs and such. -func Create(client *gophercloud.ServiceClient, auth AuthOptionsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, auth AuthOptionsBuilder) (r CreateResult) { b, err := auth.ToTokenV2CreateMap() if err != nil { r.Err = err return } - resp, err := client.Post(CreateURL(client), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, CreateURL(client), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 203}, OmitHeaders: []string{"X-Auth-Token"}, }) @@ -96,8 +105,8 @@ func Create(client *gophercloud.ServiceClient, auth AuthOptionsBuilder) (r Creat } // Get validates and retrieves information for user's token. -func Get(client *gophercloud.ServiceClient, token string) (r GetResult) { - resp, err := client.Get(GetURL(client, token), &r.Body, &gophercloud.RequestOpts{ +func Get(ctx context.Context, client *gophercloud.ServiceClient, token string) (r GetResult) { + resp, err := client.Get(ctx, GetURL(client, token), &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 203}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/results.go similarity index 97% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/results.go index ee5da37f465de..516371ee8551d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/results.go @@ -3,8 +3,8 @@ package tokens import ( "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants" ) // Token provides only the most basic information related to an authentication diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/urls.go similarity index 87% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/urls.go index ee0a28f2004c2..845cdb58b2511 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tokens/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens/urls.go @@ -1,6 +1,6 @@ package tokens -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" // CreateURL generates the URL used to create new Tokens. func CreateURL(client *gophercloud.ServiceClient) string { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens/doc.go similarity index 82% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens/doc.go index a30d0faf3a921..bd74473da105b 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens/doc.go @@ -13,7 +13,7 @@ Example to Create a Token From an EC2 access and secret keys Secret: "18f4f6761ada4e3795fa5273c30349b9", } - token, err := ec2tokens.Create(identityClient, authOptions).ExtractToken() + token, err := ec2tokens.Create(context.TODO(), identityClient, authOptions).ExtractToken() if err != nil { panic(err) } @@ -32,7 +32,7 @@ Example to auth a client using EC2 access and secret keys AllowReauth: true, } - err = openstack.AuthenticateV3(client, authOptions, gophercloud.EndpointOpts{}) + err = openstack.AuthenticateV3(context.TODO(), client, authOptions, gophercloud.EndpointOpts{}) if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens/requests.go similarity index 88% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens/requests.go index 32ba0e621d914..5b1f3d6882201 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens/requests.go @@ -1,19 +1,20 @@ package ec2tokens import ( + "context" "crypto/hmac" + "crypto/rand" "crypto/sha1" "crypto/sha256" "encoding/hex" "fmt" - "math/rand" "net/url" "sort" "strings" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens" ) const ( @@ -66,7 +67,7 @@ type AuthOptions struct { // Signature can be either a []byte (encoded to base64 automatically) or // a string. You can set the singature explicitly, when you already know // it. In this case default Params won't be automatically set. Optional. - Signature interface{} `json:"signature"` + Signature any `json:"signature"` // BodyHash is a HTTP request body sha256 hash. When nil and Signature // is not set, a random hash is generated. Optional. BodyHash *string `json:"body_hash"` @@ -204,13 +205,13 @@ func EC2CredentialsBuildAuthorizationHeaderV4(opts AuthOptions, signedHeaders st // ToTokenV3ScopeMap is a dummy method to satisfy tokens.AuthOptionsBuilder // interface. -func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) { +func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]any, error) { return nil, nil } // ToTokenV3HeadersMap allows AuthOptions to satisfy the AuthOptionsBuilder // interface in the v3 tokens package. -func (opts *AuthOptions) ToTokenV3HeadersMap(map[string]interface{}) (map[string]string, error) { +func (opts *AuthOptions) ToTokenV3HeadersMap(map[string]any) (map[string]string, error) { return nil, nil } @@ -220,7 +221,7 @@ func (opts *AuthOptions) CanReauth() bool { } // ToTokenV3CreateMap formats an AuthOptions into a create request. -func (opts *AuthOptions) ToTokenV3CreateMap(map[string]interface{}) (map[string]interface{}, error) { +func (opts *AuthOptions) ToTokenV3CreateMap(map[string]any) (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "credentials") if err != nil { return nil, err @@ -231,18 +232,14 @@ func (opts *AuthOptions) ToTokenV3CreateMap(map[string]interface{}) (map[string] } // calculate signature, when it is not set - c, _ := b["credentials"].(map[string]interface{}) + c, _ := b["credentials"].(map[string]any) h := interfaceToMap(c, "headers") p := interfaceToMap(c, "params") // detect and process a signature v2 if v, ok := p["SignatureVersion"]; ok && v == "2" { - if _, ok := c["body_hash"]; ok { - delete(c, "body_hash") - } - if _, ok := c["headers"]; ok { - delete(c, "headers") - } + delete(c, "body_hash") + delete(c, "headers") if v, ok := p["SignatureMethod"]; ok { // params is a map of strings strToSign := EC2CredentialsBuildStringToSignV2(*opts) @@ -268,12 +265,16 @@ func (opts *AuthOptions) ToTokenV3CreateMap(map[string]interface{}) (map[string] if opts.Timestamp != nil { date = *opts.Timestamp } - if v, _ := c["body_hash"]; v == nil { + if v := c["body_hash"]; v == nil { // when body_hash is not set, generate a random one - c["body_hash"] = randomBodyHash() + bodyHash, err := randomBodyHash() + if err != nil { + return nil, fmt.Errorf("failed to generate random hash") + } + c["body_hash"] = bodyHash } - signedHeaders, _ := h["X-Amz-SignedHeaders"] + signedHeaders := h["X-Amz-SignedHeaders"] stringToSign := EC2CredentialsBuildStringToSignV4(*opts, signedHeaders, c["body_hash"].(string), date) key := EC2CredentialsBuildSignatureKeyV4(opts.Secret, opts.Region, opts.Service, date) @@ -288,7 +289,7 @@ func (opts *AuthOptions) ToTokenV3CreateMap(map[string]interface{}) (map[string] } // Create authenticates and either generates a new token from EC2 credentials -func Create(c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) { b, err := opts.ToTokenV3CreateMap(nil) if err != nil { r.Err = err @@ -298,7 +299,7 @@ func Create(c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tok // delete "token" element, since it is used in s3tokens deleteBodyElements(b, "token") - resp, err := c.Post(ec2tokensURL(c), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Post(ctx, ec2tokensURL(c), b, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: map[string]string{"X-Auth-Token": ""}, OkCodes: []int{200}, }) @@ -308,7 +309,7 @@ func Create(c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tok // ValidateS3Token authenticates an S3 request using EC2 credentials. Doesn't // generate a new token ID, but returns a tokens.CreateResult. -func ValidateS3Token(c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) { +func ValidateS3Token(ctx context.Context, c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) { b, err := opts.ToTokenV3CreateMap(nil) if err != nil { r.Err = err @@ -318,7 +319,7 @@ func ValidateS3Token(c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilde // delete unused element, since it is used in ec2tokens only deleteBodyElements(b, "body_hash", "headers", "host", "params", "path", "verb") - resp, err := c.Post(s3tokensURL(c), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Post(ctx, s3tokensURL(c), b, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: map[string]string{"X-Auth-Token": ""}, OkCodes: []int{200}, }) @@ -343,18 +344,20 @@ func sumHMAC256(key []byte, data []byte) []byte { } // randomBodyHash is a func to generate a random sha256 hexdigest. -func randomBodyHash() string { +func randomBodyHash() (string, error) { h := make([]byte, 64) - rand.Read(h) - return hex.EncodeToString(h) + if _, err := rand.Read(h); err != nil { + return "", err + } + return hex.EncodeToString(h), nil } // interfaceToMap is a func used to represent a "credentials" map element as a // "map[string]string" -func interfaceToMap(c map[string]interface{}, key string) map[string]string { - // convert map[string]interface{} to map[string]string +func interfaceToMap(c map[string]any, key string) map[string]string { + // convert map[string]any to map[string]string m := make(map[string]string) - if v, _ := c[key].(map[string]interface{}); v != nil { + if v, _ := c[key].(map[string]any); v != nil { for k, v := range v { m[k] = v.(string) } @@ -366,12 +369,10 @@ func interfaceToMap(c map[string]interface{}, key string) map[string]string { } // deleteBodyElements deletes map body elements -func deleteBodyElements(b map[string]interface{}, elements ...string) { - if c, ok := b["credentials"].(map[string]interface{}); ok { +func deleteBodyElements(b map[string]any, elements ...string) { + if c, ok := b["credentials"].(map[string]any); ok { for _, k := range elements { - if _, ok := c[k]; ok { - delete(c, k) - } + delete(c, k) } } } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens/urls.go similarity index 81% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens/urls.go index 84b33b282ead1..91add91eb004e 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens/urls.go @@ -1,6 +1,6 @@ package ec2tokens -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func ec2tokensURL(c *gophercloud.ServiceClient) string { return c.ServiceURL("ec2tokens") diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/doc.go similarity index 81% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/doc.go index 4294ef6c89853..c0cfa924aa6f9 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/doc.go @@ -6,7 +6,7 @@ Example to Create an OAuth1 Consumer createConsumerOpts := oauth1.CreateConsumerOpts{ Description: "My consumer", } - consumer, err := oauth1.CreateConsumer(identityClient, createConsumerOpts).Extract() + consumer, err := oauth1.CreateConsumer(context.TODO(), identityClient, createConsumerOpts).Extract() if err != nil { panic(err) } @@ -22,7 +22,7 @@ Example to Request an unauthorized OAuth1 token OAuthSignatureMethod: oauth1.HMACSHA1, RequestedProjectID: projectID, } - requestToken, err := oauth1.RequestToken(identityClient, requestTokenOpts).Extract() + requestToken, err := oauth1.RequestToken(context.TODO(), identityClient, requestTokenOpts).Extract() if err != nil { panic(err) } @@ -37,7 +37,7 @@ Example to Authorize an unauthorized OAuth1 token {Name: "member"}, }, } - authToken, err := oauth1.AuthorizeToken(identityClient, requestToken.OAuthToken, authorizeTokenOpts).Extract() + authToken, err := oauth1.AuthorizeToken(context.TODO(), identityClient, requestToken.OAuthToken, authorizeTokenOpts).Extract() if err != nil { panic(err) } @@ -54,7 +54,7 @@ Example to Create an OAuth1 Access Token OAuthVerifier: authToken.OAuthVerifier, OAuthSignatureMethod: oauth1.HMACSHA1, } - accessToken, err := oauth1.CreateAccessToken(identityClient, accessTokenOpts).Extract() + accessToken, err := oauth1.CreateAccessToken(context.TODO(), identityClient, accessTokenOpts).Extract() if err != nil { panic(err) } @@ -64,7 +64,7 @@ Example to Create an OAuth1 Access Token Example to List User's OAuth1 Access Tokens - allPages, err := oauth1.ListAccessTokens(identityClient, userID).AllPages() + allPages, err := oauth1.ListAccessTokens(identityClient, userID).AllPages(context.TODO()) if err != nil { panic(err) } @@ -93,7 +93,7 @@ Example to Authenticate a client using OAuth1 method OAuthTokenSecret: accessToken.OAuthTokenSecret, OAuthSignatureMethod: oauth1.HMACSHA1, } - err = openstack.AuthenticateV3(client, authOptions, gophercloud.EndpointOpts{}) + err = openstack.AuthenticateV3(context.TODO(), client, authOptions, gophercloud.EndpointOpts{}) if err != nil { panic(err) } @@ -114,7 +114,7 @@ Example to Create a Token using OAuth1 method OAuthTokenSecret: accessToken.OAuthTokenSecret, OAuthSignatureMethod: oauth1.HMACSHA1, } - err := tokens.Create(identityClient, createOpts).ExtractInto(&oauth1Token) + err := tokens.Create(context.TODO(), identityClient, createOpts).ExtractInto(&oauth1Token) if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/requests.go similarity index 83% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/requests.go index 028b5a45bd7b1..8c66b36e20c49 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/requests.go @@ -1,11 +1,12 @@ package oauth1 import ( + "context" "crypto/hmac" "crypto/sha1" "encoding/base64" "fmt" - "io/ioutil" + "io" "math/rand" "net/url" "sort" @@ -13,9 +14,9 @@ import ( "strings" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens" + "github.com/gophercloud/gophercloud/v2/pagination" ) // Type SignatureMethod is a OAuth1 SignatureMethod type. @@ -71,7 +72,7 @@ type AuthOptions struct { // ToTokenV3HeadersMap builds the headers required for an OAuth1-based create // request. -func (opts AuthOptions) ToTokenV3HeadersMap(headerOpts map[string]interface{}) (map[string]string, error) { +func (opts AuthOptions) ToTokenV3HeadersMap(headerOpts map[string]any) (map[string]string, error) { q, err := buildOAuth1QueryString(opts, opts.OAuthTimestamp, "") if err != nil { return nil, err @@ -96,7 +97,7 @@ func (opts AuthOptions) ToTokenV3HeadersMap(headerOpts map[string]interface{}) ( // ToTokenV3ScopeMap allows AuthOptions to satisfy the tokens.AuthOptionsBuilder // interface. -func (opts AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) { +func (opts AuthOptions) ToTokenV3ScopeMap() (map[string]any, error) { return nil, nil } @@ -107,7 +108,7 @@ func (opts AuthOptions) CanReauth() bool { } // ToTokenV3CreateMap builds a create request body. -func (opts AuthOptions) ToTokenV3CreateMap(map[string]interface{}) (map[string]interface{}, error) { +func (opts AuthOptions) ToTokenV3CreateMap(map[string]any) (map[string]any, error) { // identityReq defines the "identity" portion of an OAuth1-based authentication // create request body. type identityReq struct { @@ -133,16 +134,16 @@ func (opts AuthOptions) ToTokenV3CreateMap(map[string]interface{}) (map[string]i return gophercloud.BuildRequestBody(req, "") } -// Create authenticates and either generates a new OpenStack token from an -// OAuth1 token. -func Create(client *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) { +// Create authenticates and either generates a new OpenStack token +// from an OAuth1 token. +func Create(ctx context.Context, client *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) { b, err := opts.ToTokenV3CreateMap(nil) if err != nil { r.Err = err return } - headerOpts := map[string]interface{}{ + headerOpts := map[string]any{ "method": "POST", "url": authURL(client), } @@ -153,7 +154,7 @@ func Create(client *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) ( return } - resp, err := client.Post(authURL(client), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, authURL(client), b, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{201}, }) @@ -164,7 +165,7 @@ func Create(client *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) ( // CreateConsumerOptsBuilder allows extensions to add additional parameters to // the CreateConsumer request. type CreateConsumerOptsBuilder interface { - ToOAuth1CreateConsumerMap() (map[string]interface{}, error) + ToOAuth1CreateConsumerMap() (map[string]any, error) } // CreateConsumerOpts provides options used to create a new Consumer. @@ -174,27 +175,27 @@ type CreateConsumerOpts struct { } // ToOAuth1CreateConsumerMap formats a CreateConsumerOpts into a create request. -func (opts CreateConsumerOpts) ToOAuth1CreateConsumerMap() (map[string]interface{}, error) { +func (opts CreateConsumerOpts) ToOAuth1CreateConsumerMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "consumer") } -// Create creates a new Consumer. -func CreateConsumer(client *gophercloud.ServiceClient, opts CreateConsumerOptsBuilder) (r CreateConsumerResult) { +// CreateConsumer creates a new Consumer. +func CreateConsumer(ctx context.Context, client *gophercloud.ServiceClient, opts CreateConsumerOptsBuilder) (r CreateConsumerResult) { b, err := opts.ToOAuth1CreateConsumerMap() if err != nil { r.Err = err return } - resp, err := client.Post(consumersURL(client), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, consumersURL(client), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{201}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } -// Delete deletes a Consumer. -func DeleteConsumer(client *gophercloud.ServiceClient, id string) (r DeleteConsumerResult) { - resp, err := client.Delete(consumerURL(client, id), nil) +// DeleteConsumer deletes a Consumer. +func DeleteConsumer(ctx context.Context, client *gophercloud.ServiceClient, id string) (r DeleteConsumerResult) { + resp, err := client.Delete(ctx, consumerURL(client, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -207,8 +208,8 @@ func ListConsumers(client *gophercloud.ServiceClient) pagination.Pager { } // GetConsumer retrieves details on a single Consumer by ID. -func GetConsumer(client *gophercloud.ServiceClient, id string) (r GetConsumerResult) { - resp, err := client.Get(consumerURL(client, id), &r.Body, nil) +func GetConsumer(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetConsumerResult) { + resp, err := client.Get(ctx, consumerURL(client, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -221,18 +222,18 @@ type UpdateConsumerOpts struct { // ToOAuth1UpdateConsumerMap formats an UpdateConsumerOpts into a consumer update // request. -func (opts UpdateConsumerOpts) ToOAuth1UpdateConsumerMap() (map[string]interface{}, error) { +func (opts UpdateConsumerOpts) ToOAuth1UpdateConsumerMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "consumer") } // UpdateConsumer updates an existing Consumer. -func UpdateConsumer(client *gophercloud.ServiceClient, id string, opts UpdateConsumerOpts) (r UpdateConsumerResult) { +func UpdateConsumer(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateConsumerOpts) (r UpdateConsumerResult) { b, err := opts.ToOAuth1UpdateConsumerMap() if err != nil { r.Err = err return } - resp, err := client.Patch(consumerURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Patch(ctx, consumerURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -298,14 +299,14 @@ func (opts RequestTokenOpts) ToOAuth1RequestTokenHeaders(method, u string) (map[ } // RequestToken requests an unauthorized OAuth1 Token. -func RequestToken(client *gophercloud.ServiceClient, opts RequestTokenOptsBuilder) (r TokenResult) { +func RequestToken(ctx context.Context, client *gophercloud.ServiceClient, opts RequestTokenOptsBuilder) (r TokenResult) { h, err := opts.ToOAuth1RequestTokenHeaders("POST", requestTokenURL(client)) if err != nil { r.Err = err return } - resp, err := client.Post(requestTokenURL(client), nil, nil, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, requestTokenURL(client), nil, nil, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{201}, KeepResponseBody: true, @@ -319,14 +320,14 @@ func RequestToken(client *gophercloud.ServiceClient, opts RequestTokenOptsBuilde r.Err = fmt.Errorf("unsupported Content-Type: %q", v) return } - r.Body, r.Err = ioutil.ReadAll(resp.Body) + r.Body, r.Err = io.ReadAll(resp.Body) return } // AuthorizeTokenOptsBuilder allows extensions to add additional parameters to // the AuthorizeToken request. type AuthorizeTokenOptsBuilder interface { - ToOAuth1AuthorizeTokenMap() (map[string]interface{}, error) + ToOAuth1AuthorizeTokenMap() (map[string]any, error) } // AuthorizeTokenOpts provides options used to authorize a request token. @@ -342,7 +343,7 @@ type Role struct { // ToOAuth1AuthorizeTokenMap formats an AuthorizeTokenOpts into an authorize token // request. -func (opts AuthorizeTokenOpts) ToOAuth1AuthorizeTokenMap() (map[string]interface{}, error) { +func (opts AuthorizeTokenOpts) ToOAuth1AuthorizeTokenMap() (map[string]any, error) { for _, r := range opts.Roles { if r == (Role{}) { return nil, fmt.Errorf("role must not be empty") @@ -352,13 +353,13 @@ func (opts AuthorizeTokenOpts) ToOAuth1AuthorizeTokenMap() (map[string]interface } // AuthorizeToken authorizes an unauthorized consumer token. -func AuthorizeToken(client *gophercloud.ServiceClient, id string, opts AuthorizeTokenOptsBuilder) (r AuthorizeTokenResult) { +func AuthorizeToken(ctx context.Context, client *gophercloud.ServiceClient, id string, opts AuthorizeTokenOptsBuilder) (r AuthorizeTokenResult) { b, err := opts.ToOAuth1AuthorizeTokenMap() if err != nil { r.Err = err return } - resp, err := client.Put(authorizeTokenURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Put(ctx, authorizeTokenURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -426,14 +427,14 @@ func (opts CreateAccessTokenOpts) ToOAuth1CreateAccessTokenHeaders(method, u str } // CreateAccessToken creates a new OAuth1 Access Token -func CreateAccessToken(client *gophercloud.ServiceClient, opts CreateAccessTokenOptsBuilder) (r TokenResult) { +func CreateAccessToken(ctx context.Context, client *gophercloud.ServiceClient, opts CreateAccessTokenOptsBuilder) (r TokenResult) { h, err := opts.ToOAuth1CreateAccessTokenHeaders("POST", createAccessTokenURL(client)) if err != nil { r.Err = err return } - resp, err := client.Post(createAccessTokenURL(client), nil, nil, &gophercloud.RequestOpts{ + resp, err := client.Post(ctx, createAccessTokenURL(client), nil, nil, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{201}, KeepResponseBody: true, @@ -447,20 +448,20 @@ func CreateAccessToken(client *gophercloud.ServiceClient, opts CreateAccessToken r.Err = fmt.Errorf("unsupported Content-Type: %q", v) return } - r.Body, r.Err = ioutil.ReadAll(resp.Body) + r.Body, r.Err = io.ReadAll(resp.Body) return } // GetAccessToken retrieves details on a single OAuth1 access token by an ID. -func GetAccessToken(client *gophercloud.ServiceClient, userID string, id string) (r GetAccessTokenResult) { - resp, err := client.Get(userAccessTokenURL(client, userID, id), &r.Body, nil) +func GetAccessToken(ctx context.Context, client *gophercloud.ServiceClient, userID string, id string) (r GetAccessTokenResult) { + resp, err := client.Get(ctx, userAccessTokenURL(client, userID, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // RevokeAccessToken revokes an OAuth1 access token. -func RevokeAccessToken(client *gophercloud.ServiceClient, userID string, id string) (r RevokeAccessTokenResult) { - resp, err := client.Delete(userAccessTokenURL(client, userID, id), nil) +func RevokeAccessToken(ctx context.Context, client *gophercloud.ServiceClient, userID string, id string) (r RevokeAccessTokenResult) { + resp, err := client.Delete(ctx, userAccessTokenURL(client, userID, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -483,8 +484,8 @@ func ListAccessTokenRoles(client *gophercloud.ServiceClient, userID string, id s // GetAccessTokenRole retrieves details on a single OAuth1 access token role by // an ID. -func GetAccessTokenRole(client *gophercloud.ServiceClient, userID string, id string, roleID string) (r GetAccessTokenRoleResult) { - resp, err := client.Get(userAccessTokenRoleURL(client, userID, id, roleID), &r.Body, nil) +func GetAccessTokenRole(ctx context.Context, client *gophercloud.ServiceClient, userID string, id string, roleID string) (r GetAccessTokenRoleResult) { + resp, err := client.Get(ctx, userAccessTokenRoleURL(client, userID, id, roleID), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -493,7 +494,7 @@ func GetAccessTokenRole(client *gophercloud.ServiceClient, userID string, id str // buildOAuth1QueryString builds a URLEncoded parameters string specific for // OAuth1-based requests. -func buildOAuth1QueryString(opts interface{}, timestamp *time.Time, callback string) (*url.URL, error) { +func buildOAuth1QueryString(opts any, timestamp *time.Time, callback string) (*url.URL, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return nil, err diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/results.go similarity index 98% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/results.go index 2a37061627683..2ed75bd74a188 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/results.go @@ -5,8 +5,8 @@ import ( "net/url" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // Consumer represents a delegated authorization request between two diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/urls.go similarity index 96% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/urls.go index 9b51d53b31d1c..c8dc02e5da230 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1/urls.go @@ -1,6 +1,6 @@ package oauth1 -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func consumersURL(c *gophercloud.ServiceClient) string { return c.ServiceURL("OS-OAUTH1", "consumers") diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/doc.go similarity index 74% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/doc.go index de74c82ecd218..c711d0c28e445 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/doc.go @@ -12,7 +12,7 @@ Example to Create a Token From a Username and Password Password: "password", } - token, err := tokens.Create(identityClient, authOptions).ExtractToken() + token, err := tokens.Create(context.TODO(), identityClient, authOptions).ExtractToken() if err != nil { panic(err) } @@ -25,7 +25,7 @@ Example to Create a Token From a Username, Password, and Domain DomainID: "default", } - token, err := tokens.Create(identityClient, authOptions).ExtractToken() + token, err := tokens.Create(context.TODO(), identityClient, authOptions).ExtractToken() if err != nil { panic(err) } @@ -36,7 +36,7 @@ Example to Create a Token From a Username, Password, and Domain DomainName: "default", } - token, err = tokens.Create(identityClient, authOptions).ExtractToken() + token, err = tokens.Create(context.TODO(), identityClient, authOptions).ExtractToken() if err != nil { panic(err) } @@ -47,7 +47,7 @@ Example to Create a Token From a Token TokenID: "token_id", } - token, err := tokens.Create(identityClient, authOptions).ExtractToken() + token, err := tokens.Create(context.TODO(), identityClient, authOptions).ExtractToken() if err != nil { panic(err) } @@ -64,7 +64,7 @@ Example to Create a Token from a Username and Password with Project ID Scope Password: "password", } - token, err = tokens.Create(identityClient, authOptions).ExtractToken() + token, err = tokens.Create(context.TODO(), identityClient, authOptions).ExtractToken() if err != nil { panic(err) } @@ -81,7 +81,7 @@ Example to Create a Token from a Username and Password with Domain ID Scope Password: "password", } - token, err = tokens.Create(identityClient, authOptions).ExtractToken() + token, err = tokens.Create(context.TODO(), identityClient, authOptions).ExtractToken() if err != nil { panic(err) } @@ -99,7 +99,7 @@ Example to Create a Token from a Username and Password with Project Name Scope Password: "password", } - token, err = tokens.Create(identityClient, authOptions).ExtractToken() + token, err = tokens.Create(context.TODO(), identityClient, authOptions).ExtractToken() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/requests.go similarity index 80% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/requests.go index 1af55d8137752..fa8b925d04946 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/requests.go @@ -1,6 +1,10 @@ package tokens -import "github.com/gophercloud/gophercloud" +import ( + "context" + + "github.com/gophercloud/gophercloud/v2" +) // Scope allows a created token to be limited to a specific domain or project. type Scope struct { @@ -9,6 +13,7 @@ type Scope struct { DomainID string DomainName string System bool + TrustID string } // AuthOptionsBuilder provides the ability for extensions to add additional @@ -16,9 +21,9 @@ type Scope struct { type AuthOptionsBuilder interface { // ToTokenV3CreateMap assembles the Create request body, returning an error // if parameters are missing or inconsistent. - ToTokenV3CreateMap(map[string]interface{}) (map[string]interface{}, error) - ToTokenV3HeadersMap(map[string]interface{}) (map[string]string, error) - ToTokenV3ScopeMap() (map[string]interface{}, error) + ToTokenV3CreateMap(map[string]any) (map[string]any, error) + ToTokenV3HeadersMap(map[string]any) (map[string]string, error) + ToTokenV3ScopeMap() (map[string]any, error) CanReauth() bool } @@ -67,7 +72,7 @@ type AuthOptions struct { } // ToTokenV3CreateMap builds a request body from AuthOptions. -func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]interface{}) (map[string]interface{}, error) { +func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]any) (map[string]any, error) { gophercloudAuthOpts := gophercloud.AuthOptions{ Username: opts.Username, UserID: opts.UserID, @@ -86,7 +91,7 @@ func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]interface{}) (map[s } // ToTokenV3ScopeMap builds a scope request body from AuthOptions. -func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) { +func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]any, error) { scope := gophercloud.AuthScope(opts.Scope) gophercloudAuthOpts := gophercloud.AuthOptions{ @@ -109,7 +114,7 @@ func (opts *AuthOptions) CanReauth() bool { // ToTokenV3HeadersMap allows AuthOptions to satisfy the AuthOptionsBuilder // interface in the v3 tokens package. -func (opts *AuthOptions) ToTokenV3HeadersMap(map[string]interface{}) (map[string]string, error) { +func (opts *AuthOptions) ToTokenV3HeadersMap(map[string]any) (map[string]string, error) { return nil, nil } @@ -121,7 +126,7 @@ func subjectTokenHeaders(subjectToken string) map[string]string { // Create authenticates and either generates a new token, or changes the Scope // of an existing token. -func Create(c *gophercloud.ServiceClient, opts AuthOptionsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts AuthOptionsBuilder) (r CreateResult) { scope, err := opts.ToTokenV3ScopeMap() if err != nil { r.Err = err @@ -134,7 +139,7 @@ func Create(c *gophercloud.ServiceClient, opts AuthOptionsBuilder) (r CreateResu return } - resp, err := c.Post(tokenURL(c), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Post(ctx, tokenURL(c), b, &r.Body, &gophercloud.RequestOpts{ OmitHeaders: []string{"X-Auth-Token"}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -142,8 +147,8 @@ func Create(c *gophercloud.ServiceClient, opts AuthOptionsBuilder) (r CreateResu } // Get validates and retrieves information about another token. -func Get(c *gophercloud.ServiceClient, token string) (r GetResult) { - resp, err := c.Get(tokenURL(c), &r.Body, &gophercloud.RequestOpts{ +func Get(ctx context.Context, c *gophercloud.ServiceClient, token string) (r GetResult) { + resp, err := c.Get(ctx, tokenURL(c), &r.Body, &gophercloud.RequestOpts{ MoreHeaders: subjectTokenHeaders(token), OkCodes: []int{200, 203}, }) @@ -152,8 +157,8 @@ func Get(c *gophercloud.ServiceClient, token string) (r GetResult) { } // Validate determines if a specified token is valid or not. -func Validate(c *gophercloud.ServiceClient, token string) (bool, error) { - resp, err := c.Head(tokenURL(c), &gophercloud.RequestOpts{ +func Validate(ctx context.Context, c *gophercloud.ServiceClient, token string) (bool, error) { + resp, err := c.Head(ctx, tokenURL(c), &gophercloud.RequestOpts{ MoreHeaders: subjectTokenHeaders(token), OkCodes: []int{200, 204, 404}, }) @@ -165,8 +170,8 @@ func Validate(c *gophercloud.ServiceClient, token string) (bool, error) { } // Revoke immediately makes specified token invalid. -func Revoke(c *gophercloud.ServiceClient, token string) (r RevokeResult) { - resp, err := c.Delete(tokenURL(c), &gophercloud.RequestOpts{ +func Revoke(ctx context.Context, c *gophercloud.ServiceClient, token string) (r RevokeResult) { + resp, err := c.Delete(ctx, tokenURL(c), &gophercloud.RequestOpts{ MoreHeaders: subjectTokenHeaders(token), }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/results.go similarity index 89% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/results.go index f1e17e9f75a09..bd61a9a67d61e 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/results.go @@ -3,7 +3,7 @@ package tokens import ( "time" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) // Endpoint represents a single API endpoint offered by a service. @@ -76,6 +76,18 @@ type Project struct { Name string `json:"name"` } +type TrustUser struct { + ID string `json:"id"` +} + +// Trust provides information about trust with which User is authorized. +type Trust struct { + ID string `json:"id"` + Impersonation bool `json:"impersonation"` + TrusteeUserID TrustUser `json:"trustee_user"` + TrustorUserID TrustUser `json:"trustor_user"` +} + // commonResult is the response from a request. A commonResult has various // methods which can be used to extract different details about the result. type commonResult struct { @@ -160,6 +172,15 @@ func (r commonResult) ExtractDomain() (*Domain, error) { return s.Domain, err } +// ExtractTrust returns Trust to which User is authorized. +func (r commonResult) ExtractTrust() (*Trust, error) { + var s struct { + Trust *Trust `json:"OS-TRUST:trust"` + } + err := r.ExtractInto(&s) + return s.Trust, err +} + // CreateResult is the response from a Create request. Use ExtractToken() // to interpret it as a Token, or ExtractServiceCatalog() to interpret it // as a service catalog. @@ -189,6 +210,6 @@ type Token struct { ExpiresAt time.Time `json:"expires_at"` } -func (r commonResult) ExtractInto(v interface{}) error { +func (r commonResult) ExtractInto(v any) error { return r.ExtractIntoStructPtr(v, "token") } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/urls.go similarity index 70% rename from vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/urls.go index 2f864a31c8bff..2218c107fb24d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v3/tokens/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens/urls.go @@ -1,6 +1,6 @@ package tokens -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func tokenURL(c *gophercloud.ServiceClient) string { return c.ServiceURL("auth", "tokens") diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/doc.go similarity index 73% rename from vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/doc.go index 14da9ac90da97..bf1a6cd5b978d 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/doc.go @@ -8,7 +8,7 @@ Example to List Images Owner: "a7509e1ae65945fda83f3e52c6296017", } - allPages, err := images.List(imagesClient, listOpts).AllPages() + allPages, err := images.List(imagesClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -29,7 +29,7 @@ Example to Create an Image Visibility: images.ImageVisibilityPrivate, } - image, err := images.Create(imageClient, createOpts) + image, err := images.Create(context.TODO(), imageClient, createOpts) if err != nil { panic(err) } @@ -44,7 +44,7 @@ Example to Update an Image }, } - image, err := images.Update(imageClient, imageID, updateOpts).Extract() + image, err := images.Update(context.TODO(), imageClient, imageID, updateOpts).Extract() if err != nil { panic(err) } @@ -52,7 +52,7 @@ Example to Update an Image Example to Delete an Image imageID := "1bea47ed-f6a9-463b-b423-14b9cca9ad27" - err := images.Delete(imageClient, imageID).ExtractErr() + err := images.Delete(context.TODO(), imageClient, imageID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/requests.go similarity index 83% rename from vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/requests.go index 2ab609cbca8be..a5f61dd615d39 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/requests.go @@ -1,12 +1,13 @@ package images import ( + "context" "fmt" "net/url" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -144,7 +145,7 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { // CreateOptsBuilder allows extensions to add parameters to the Create request. type CreateOptsBuilder interface { // Returns value that can be passed to json.Marshal - ToImageCreateMap() (map[string]interface{}, error) + ToImageCreateMap() (map[string]any, error) } // CreateOpts represents options used to create an image. @@ -191,7 +192,7 @@ type CreateOpts struct { // ToImageCreateMap assembles a request body based on the contents of // a CreateOpts. -func (opts CreateOpts) ToImageCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToImageCreateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "") if err != nil { return nil, err @@ -206,39 +207,39 @@ func (opts CreateOpts) ToImageCreateMap() (map[string]interface{}, error) { } // Create implements create image request. -func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToImageCreateMap() if err != nil { r.Err = err return r } - resp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{OkCodes: []int{201}}) + resp, err := client.Post(ctx, createURL(client), b, &r.Body, &gophercloud.RequestOpts{OkCodes: []int{201}}) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Delete implements image delete request. -func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := client.Delete(deleteURL(client, id), nil) +func Delete(ctx context.Context, client *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := client.Delete(ctx, deleteURL(client, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Get implements image get request. -func Get(client *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := client.Get(getURL(client, id), &r.Body, nil) +func Get(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := client.Get(ctx, getURL(client, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Update implements image updated request. -func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToImageUpdateMap() if err != nil { r.Err = err return r } - resp, err := client.Patch(updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Patch(ctx, updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, MoreHeaders: map[string]string{"Content-Type": "application/openstack-images-v2.1-json-patch"}, }) @@ -252,7 +253,7 @@ type UpdateOptsBuilder interface { // returns value implementing json.Marshaler which when marshaled matches // the patch schema: // http://specs.openstack.org/openstack/glance-specs/specs/api/v2/http-patch-image-api-v2.html - ToImageUpdateMap() ([]interface{}, error) + ToImageUpdateMap() ([]any, error) } // UpdateOpts implements UpdateOpts @@ -260,8 +261,8 @@ type UpdateOpts []Patch // ToImageUpdateMap assembles a request body based on the contents of // UpdateOpts. -func (opts UpdateOpts) ToImageUpdateMap() ([]interface{}, error) { - m := make([]interface{}, len(opts)) +func (opts UpdateOpts) ToImageUpdateMap() ([]any, error) { + m := make([]any, len(opts)) for i, patch := range opts { patchJSON := patch.ToImagePatchMap() m[i] = patchJSON @@ -272,7 +273,7 @@ func (opts UpdateOpts) ToImageUpdateMap() ([]interface{}, error) { // Patch represents a single update to an existing image. Multiple updates // to an image can be submitted at the same time. type Patch interface { - ToImagePatchMap() map[string]interface{} + ToImagePatchMap() map[string]any } // UpdateVisibility represents an updated visibility property request. @@ -281,8 +282,8 @@ type UpdateVisibility struct { } // ToImagePatchMap assembles a request body based on UpdateVisibility. -func (r UpdateVisibility) ToImagePatchMap() map[string]interface{} { - return map[string]interface{}{ +func (r UpdateVisibility) ToImagePatchMap() map[string]any { + return map[string]any{ "op": "replace", "path": "/visibility", "value": r.Visibility, @@ -295,8 +296,8 @@ type ReplaceImageHidden struct { } // ToImagePatchMap assembles a request body based on ReplaceImageHidden. -func (r ReplaceImageHidden) ToImagePatchMap() map[string]interface{} { - return map[string]interface{}{ +func (r ReplaceImageHidden) ToImagePatchMap() map[string]any { + return map[string]any{ "op": "replace", "path": "/os_hidden", "value": r.NewHidden, @@ -309,8 +310,8 @@ type ReplaceImageName struct { } // ToImagePatchMap assembles a request body based on ReplaceImageName. -func (r ReplaceImageName) ToImagePatchMap() map[string]interface{} { - return map[string]interface{}{ +func (r ReplaceImageName) ToImagePatchMap() map[string]any { + return map[string]any{ "op": "replace", "path": "/name", "value": r.NewName, @@ -323,8 +324,8 @@ type ReplaceImageChecksum struct { } // ReplaceImageChecksum assembles a request body based on ReplaceImageChecksum. -func (r ReplaceImageChecksum) ToImagePatchMap() map[string]interface{} { - return map[string]interface{}{ +func (r ReplaceImageChecksum) ToImagePatchMap() map[string]any { + return map[string]any{ "op": "replace", "path": "/checksum", "value": r.Checksum, @@ -337,8 +338,8 @@ type ReplaceImageTags struct { } // ToImagePatchMap assembles a request body based on ReplaceImageTags. -func (r ReplaceImageTags) ToImagePatchMap() map[string]interface{} { - return map[string]interface{}{ +func (r ReplaceImageTags) ToImagePatchMap() map[string]any { + return map[string]any{ "op": "replace", "path": "/tags", "value": r.NewTags, @@ -351,8 +352,8 @@ type ReplaceImageMinDisk struct { } // ToImagePatchMap assembles a request body based on ReplaceImageTags. -func (r ReplaceImageMinDisk) ToImagePatchMap() map[string]interface{} { - return map[string]interface{}{ +func (r ReplaceImageMinDisk) ToImagePatchMap() map[string]any { + return map[string]any{ "op": "replace", "path": "/min_disk", "value": r.NewMinDisk, @@ -365,8 +366,8 @@ type ReplaceImageMinRam struct { } // ToImagePatchMap assembles a request body based on ReplaceImageTags. -func (r ReplaceImageMinRam) ToImagePatchMap() map[string]interface{} { - return map[string]interface{}{ +func (r ReplaceImageMinRam) ToImagePatchMap() map[string]any { + return map[string]any{ "op": "replace", "path": "/min_ram", "value": r.NewMinRam, @@ -379,8 +380,8 @@ type ReplaceImageProtected struct { } // ToImagePatchMap assembles a request body based on ReplaceImageProtected -func (r ReplaceImageProtected) ToImagePatchMap() map[string]interface{} { - return map[string]interface{}{ +func (r ReplaceImageProtected) ToImagePatchMap() map[string]any { + return map[string]any{ "op": "replace", "path": "/protected", "value": r.NewProtected, @@ -404,8 +405,8 @@ type UpdateImageProperty struct { } // ToImagePatchMap assembles a request body based on UpdateImageProperty. -func (r UpdateImageProperty) ToImagePatchMap() map[string]interface{} { - updateMap := map[string]interface{}{ +func (r UpdateImageProperty) ToImagePatchMap() map[string]any { + updateMap := map[string]any{ "op": r.Op, "path": fmt.Sprintf("/%s", r.Name), } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/results.go similarity index 92% rename from vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/results.go index 96fd91a2cacb2..6652f0e791dac 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/results.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // Image represents an image found in the OpenStack Image service. @@ -20,7 +20,7 @@ type Image struct { Name string `json:"name"` // Status is the image status. It can be "queued" or "active" - // See imageservice/v2/images/type.go + // See image/v2/images/type.go Status ImageStatus `json:"status"` // Tags is a list of image tags. Tags are arbitrarily defined strings @@ -70,7 +70,7 @@ type Image struct { // Properties is a set of key-value pairs, if any, that are associated with // the image. - Properties map[string]interface{} + Properties map[string]any // CreatedAt is the date when the image has been created. CreatedAt time.Time `json:"created_at"` @@ -102,9 +102,9 @@ func (r *Image) UnmarshalJSON(b []byte) error { type tmp Image var s struct { tmp - SizeBytes interface{} `json:"size"` - OpenStackImageImportMethods string `json:"openstack-image-import-methods"` - OpenStackImageStoreIDs string `json:"openstack-image-store-ids"` + SizeBytes any `json:"size"` + OpenStackImageImportMethods string `json:"openstack-image-import-methods"` + OpenStackImageStoreIDs string `json:"openstack-image-store-ids"` } err := json.Unmarshal(b, &s) if err != nil { @@ -124,12 +124,12 @@ func (r *Image) UnmarshalJSON(b []byte) error { } // Bundle all other fields into Properties - var result interface{} + var result any err = json.Unmarshal(b, &result) if err != nil { return err } - if resultMap, ok := result.(map[string]interface{}); ok { + if resultMap, ok := result.(map[string]any); ok { delete(resultMap, "self") delete(resultMap, "size") delete(resultMap, "openstack-image-import-methods") @@ -154,7 +154,7 @@ type commonResult struct { // Extract interprets any commonResult as an Image. func (r commonResult) Extract() (*Image, error) { var s *Image - if v, ok := r.Body.(map[string]interface{}); ok { + if v, ok := r.Body.(map[string]any); ok { for k, h := range r.Header { if strings.ToLower(k) == "openstack-image-import-methods" { for _, s := range h { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/types.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/types.go similarity index 100% rename from vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/types.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/types.go diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/urls.go similarity index 94% rename from vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/urls.go index 1780c3c6ca702..c3007a6129d25 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/image/v2/images/urls.go @@ -4,8 +4,8 @@ import ( "net/url" "strings" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/utils" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/utils" ) // `listURL` is a pure function. `listURL(c)` is a URL for which a GET diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/doc.go similarity index 97% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/doc.go index d9b5eff9d9bea..d65e3a6dd4481 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/doc.go @@ -5,7 +5,7 @@ restricted to this particular version. Example to List API Versions - allPages, err := apiversions.List(loadbalancerClient).AllPages() + allPages, err := apiversions.List(loadbalancerClient).AllPages(context.TODO()) if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/requests.go similarity index 77% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/requests.go index 18c88de077d23..1a08dc4880bc0 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/requests.go @@ -1,8 +1,8 @@ package apiversions import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // List lists all the load balancer API versions available to end-users. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/results.go similarity index 94% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/results.go index dce4aa5d1427c..4d3d1ae222b29 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/results.go @@ -1,6 +1,6 @@ package apiversions -import "github.com/gophercloud/gophercloud/pagination" +import "github.com/gophercloud/gophercloud/v2/pagination" // APIVersion represents an API version for load balancer. It contains // the status of the API, and its unique ID. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/urls.go similarity index 69% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/urls.go index a6a35d4225c2c..deaf71765118e 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions/urls.go @@ -3,8 +3,8 @@ package apiversions import ( "strings" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/utils" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/utils" ) func listURL(c *gophercloud.ServiceClient) string { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/doc.go similarity index 72% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/doc.go index 813579905c256..1b02b9230492f 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/doc.go @@ -10,7 +10,7 @@ Example to Create a L7Policy Action: l7policies.ActionRedirectToURL, RedirectURL: "http://www.example.com", } - l7policy, err := l7policies.Create(lbClient, createOpts).Extract() + l7policy, err := l7policies.Create(context.TODO(), lbClient, createOpts).Extract() if err != nil { panic(err) } @@ -20,7 +20,7 @@ Example to List L7Policies listOpts := l7policies.ListOpts{ ListenerID: "c79a4468-d788-410c-bf79-9a8ef6354852", } - allPages, err := l7policies.List(lbClient, listOpts).AllPages() + allPages, err := l7policies.List(lbClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -34,7 +34,7 @@ Example to List L7Policies Example to Get a L7Policy - l7policy, err := l7policies.Get(lbClient, "023f2e34-7806-443b-bfae-16c324569a3d").Extract() + l7policy, err := l7policies.Get(context.TODO(), lbClient, "023f2e34-7806-443b-bfae-16c324569a3d").Extract() if err != nil { panic(err) } @@ -42,7 +42,7 @@ Example to Get a L7Policy Example to Delete a L7Policy l7policyID := "d67d56a6-4a86-4688-a282-f46444705c64" - err := l7policies.Delete(lbClient, l7policyID).ExtractErr() + err := l7policies.Delete(context.TODO(), lbClient, l7policyID).ExtractErr() if err != nil { panic(err) } @@ -54,7 +54,7 @@ Example to Update a L7Policy updateOpts := l7policies.UpdateOpts{ Name: &name, } - l7policy, err := l7policies.Update(lbClient, l7policyID, updateOpts).Extract() + l7policy, err := l7policies.Update(context.TODO(), lbClient, l7policyID, updateOpts).Extract() if err != nil { panic(err) } @@ -67,7 +67,7 @@ Example to Create a Rule CompareType: l7policies.CompareTypeRegex, Value: "/images*", } - rule, err := l7policies.CreateRule(lbClient, l7policyID, createOpts).Extract() + rule, err := l7policies.CreateRule(context.TODO(), lbClient, l7policyID, createOpts).Extract() if err != nil { panic(err) } @@ -78,7 +78,7 @@ Example to List L7 Rules listOpts := l7policies.ListRulesOpts{ RuleType: l7policies.TypePath, } - allPages, err := l7policies.ListRules(lbClient, l7policyID, listOpts).AllPages() + allPages, err := l7policies.ListRules(lbClient, l7policyID, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -92,7 +92,7 @@ Example to List L7 Rules Example to Get a l7 rule - l7rule, err := l7policies.GetRule(lbClient, "023f2e34-7806-443b-bfae-16c324569a3d", "53ad8ab8-40fa-11e8-a508-00224d6b7bc1").Extract() + l7rule, err := l7policies.GetRule(context.TODO(), lbClient, "023f2e34-7806-443b-bfae-16c324569a3d", "53ad8ab8-40fa-11e8-a508-00224d6b7bc1").Extract() if err != nil { panic(err) } @@ -101,7 +101,7 @@ Example to Delete a l7 rule l7policyID := "d67d56a6-4a86-4688-a282-f46444705c64" ruleID := "64dba99f-8af8-4200-8882-e32a0660f23e" - err := l7policies.DeleteRule(lbClient, l7policyID, ruleID).ExtractErr() + err := l7policies.DeleteRule(context.TODO(), lbClient, l7policyID, ruleID).ExtractErr() if err != nil { panic(err) } @@ -115,7 +115,7 @@ Example to Update a Rule CompareType: l7policies.CompareTypeRegex, Value: "/images/special*", } - rule, err := l7policies.UpdateRule(lbClient, l7policyID, ruleID, updateOpts).Extract() + rule, err := l7policies.UpdateRule(context.TODO(), lbClient, l7policyID, ruleID, updateOpts).Extract() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/requests.go similarity index 81% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/requests.go index 2b84bcad14a3d..62a4f179eef45 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/requests.go @@ -1,14 +1,16 @@ package l7policies import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToL7PolicyCreateMap() (map[string]interface{}, error) + ToL7PolicyCreateMap() (map[string]any, error) } type Action string @@ -21,11 +23,14 @@ const ( ActionRedirectToURL Action = "REDIRECT_TO_URL" ActionReject Action = "REJECT" - TypeCookie RuleType = "COOKIE" - TypeFileType RuleType = "FILE_TYPE" - TypeHeader RuleType = "HEADER" - TypeHostName RuleType = "HOST_NAME" - TypePath RuleType = "PATH" + TypeCookie RuleType = "COOKIE" + TypeFileType RuleType = "FILE_TYPE" + TypeHeader RuleType = "HEADER" + TypeHostName RuleType = "HOST_NAME" + TypePath RuleType = "PATH" + TypeSSLConnHasCert RuleType = "SSL_CONN_HAS_CERT" + TypeSSLVerifyResult RuleType = "SSL_VERIFY_RESULT" + TypeSSLDNField RuleType = "SSL_DN_FIELD" CompareTypeContains CompareType = "CONTAINS" CompareTypeEndWith CompareType = "ENDS_WITH" @@ -83,21 +88,24 @@ type CreateOpts struct { // This is only possible to use when creating a fully populated // Loadbalancer. Rules []CreateRuleOpts `json:"rules,omitempty"` + + // Tags is a set of resource tags. Requires version 2.5. + Tags []string `json:"tags,omitempty"` } // ToL7PolicyCreateMap builds a request body from CreateOpts. -func (opts CreateOpts) ToL7PolicyCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToL7PolicyCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "l7policy") } // Create accepts a CreateOpts struct and uses the values to create a new l7policy. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToL7PolicyCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(rootURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, rootURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -154,15 +162,15 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { } // Get retrieves a particular l7policy based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(resourceURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, resourceURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Delete will permanently delete a particular l7policy based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(resourceURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, resourceURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -170,7 +178,7 @@ func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToL7PolicyUpdateMap() (map[string]interface{}, error) + ToL7PolicyUpdateMap() (map[string]any, error) } // UpdateOpts is the common options struct used in this package's Update @@ -208,16 +216,19 @@ type UpdateOpts struct { // The administrative state of the Loadbalancer. A valid value is true (UP) // or false (DOWN). AdminStateUp *bool `json:"admin_state_up,omitempty"` + + // Tags is a set of resource tags. Requires version 2.5. + Tags *[]string `json:"tags,omitempty"` } // ToL7PolicyUpdateMap builds a request body from UpdateOpts. -func (opts UpdateOpts) ToL7PolicyUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToL7PolicyUpdateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "l7policy") if err != nil { return nil, err } - m := b["l7policy"].(map[string]interface{}) + m := b["l7policy"].(map[string]any) if m["redirect_pool_id"] == "" { m["redirect_pool_id"] = nil @@ -239,13 +250,13 @@ func (opts UpdateOpts) ToL7PolicyUpdateMap() (map[string]interface{}, error) { } // Update allows l7policy to be updated. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToL7PolicyUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -278,21 +289,24 @@ type CreateRuleOpts struct { // The administrative state of the Loadbalancer. A valid value is true (UP) // or false (DOWN). AdminStateUp *bool `json:"admin_state_up,omitempty"` + + // Tags is a set of resource tags. Requires version 2.5. + Tags []string `json:"tags,omitempty"` } // ToRuleCreateMap builds a request body from CreateRuleOpts. -func (opts CreateRuleOpts) ToRuleCreateMap() (map[string]interface{}, error) { +func (opts CreateRuleOpts) ToRuleCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "rule") } // CreateRule will create and associate a Rule with a particular L7Policy. -func CreateRule(c *gophercloud.ServiceClient, policyID string, opts CreateRuleOpts) (r CreateRuleResult) { +func CreateRule(ctx context.Context, c *gophercloud.ServiceClient, policyID string, opts CreateRuleOpts) (r CreateRuleResult) { b, err := opts.ToRuleCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(ruleRootURL(c, policyID), b, &r.Body, nil) + resp, err := c.Post(ctx, ruleRootURL(c, policyID), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -347,22 +361,22 @@ func ListRules(c *gophercloud.ServiceClient, policyID string, opts ListRulesOpts } // GetRule retrieves a particular L7Policy Rule based on its unique ID. -func GetRule(c *gophercloud.ServiceClient, policyID string, ruleID string) (r GetRuleResult) { - resp, err := c.Get(ruleResourceURL(c, policyID, ruleID), &r.Body, nil) +func GetRule(ctx context.Context, c *gophercloud.ServiceClient, policyID string, ruleID string) (r GetRuleResult) { + resp, err := c.Get(ctx, ruleResourceURL(c, policyID, ruleID), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // DeleteRule will remove a Rule from a particular L7Policy. -func DeleteRule(c *gophercloud.ServiceClient, policyID string, ruleID string) (r DeleteRuleResult) { - resp, err := c.Delete(ruleResourceURL(c, policyID, ruleID), nil) +func DeleteRule(ctx context.Context, c *gophercloud.ServiceClient, policyID string, ruleID string) (r DeleteRuleResult) { + resp, err := c.Delete(ctx, ruleResourceURL(c, policyID, ruleID), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // UpdateRuleOptsBuilder allows to add additional parameters to the PUT request. type UpdateRuleOptsBuilder interface { - ToRuleUpdateMap() (map[string]interface{}, error) + ToRuleUpdateMap() (map[string]any, error) } // UpdateRuleOpts is the common options struct used in this package's Update @@ -387,16 +401,19 @@ type UpdateRuleOpts struct { // The administrative state of the Loadbalancer. A valid value is true (UP) // or false (DOWN). AdminStateUp *bool `json:"admin_state_up,omitempty"` + + // Tags is a set of resource tags. Requires version 2.5. + Tags *[]string `json:"tags,omitempty"` } // ToRuleUpdateMap builds a request body from UpdateRuleOpts. -func (opts UpdateRuleOpts) ToRuleUpdateMap() (map[string]interface{}, error) { +func (opts UpdateRuleOpts) ToRuleUpdateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "rule") if err != nil { return nil, err } - if m := b["rule"].(map[string]interface{}); m["key"] == "" { + if m := b["rule"].(map[string]any); m["key"] == "" { m["key"] = nil } @@ -404,13 +421,13 @@ func (opts UpdateRuleOpts) ToRuleUpdateMap() (map[string]interface{}, error) { } // UpdateRule allows Rule to be updated. -func UpdateRule(c *gophercloud.ServiceClient, policyID string, ruleID string, opts UpdateRuleOptsBuilder) (r UpdateRuleResult) { +func UpdateRule(ctx context.Context, c *gophercloud.ServiceClient, policyID string, ruleID string, opts UpdateRuleOptsBuilder) (r UpdateRuleResult) { b, err := opts.ToRuleUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(ruleResourceURL(c, policyID, ruleID), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, ruleResourceURL(c, policyID, ruleID), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 201, 202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/results.go similarity index 95% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/results.go index bc5b32139a14d..214d59d121126 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/results.go @@ -1,8 +1,8 @@ package l7policies import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // L7Policy is a collection of L7 rules associated with a Listener, and which @@ -58,6 +58,10 @@ type L7Policy struct { // Rules are List of associated L7 rule IDs. Rules []Rule `json:"rules"` + + // Tags is a list of resource tags. Tags are arbitrarily defined strings + // attached to the resource. + Tags []string `json:"tags"` } // Rule represents layer 7 load balancing rule. @@ -94,6 +98,10 @@ type Rule struct { // The operating status of the L7 policy. OperatingStatus string `json:"operating_status"` + + // Tags is a list of resource tags. Tags are arbitrarily defined strings + // attached to the resource. + Tags []string `json:"tags"` } type commonResult struct { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/urls.go similarity index 93% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/urls.go index ecb607a8e89d7..57126a8811a00 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies/urls.go @@ -1,6 +1,6 @@ package l7policies -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const ( rootPath = "lbaas" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/doc.go similarity index 80% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/doc.go index c99bbc7026532..2659715f80105 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/doc.go @@ -8,7 +8,7 @@ Example to List Listeners LoadbalancerID : "ca430f80-1737-4712-8dc6-3f640d55594b", } - allPages, err := listeners.List(networkClient, listOpts).AllPages() + allPages, err := listeners.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -34,7 +34,7 @@ Example to Create a Listener Tags: []string{"test", "stage"}, } - listener, err := listeners.Create(networkClient, createOpts).Extract() + listener, err := listeners.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -53,7 +53,7 @@ Example to Update a Listener Tags: &newTags, } - listener, err := listeners.Update(networkClient, listenerID, updateOpts).Extract() + listener, err := listeners.Update(context.TODO(), networkClient, listenerID, updateOpts).Extract() if err != nil { panic(err) } @@ -61,7 +61,7 @@ Example to Update a Listener Example to Delete a Listener listenerID := "d67d56a6-4a86-4688-a282-f46444705c64" - err := listeners.Delete(networkClient, listenerID).ExtractErr() + err := listeners.Delete(context.TODO(), networkClient, listenerID).ExtractErr() if err != nil { panic(err) } @@ -69,7 +69,7 @@ Example to Delete a Listener Example to Get the Statistics of a Listener listenerID := "d67d56a6-4a86-4688-a282-f46444705c64" - stats, err := listeners.GetStats(networkClient, listenerID).Extract() + stats, err := listeners.GetStats(context.TODO(), networkClient, listenerID).Extract() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/requests.go similarity index 57% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/requests.go index a0a06f64485e9..3216fbddd04bf 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/requests.go @@ -1,10 +1,12 @@ package listeners import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2/pagination" ) // Type Protocol represents a listener protocol. @@ -35,6 +37,15 @@ const ( TLSVersionTLSv1_3 TLSVersion = "TLSv1.3" ) +// ClientAuthentication represents the TLS client authentication mode. +type ClientAuthentication string + +const ( + ClientAuthenticationNone ClientAuthentication = "NONE" + ClientAuthenticationOptional ClientAuthentication = "OPTIONAL" + ClientAuthenticationMandatory ClientAuthentication = "MANDATORY" +) + // ListOptsBuilder allows extensions to add additional parameters to the // List request. type ListOptsBuilder interface { @@ -47,23 +58,24 @@ type ListOptsBuilder interface { // sort by a particular listener attribute. SortDir sets the direction, and is // either `asc' or `desc'. Marker and Limit are used for pagination. type ListOpts struct { - ID string `q:"id"` - Name string `q:"name"` - AdminStateUp *bool `q:"admin_state_up"` - ProjectID string `q:"project_id"` - LoadbalancerID string `q:"loadbalancer_id"` - DefaultPoolID string `q:"default_pool_id"` - Protocol string `q:"protocol"` - ProtocolPort int `q:"protocol_port"` - ConnectionLimit int `q:"connection_limit"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` - TimeoutClientData *int `q:"timeout_client_data"` - TimeoutMemberData *int `q:"timeout_member_data"` - TimeoutMemberConnect *int `q:"timeout_member_connect"` - TimeoutTCPInspect *int `q:"timeout_tcp_inspect"` + ID string `q:"id"` + Name string `q:"name"` + AdminStateUp *bool `q:"admin_state_up"` + ProjectID string `q:"project_id"` + LoadbalancerID string `q:"loadbalancer_id"` + DefaultPoolID string `q:"default_pool_id"` + Protocol string `q:"protocol"` + ProtocolPort int `q:"protocol_port"` + ConnectionLimit int `q:"connection_limit"` + Limit int `q:"limit"` + Marker string `q:"marker"` + SortKey string `q:"sort_key"` + SortDir string `q:"sort_dir"` + TimeoutClientData *int `q:"timeout_client_data"` + TimeoutMemberData *int `q:"timeout_member_data"` + TimeoutMemberConnect *int `q:"timeout_member_connect"` + TimeoutTCPInspect *int `q:"timeout_tcp_inspect"` + Tags []string `q:"tags"` } // ToListenerListQuery formats a ListOpts into a query string. @@ -95,7 +107,7 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToListenerCreateMap() (map[string]interface{}, error) + ToListenerCreateMap() (map[string]any, error) } // CreateOpts represents options for creating a listener. @@ -167,6 +179,46 @@ type CreateOpts struct { // A list of IPv4, IPv6 or mix of both CIDRs AllowedCIDRs []string `json:"allowed_cidrs,omitempty"` + // A list of ALPN protocols. Available protocols: http/1.0, http/1.1, + // h2. Available from microversion 2.20. + ALPNProtocols []string `json:"alpn_protocols,omitempty"` + + // The TLS client authentication mode. One of the options NONE, + // OPTIONAL or MANDATORY. Available from microversion 2.8. + ClientAuthentication ClientAuthentication `json:"client_authentication,omitempty"` + + // The ref of the key manager service secret containing a PEM format + // client CA certificate bundle for TERMINATED_HTTPS listeners. + // Available from microversion 2.8. + ClientCATLSContainerRef string `json:"client_ca_tls_container_ref,omitempty"` + + // The URI of the key manager service secret containing a PEM format CA + // revocation list file for TERMINATED_HTTPS listeners. Available from + // microversion 2.8. + ClientCRLContainerRef string `json:"client_crl_container_ref,omitempty"` + + // Defines whether the includeSubDomains directive should be added to + // the Strict-Transport-Security HTTP response header. This requires + // setting the hsts_max_age option as well in order to become + // effective. Available from microversion 2.27. + HSTSIncludeSubdomains bool `json:"hsts_include_subdomains,omitempty"` + + // The value of the max_age directive for the Strict-Transport-Security + // HTTP response header. Setting this enables HTTP Strict Transport + // Security (HSTS) for the TLS-terminated listener. Available from + // microversion 2.27. + HSTSMaxAge int `json:"hsts_max_age,omitempty"` + + // Defines whether the preload directive should be added to the + // Strict-Transport-Security HTTP response header. This requires + // setting the hsts_max_age option as well in order to become + // effective. Available from microversion 2.27. + HSTSPreload bool `json:"hsts_preload,omitempty"` + + // List of ciphers in OpenSSL format (colon-separated). Available from + // microversion 2.15. + TLSCiphers string `json:"tls_ciphers,omitempty"` + // A list of TLS protocol versions. Available from microversion 2.17 TLSVersions []TLSVersion `json:"tls_versions,omitempty"` @@ -175,7 +227,7 @@ type CreateOpts struct { } // ToListenerCreateMap builds a request body from CreateOpts. -func (opts CreateOpts) ToListenerCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToListenerCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "listener") } @@ -186,20 +238,20 @@ func (opts CreateOpts) ToListenerCreateMap() (map[string]interface{}, error) { // // Users with an admin role can create Listeners on behalf of other projects by // specifying a ProjectID attribute different than their own. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToListenerCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(rootURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, rootURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Get retrieves a particular Listeners based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(resourceURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, resourceURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -207,7 +259,7 @@ func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToListenerUpdateMap() (map[string]interface{}, error) + ToListenerUpdateMap() (map[string]any, error) } // UpdateOpts represents options for updating a Listener. @@ -252,6 +304,46 @@ type UpdateOpts struct { // A list of IPv4, IPv6 or mix of both CIDRs AllowedCIDRs *[]string `json:"allowed_cidrs,omitempty"` + // A list of ALPN protocols. Available protocols: http/1.0, http/1.1, + // h2. Available from microversion 2.20. + ALPNProtocols *[]string `json:"alpn_protocols,omitempty"` + + // The TLS client authentication mode. One of the options NONE, + // OPTIONAL or MANDATORY. Available from microversion 2.8. + ClientAuthentication *ClientAuthentication `json:"client_authentication,omitempty"` + + // The ref of the key manager service secret containing a PEM format + // client CA certificate bundle for TERMINATED_HTTPS listeners. + // Available from microversion 2.8. + ClientCATLSContainerRef *string `json:"client_ca_tls_container_ref,omitempty"` + + // The URI of the key manager service secret containing a PEM format CA + // revocation list file for TERMINATED_HTTPS listeners. Available from + // microversion 2.8. + ClientCRLContainerRef *string `json:"client_crl_container_ref,omitempty"` + + // Defines whether the includeSubDomains directive should be added to + // the Strict-Transport-Security HTTP response header. This requires + // setting the hsts_max_age option as well in order to become + // effective. Available from microversion 2.27. + HSTSIncludeSubdomains *bool `json:"hsts_include_subdomains,omitempty"` + + // The value of the max_age directive for the Strict-Transport-Security + // HTTP response header. Setting this enables HTTP Strict Transport + // Security (HSTS) for the TLS-terminated listener. Available from + // microversion 2.27. + HSTSMaxAge *int `json:"hsts_max_age,omitempty"` + + // Defines whether the preload directive should be added to the + // Strict-Transport-Security HTTP response header. This requires + // setting the hsts_max_age option as well in order to become + // effective. Available from microversion 2.27. + HSTSPreload *bool `json:"hsts_preload,omitempty"` + + // List of ciphers in OpenSSL format (colon-separated). Available from + // microversion 2.15. + TLSCiphers *string `json:"tls_ciphers,omitempty"` + // A list of TLS protocol versions. Available from microversion 2.17 TLSVersions *[]TLSVersion `json:"tls_versions,omitempty"` @@ -260,28 +352,41 @@ type UpdateOpts struct { } // ToListenerUpdateMap builds a request body from UpdateOpts. -func (opts UpdateOpts) ToListenerUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToListenerUpdateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "listener") if err != nil { return nil, err } - if m := b["listener"].(map[string]interface{}); m["default_pool_id"] == "" { + m := b["listener"].(map[string]any) + + // allow to unset default_pool_id on empty string + if m["default_pool_id"] == "" { m["default_pool_id"] = nil } + // allow to unset alpn_protocols on empty slice + if opts.ALPNProtocols != nil && len(*opts.ALPNProtocols) == 0 { + m["alpn_protocols"] = nil + } + + // allow to unset tls_versions on empty slice + if opts.TLSVersions != nil && len(*opts.TLSVersions) == 0 { + m["tls_versions"] = nil + } + return b, nil } // Update is an operation which modifies the attributes of the specified // Listener. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult) { b, err := opts.ToListenerUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -289,15 +394,15 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateR } // Delete will permanently delete a particular Listeners based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(resourceURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, resourceURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // GetStats will return the shows the current statistics of a particular Listeners. -func GetStats(c *gophercloud.ServiceClient, id string) (r StatsResult) { - resp, err := c.Get(statisticsRootURL(c, id), &r.Body, nil) +func GetStats(ctx context.Context, c *gophercloud.ServiceClient, id string) (r StatsResult) { + resp, err := c.Get(ctx, statisticsRootURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/results.go similarity index 86% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/results.go index 234b6cb06232b..0bd08f783ad63 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/results.go @@ -1,10 +1,10 @@ package listeners import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2/pagination" ) type LoadBalancerID struct { @@ -114,6 +114,24 @@ type Listener struct { // New in version 2.8 ClientCRLContainerRef string `json:"client_crl_container_ref"` + // Defines whether the includeSubDomains directive should be added to + // the Strict-Transport-Security HTTP response header. This requires + // setting the hsts_max_age option as well in order to become + // effective. Available from microversion 2.27. + HSTSIncludeSubdomains bool `json:"hsts_include_subdomains"` + + // The value of the max_age directive for the Strict-Transport-Security + // HTTP response header. Setting this enables HTTP Strict Transport + // Security (HSTS) for the TLS-terminated listener. Available from + // microversion 2.27. + HSTSMaxAge int `json:"hsts_max_age"` + + // Defines whether the preload directive should be added to the + // Strict-Transport-Security HTTP response header. This requires + // setting the hsts_max_age option as well in order to become + // effective. Available from microversion 2.27. + HSTSPreload bool `json:"hsts_preload"` + // The operating status of the resource OperatingStatus string `json:"operating_status"` } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/urls.go similarity index 90% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/urls.go index e9e3bccd3e720..77157c726c047 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners/urls.go @@ -1,6 +1,6 @@ package listeners -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const ( rootPath = "lbaas" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/doc.go similarity index 82% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/doc.go index 8587a0d99e4df..0e318558cdc5e 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/doc.go @@ -8,7 +8,7 @@ Example to List Load Balancers Provider: "haproxy", } - allPages, err := loadbalancers.List(networkClient, listOpts).AllPages() + allPages, err := loadbalancers.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -34,7 +34,7 @@ Example to Create a Load Balancer Tags: []string{"test", "stage"}, } - lb, err := loadbalancers.Create(networkClient, createOpts).Extract() + lb, err := loadbalancers.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -82,7 +82,7 @@ Example to Create a fully populated Load Balancer }}, } - lb, err := loadbalancers.Create(networkClient, createOpts).Extract() + lb, err := loadbalancers.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -94,7 +94,7 @@ Example to Update a Load Balancer updateOpts := loadbalancers.UpdateOpts{ Name: &name, } - lb, err := loadbalancers.Update(networkClient, lbID, updateOpts).Extract() + lb, err := loadbalancers.Update(context.TODO(), networkClient, lbID, updateOpts).Extract() if err != nil { panic(err) } @@ -107,7 +107,7 @@ Example to Delete a Load Balancers lbID := "d67d56a6-4a86-4688-a282-f46444705c64" - err := loadbalancers.Delete(networkClient, lbID, deleteOpts).ExtractErr() + err := loadbalancers.Delete(context.TODO(), networkClient, lbID, deleteOpts).ExtractErr() if err != nil { panic(err) } @@ -115,7 +115,7 @@ Example to Delete a Load Balancers Example to Get the Status of a Load Balancer lbID := "d67d56a6-4a86-4688-a282-f46444705c64" - status, err := loadbalancers.GetStatuses(networkClient, LBID).Extract() + status, err := loadbalancers.GetStatuses(context.TODO(), networkClient, LBID).Extract() if err != nil { panic(err) } @@ -123,7 +123,7 @@ Example to Get the Status of a Load Balancer Example to Get the Statistics of a Load Balancer lbID := "d67d56a6-4a86-4688-a282-f46444705c64" - stats, err := loadbalancers.GetStats(networkClient, LBID).Extract() + stats, err := loadbalancers.GetStats(context.TODO(), networkClient, LBID).Extract() if err != nil { panic(err) } @@ -132,7 +132,7 @@ Example to Failover a Load Balancers lbID := "d67d56a6-4a86-4688-a282-f46444705c64" - err := loadbalancers.Failover(networkClient, lbID).ExtractErr() + err := loadbalancers.Failover(context.TODO(), networkClient, lbID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/requests.go similarity index 82% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/requests.go index 099113c418771..f815806f39895 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/requests.go @@ -1,10 +1,12 @@ package loadbalancers import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -72,7 +74,7 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToLoadBalancerCreateMap() (map[string]interface{}, error) + ToLoadBalancerCreateMap() (map[string]any, error) } // CreateOpts is the common options struct used in this package's Create @@ -140,10 +142,14 @@ type CreateOpts struct { // Tags is a set of resource tags. Tags []string `json:"tags,omitempty"` + + // The additional ips of the loadbalancer. Subnets must all belong to the same network as the primary VIP. + // New in version 2.26 + AdditionalVips []AdditionalVip `json:"additional_vips,omitempty"` } // ToLoadBalancerCreateMap builds a request body from CreateOpts. -func (opts CreateOpts) ToLoadBalancerCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToLoadBalancerCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "loadbalancer") } @@ -151,20 +157,20 @@ func (opts CreateOpts) ToLoadBalancerCreateMap() (map[string]interface{}, error) // configuration defined in the CreateOpts struct. Once the request is // validated and progress has started on the provisioning process, a // CreateResult will be returned. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToLoadBalancerCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(rootURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, rootURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Get retrieves a particular Loadbalancer based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(resourceURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, resourceURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -172,7 +178,7 @@ func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToLoadBalancerUpdateMap() (map[string]interface{}, error) + ToLoadBalancerUpdateMap() (map[string]any, error) } // UpdateOpts is the common options struct used in this package's Update @@ -196,19 +202,19 @@ type UpdateOpts struct { } // ToLoadBalancerUpdateMap builds a request body from UpdateOpts. -func (opts UpdateOpts) ToLoadBalancerUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToLoadBalancerUpdateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "loadbalancer") } // Update is an operation which modifies the attributes of the specified // LoadBalancer. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult) { b, err := opts.ToLoadBalancerUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -236,7 +242,7 @@ func (opts DeleteOpts) ToLoadBalancerDeleteQuery() (string, error) { // Delete will permanently delete a particular LoadBalancer based on its // unique ID. -func Delete(c *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult) { +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult) { url := resourceURL(c, id) if opts != nil { query, err := opts.ToLoadBalancerDeleteQuery() @@ -246,28 +252,28 @@ func Delete(c *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) (r } url += query } - resp, err := c.Delete(url, nil) + resp, err := c.Delete(ctx, url, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // GetStatuses will return the status of a particular LoadBalancer. -func GetStatuses(c *gophercloud.ServiceClient, id string) (r GetStatusesResult) { - resp, err := c.Get(statusRootURL(c, id), &r.Body, nil) +func GetStatuses(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetStatusesResult) { + resp, err := c.Get(ctx, statusRootURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // GetStats will return the shows the current statistics of a particular LoadBalancer. -func GetStats(c *gophercloud.ServiceClient, id string) (r StatsResult) { - resp, err := c.Get(statisticsRootURL(c, id), &r.Body, nil) +func GetStats(ctx context.Context, c *gophercloud.ServiceClient, id string) (r StatsResult) { + resp, err := c.Get(ctx, statisticsRootURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Failover performs a failover of a load balancer. -func Failover(c *gophercloud.ServiceClient, id string) (r FailoverResult) { - resp, err := c.Put(failoverRootURL(c, id), nil, nil, &gophercloud.RequestOpts{ +func Failover(ctx context.Context, c *gophercloud.ServiceClient, id string) (r FailoverResult) { + resp, err := c.Put(ctx, failoverRootURL(c, id), nil, nil, &gophercloud.RequestOpts{ OkCodes: []int{202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/results.go similarity index 91% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/results.go index 71f750dd6adbe..67e5c749dfc2a 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/results.go @@ -4,10 +4,10 @@ import ( "encoding/json" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools" + "github.com/gophercloud/gophercloud/v2/pagination" ) // LoadBalancer is the primary load balancing configuration object that @@ -77,6 +77,16 @@ type LoadBalancer struct { // Tags is a list of resource tags. Tags are arbitrarily defined strings // attached to the resource. Tags []string `json:"tags"` + + // The additional ips of the loadbalancer. Subnets must all belong to the same network as the primary VIP. + // New in version 2.26 + AdditionalVips []AdditionalVip `json:"additional_vips"` +} + +// AdditionalVip represent additional ip of a loadbalancer. IpAddress field is optional. +type AdditionalVip struct { + SubnetID string `json:"subnet_id"` + IPAddress string `json:"ip_address,omitempty"` } func (r *LoadBalancer) UnmarshalJSON(b []byte) error { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/urls.go similarity index 94% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/urls.go index 7b184e35f6af2..221bc84e3dbff 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers/urls.go @@ -1,6 +1,6 @@ package loadbalancers -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const ( rootPath = "lbaas" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/doc.go similarity index 82% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/doc.go index b191b45e9c0e9..f471084cfd969 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/doc.go @@ -8,7 +8,7 @@ Example to List Monitors PoolID: "c79a4468-d788-410c-bf79-9a8ef6354852", } - allPages, err := monitors.List(networkClient, listOpts).AllPages() + allPages, err := monitors.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -36,7 +36,7 @@ Example to Create a Monitor ExpectedCodes: "200-299", } - monitor, err := monitors.Create(networkClient, createOpts).Extract() + monitor, err := monitors.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -55,7 +55,7 @@ Example to Update a Monitor ExpectedCodes: "301", } - monitor, err := monitors.Update(networkClient, monitorID, updateOpts).Extract() + monitor, err := monitors.Update(context.TODO(), networkClient, monitorID, updateOpts).Extract() if err != nil { panic(err) } @@ -63,7 +63,7 @@ Example to Update a Monitor Example to Delete a Monitor monitorID := "d67d56a6-4a86-4688-a282-f46444705c64" - err := monitors.Delete(networkClient, monitorID).ExtractErr() + err := monitors.Delete(context.TODO(), networkClient, monitorID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/requests.go similarity index 73% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/requests.go index 7d7466a0811f4..be5701c5f4f02 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/requests.go @@ -1,10 +1,10 @@ package monitors import ( - "fmt" + "context" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -19,25 +19,26 @@ type ListOptsBuilder interface { // sort by a particular Monitor attribute. SortDir sets the direction, and is // either `asc' or `desc'. Marker and Limit are used for pagination. type ListOpts struct { - ID string `q:"id"` - Name string `q:"name"` - TenantID string `q:"tenant_id"` - ProjectID string `q:"project_id"` - PoolID string `q:"pool_id"` - Type string `q:"type"` - Delay int `q:"delay"` - Timeout int `q:"timeout"` - MaxRetries int `q:"max_retries"` - MaxRetriesDown int `q:"max_retries_down"` - HTTPMethod string `q:"http_method"` - URLPath string `q:"url_path"` - ExpectedCodes string `q:"expected_codes"` - AdminStateUp *bool `q:"admin_state_up"` - Status string `q:"status"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` + ID string `q:"id"` + Name string `q:"name"` + TenantID string `q:"tenant_id"` + ProjectID string `q:"project_id"` + PoolID string `q:"pool_id"` + Type string `q:"type"` + Delay int `q:"delay"` + Timeout int `q:"timeout"` + MaxRetries int `q:"max_retries"` + MaxRetriesDown int `q:"max_retries_down"` + HTTPMethod string `q:"http_method"` + URLPath string `q:"url_path"` + ExpectedCodes string `q:"expected_codes"` + AdminStateUp *bool `q:"admin_state_up"` + Status string `q:"status"` + Limit int `q:"limit"` + Marker string `q:"marker"` + SortKey string `q:"sort_key"` + SortDir string `q:"sort_dir"` + Tags []string `q:"tags"` } // ToMonitorListQuery formats a ListOpts into a query string. @@ -80,14 +81,10 @@ const ( TypeSCTP = "SCTP" ) -var ( - errDelayMustGETimeout = fmt.Errorf("Delay must be greater than or equal to timeout") -) - // CreateOptsBuilder allows extensions to add additional parameters to the // List request. type CreateOptsBuilder interface { - ToMonitorCreateMap() (map[string]interface{}, error) + ToMonitorCreateMap() (map[string]any, error) } // CreateOpts is the common options struct used in this package's Create @@ -122,6 +119,10 @@ type CreateOpts struct { // is not specified, it defaults to "GET". Required for HTTP(S) types. HTTPMethod string `json:"http_method,omitempty"` + // The HTTP version. One of 1.0 or 1.1. The default is 1.0. New in + // version 2.10. + HTTPVersion string `json:"http_version,omitempty"` + // Expected HTTP codes for a passing HTTP(S) Monitor. You can either specify // a single status like "200", a range like "200-202", or a combination like // "200-202, 401". @@ -141,10 +142,17 @@ type CreateOpts struct { // The administrative state of the Monitor. A valid value is true (UP) // or false (DOWN). AdminStateUp *bool `json:"admin_state_up,omitempty"` + + // The domain name, which be injected into the HTTP Host Header to the + // backend server for HTTP health check. New in version 2.10 + DomainName string `json:"domain_name,omitempty"` + + // Tags is a set of resource tags. New in version 2.5 + Tags []string `json:"tags,omitempty"` } // ToMonitorCreateMap builds a request body from CreateOpts. -func (opts CreateOpts) ToMonitorCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToMonitorCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "healthmonitor") } @@ -163,20 +171,20 @@ Here is an example config struct to use when creating a HTTP(S) Monitor: CreateOpts{Type: TypeHTTP, Delay: 20, Timeout: 10, MaxRetries: 3, HttpMethod: "HEAD", ExpectedCodes: "200", PoolID: "2c946bfc-1804-43ab-a2ff-58f6a762b505"} */ -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToMonitorCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(rootURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, rootURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Get retrieves a particular Health Monitor based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(resourceURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, resourceURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -184,7 +192,7 @@ func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToMonitorUpdateMap() (map[string]interface{}, error) + ToMonitorUpdateMap() (map[string]any, error) } // UpdateOpts is the common options struct used in this package's Update @@ -213,6 +221,10 @@ type UpdateOpts struct { // is not specified, it defaults to "GET". Required for HTTP(S) types. HTTPMethod string `json:"http_method,omitempty"` + // The HTTP version. One of 1.0 or 1.1. The default is 1.0. New in + // version 2.10. + HTTPVersion *string `json:"http_version,omitempty"` + // Expected HTTP codes for a passing HTTP(S) Monitor. You can either specify // a single status like "200", or a range like "200-202". Required for HTTP(S) // types. @@ -221,26 +233,33 @@ type UpdateOpts struct { // The Name of the Monitor. Name *string `json:"name,omitempty"` + // The domain name, which be injected into the HTTP Host Header to the + // backend server for HTTP health check. New in version 2.10 + DomainName *string `json:"domain_name,omitempty"` + // The administrative state of the Monitor. 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"` } // ToMonitorUpdateMap builds a request body from UpdateOpts. -func (opts UpdateOpts) ToMonitorUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToMonitorUpdateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "healthmonitor") } // Update is an operation which modifies the attributes of the specified // Monitor. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToMonitorUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -248,8 +267,8 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r } // Delete will permanently delete a particular Monitor based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(resourceURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, resourceURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/results.go similarity index 92% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/results.go index 502581feba864..644ef187003a1 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/results.go @@ -1,8 +1,8 @@ package monitors import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type PoolID struct { @@ -60,6 +60,9 @@ type Monitor struct { // The HTTP method that the monitor uses for requests. HTTPMethod string `json:"http_method"` + // The HTTP version that the monitor uses for requests. + HTTPVersion string `json:"http_version"` + // The HTTP path of the request sent by the monitor to test the health of a // member. Must be a string beginning with a forward slash (/). URLPath string `json:"url_path" ` @@ -67,6 +70,9 @@ type Monitor struct { // Expected HTTP codes for a passing HTTP(S) monitor. ExpectedCodes string `json:"expected_codes"` + // The HTTP host header that the monitor uses for requests. + DomainName string `json:"domain_name"` + // The administrative state of the health monitor, which is up (true) or // down (false). AdminStateUp bool `json:"admin_state_up"` @@ -84,6 +90,10 @@ type Monitor struct { // The operating status of the monitor. 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"` } // MonitorPage is the page returned by a pager when traversing over a diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/urls.go similarity index 86% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/urls.go index a222e52a93dd4..d5723a305f42f 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors/urls.go @@ -1,6 +1,6 @@ package monitors -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const ( rootPath = "lbaas" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/doc.go similarity index 80% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/doc.go index 5657cd87334e4..f5156d661a230 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/doc.go @@ -8,7 +8,7 @@ Example to List Pools LoadbalancerID: "c79a4468-d788-410c-bf79-9a8ef6354852", } - allPages, err := pools.List(networkClient, listOpts).AllPages() + allPages, err := pools.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -32,7 +32,7 @@ Example to Create a Pool LoadbalancerID: "79e05663-7f03-45d2-a092-8b94062f22ab", } - pool, err := pools.Create(networkClient, createOpts).Extract() + pool, err := pools.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -47,7 +47,7 @@ Example to Update a Pool Tags: &newTags, } - pool, err := pools.Update(networkClient, poolID, updateOpts).Extract() + pool, err := pools.Update(context.TODO(), networkClient, poolID, updateOpts).Extract() if err != nil { panic(err) } @@ -55,7 +55,7 @@ Example to Update a Pool Example to Delete a Pool poolID := "d67d56a6-4a86-4688-a282-f46444705c64" - err := pools.Delete(networkClient, poolID).ExtractErr() + err := pools.Delete(context.TODO(), networkClient, poolID).ExtractErr() if err != nil { panic(err) } @@ -68,7 +68,7 @@ Example to List Pool Members ProtocolPort: 80, } - allPages, err := pools.ListMembers(networkClient, poolID, listOpts).AllPages() + allPages, err := pools.ListMembers(networkClient, poolID, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -95,7 +95,7 @@ Example to Create a Member Weight: &weight, } - member, err := pools.CreateMember(networkClient, poolID, createOpts).Extract() + member, err := pools.CreateMember(context.TODO(), networkClient, poolID, createOpts).Extract() if err != nil { panic(err) } @@ -111,7 +111,7 @@ Example to Update a Member Weight: &weight, } - member, err := pools.UpdateMember(networkClient, poolID, memberID, updateOpts).Extract() + member, err := pools.UpdateMember(context.TODO(), networkClient, poolID, memberID, updateOpts).Extract() if err != nil { panic(err) } @@ -121,7 +121,7 @@ Example to Delete a Member poolID := "d67d56a6-4a86-4688-a282-f46444705c64" memberID := "64dba99f-8af8-4200-8882-e32a0660f23e" - err := pools.DeleteMember(networkClient, poolID, memberID).ExtractErr() + err := pools.DeleteMember(context.TODO(), networkClient, poolID, memberID).ExtractErr() if err != nil { panic(err) } @@ -149,7 +149,7 @@ Example to Update Members: } members := []pools.BatchUpdateMemberOpts{member1, member2} - err := pools.BatchUpdateMembers(networkClient, poolID, members).ExtractErr() + err := pools.BatchUpdateMembers(context.TODO(), networkClient, poolID, members).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/requests.go similarity index 68% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/requests.go index 69e6a2a76371d..3443686370011 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/requests.go @@ -1,9 +1,22 @@ package pools import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors" + "github.com/gophercloud/gophercloud/v2/pagination" +) + +// Type TLSVersion represents a tls version +type TLSVersion string + +const ( + TLSVersionSSLv3 TLSVersion = "SSLv3" + TLSVersionTLSv1 TLSVersion = "TLSv1" + TLSVersionTLSv1_1 TLSVersion = "TLSv1.1" + TLSVersionTLSv1_2 TLSVersion = "TLSv1.2" + TLSVersionTLSv1_3 TLSVersion = "TLSv1.3" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -18,17 +31,18 @@ type ListOptsBuilder interface { // sort by a particular Pool attribute. SortDir sets the direction, and is // either `asc' or `desc'. Marker and Limit are used for pagination. type ListOpts struct { - LBMethod string `q:"lb_algorithm"` - Protocol string `q:"protocol"` - ProjectID string `q:"project_id"` - AdminStateUp *bool `q:"admin_state_up"` - Name string `q:"name"` - ID string `q:"id"` - LoadbalancerID string `q:"loadbalancer_id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` + LBMethod string `q:"lb_algorithm"` + Protocol string `q:"protocol"` + ProjectID string `q:"project_id"` + AdminStateUp *bool `q:"admin_state_up"` + Name string `q:"name"` + ID string `q:"id"` + LoadbalancerID string `q:"loadbalancer_id"` + Limit int `q:"limit"` + Marker string `q:"marker"` + SortKey string `q:"sort_key"` + SortDir string `q:"sort_dir"` + Tags []string `q:"tags"` } // ToPoolListQuery formats a ListOpts into a query string. @@ -81,7 +95,7 @@ const ( // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToPoolCreateMap() (map[string]interface{}, error) + ToPoolCreateMap() (map[string]any, error) } // CreateOpts is the common options struct used in this package's Create @@ -119,49 +133,80 @@ type CreateOpts struct { // Omit this field to prevent session persistence. Persistence *SessionPersistence `json:"session_persistence,omitempty"` + // A list of ALPN protocols. Available protocols: http/1.0, http/1.1, + // h2. Available from microversion 2.24. + ALPNProtocols []string `json:"alpn_protocols,omitempty"` + + // The reference of the key manager service secret containing a PEM + // format CA certificate bundle for tls_enabled pools. Available from + // microversion 2.8. + CATLSContainerRef string `json:"ca_tls_container_ref,omitempty"` + + // The reference of the key manager service secret containing a PEM + // format CA revocation list file for tls_enabled pools. Available from + // microversion 2.8. + CRLContainerRef string `json:"crl_container_ref,omitempty"` + + // When true connections to backend member servers will use TLS + // encryption. Default is false. Available from microversion 2.8. + TLSEnabled bool `json:"tls_enabled,omitempty"` + + // List of ciphers in OpenSSL format (colon-separated). Available from + // microversion 2.15. + TLSCiphers string `json:"tls_ciphers,omitempty"` + + // The reference to the key manager service secret containing a PKCS12 + // format certificate/key bundle for tls_enabled pools for TLS client + // authentication to the member servers. Available from microversion 2.8. + TLSContainerRef string `json:"tls_container_ref,omitempty"` + + // A list of TLS protocol versions. Available versions: SSLv3, TLSv1, + // TLSv1.1, TLSv1.2, TLSv1.3. Available from microversion 2.17. + TLSVersions []TLSVersion `json:"tls_versions,omitempty"` + // The administrative state of the Pool. A valid value is true (UP) // or false (DOWN). AdminStateUp *bool `json:"admin_state_up,omitempty"` - // Members is a slice of BatchUpdateMemberOpts which allows a set of + // Members is a slice of CreateMemberOpts which allows a set of // members to be created at the same time the pool is created. // // This is only possible to use when creating a fully populated // Loadbalancer. - Members []BatchUpdateMemberOpts `json:"members,omitempty"` + Members []CreateMemberOpts `json:"members,omitempty"` // Monitor is an instance of monitors.CreateOpts which allows a monitor // to be created at the same time the pool is created. // // This is only possible to use when creating a fully populated // Loadbalancer. - Monitor *monitors.CreateOpts `json:"healthmonitor,omitempty"` + Monitor monitors.CreateOptsBuilder `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. -func (opts CreateOpts) ToPoolCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToPoolCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "pool") } // Create accepts a CreateOpts struct and uses the values to create a new // load balancer pool. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToPoolCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(rootURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, rootURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Get retrieves a particular pool based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(resourceURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, resourceURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -169,7 +214,7 @@ func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToPoolUpdateMap() (map[string]interface{}, error) + ToPoolUpdateMap() (map[string]any, error) } // UpdateOpts is the common options struct used in this package's Update @@ -193,23 +238,76 @@ type UpdateOpts struct { // Persistence is the session persistence of the pool. Persistence *SessionPersistence `json:"session_persistence,omitempty"` + // A list of ALPN protocols. Available protocols: http/1.0, http/1.1, + // h2. Available from microversion 2.24. + ALPNProtocols *[]string `json:"alpn_protocols,omitempty"` + + // The reference of the key manager service secret containing a PEM + // format CA certificate bundle for tls_enabled pools. Available from + // microversion 2.8. + CATLSContainerRef *string `json:"ca_tls_container_ref,omitempty"` + + // The reference of the key manager service secret containing a PEM + // format CA revocation list file for tls_enabled pools. Available from + // microversion 2.8. + CRLContainerRef *string `json:"crl_container_ref,omitempty"` + + // When true connections to backend member servers will use TLS + // encryption. Default is false. Available from microversion 2.8. + TLSEnabled *bool `json:"tls_enabled,omitempty"` + + // List of ciphers in OpenSSL format (colon-separated). Available from + // microversion 2.15. + TLSCiphers *string `json:"tls_ciphers,omitempty"` + + // The reference to the key manager service secret containing a PKCS12 + // format certificate/key bundle for tls_enabled pools for TLS client + // authentication to the member servers. Available from microversion 2.8. + TLSContainerRef *string `json:"tls_container_ref,omitempty"` + + // A list of TLS protocol versions. Available versions: SSLv3, TLSv1, + // TLSv1.1, TLSv1.2, TLSv1.3. 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"` } // ToPoolUpdateMap builds a request body from UpdateOpts. -func (opts UpdateOpts) ToPoolUpdateMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "pool") +func (opts UpdateOpts) ToPoolUpdateMap() (map[string]any, error) { + b, err := gophercloud.BuildRequestBody(opts, "pool") + if err != nil { + return nil, err + } + + m := b["pool"].(map[string]any) + + // allow to unset session_persistence on empty SessionPersistence struct + if opts.Persistence != nil && *opts.Persistence == (SessionPersistence{}) { + m["session_persistence"] = nil + } + + // allow to unset alpn_protocols on empty slice + if opts.ALPNProtocols != nil && len(*opts.ALPNProtocols) == 0 { + m["alpn_protocols"] = nil + } + + // allow to unset tls_versions on empty slice + if opts.TLSVersions != nil && len(*opts.TLSVersions) == 0 { + m["tls_versions"] = nil + } + + return b, nil } // Update allows pools to be updated. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToPoolUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -217,8 +315,8 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r } // Delete will permanently delete a particular pool based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(resourceURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, resourceURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -277,7 +375,7 @@ func ListMembers(c *gophercloud.ServiceClient, poolID string, opts ListMembersOp // CreateMemberOptsBuilder allows extensions to add additional parameters to the // CreateMember request. type CreateMemberOptsBuilder interface { - ToMemberCreateMap() (map[string]interface{}, error) + ToMemberCreateMap() (map[string]any, error) } // CreateMemberOpts is the common options struct used in this package's CreateMember @@ -327,25 +425,25 @@ type CreateMemberOpts struct { } // ToMemberCreateMap builds a request body from CreateMemberOpts. -func (opts CreateMemberOpts) ToMemberCreateMap() (map[string]interface{}, error) { +func (opts CreateMemberOpts) ToMemberCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "member") } // CreateMember will create and associate a Member with a particular Pool. -func CreateMember(c *gophercloud.ServiceClient, poolID string, opts CreateMemberOptsBuilder) (r CreateMemberResult) { +func CreateMember(ctx context.Context, c *gophercloud.ServiceClient, poolID string, opts CreateMemberOptsBuilder) (r CreateMemberResult) { b, err := opts.ToMemberCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(memberRootURL(c, poolID), b, &r.Body, nil) + resp, err := c.Post(ctx, memberRootURL(c, poolID), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // GetMember retrieves a particular Pool Member based on its unique ID. -func GetMember(c *gophercloud.ServiceClient, poolID string, memberID string) (r GetMemberResult) { - resp, err := c.Get(memberResourceURL(c, poolID, memberID), &r.Body, nil) +func GetMember(ctx context.Context, c *gophercloud.ServiceClient, poolID string, memberID string) (r GetMemberResult) { + resp, err := c.Get(ctx, memberResourceURL(c, poolID, memberID), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -353,7 +451,7 @@ func GetMember(c *gophercloud.ServiceClient, poolID string, memberID string) (r // UpdateMemberOptsBuilder allows extensions to add additional parameters to the // List request. type UpdateMemberOptsBuilder interface { - ToMemberUpdateMap() (map[string]interface{}, error) + ToMemberUpdateMap() (map[string]any, error) } // UpdateMemberOpts is the common options struct used in this package's Update @@ -389,18 +487,18 @@ type UpdateMemberOpts struct { } // ToMemberUpdateMap builds a request body from UpdateMemberOpts. -func (opts UpdateMemberOpts) ToMemberUpdateMap() (map[string]interface{}, error) { +func (opts UpdateMemberOpts) ToMemberUpdateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "member") } // Update allows Member to be updated. -func UpdateMember(c *gophercloud.ServiceClient, poolID string, memberID string, opts UpdateMemberOptsBuilder) (r UpdateMemberResult) { +func UpdateMember(ctx context.Context, c *gophercloud.ServiceClient, poolID string, memberID string, opts UpdateMemberOptsBuilder) (r UpdateMemberResult) { b, err := opts.ToMemberUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(memberResourceURL(c, poolID, memberID), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, memberResourceURL(c, poolID, memberID), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200, 201, 202}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -409,7 +507,7 @@ func UpdateMember(c *gophercloud.ServiceClient, poolID string, memberID string, // BatchUpdateMemberOptsBuilder allows extensions to add additional parameters to the BatchUpdateMembers request. type BatchUpdateMemberOptsBuilder interface { - ToBatchMemberUpdateMap() (map[string]interface{}, error) + ToBatchMemberUpdateMap() (map[string]any, error) } // BatchUpdateMemberOpts is the common options struct used in this package's BatchUpdateMembers @@ -459,7 +557,7 @@ type BatchUpdateMemberOpts struct { } // ToBatchMemberUpdateMap builds a request body from BatchUpdateMemberOpts. -func (opts BatchUpdateMemberOpts) ToBatchMemberUpdateMap() (map[string]interface{}, error) { +func (opts BatchUpdateMemberOpts) ToBatchMemberUpdateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "") if err != nil { return nil, err @@ -473,8 +571,8 @@ func (opts BatchUpdateMemberOpts) ToBatchMemberUpdateMap() (map[string]interface } // BatchUpdateMembers updates the pool members in batch -func BatchUpdateMembers(c *gophercloud.ServiceClient, poolID string, opts []BatchUpdateMemberOpts) (r UpdateMembersResult) { - members := []map[string]interface{}{} +func BatchUpdateMembers[T BatchUpdateMemberOptsBuilder](ctx context.Context, c *gophercloud.ServiceClient, poolID string, opts []T) (r UpdateMembersResult) { + members := []map[string]any{} for _, opt := range opts { b, err := opt.ToBatchMemberUpdateMap() if err != nil { @@ -484,16 +582,16 @@ func BatchUpdateMembers(c *gophercloud.ServiceClient, poolID string, opts []Batc members = append(members, b) } - b := map[string]interface{}{"members": members} + b := map[string]any{"members": members} - resp, err := c.Put(memberRootURL(c, poolID), b, nil, &gophercloud.RequestOpts{OkCodes: []int{202}}) + resp, err := c.Put(ctx, memberRootURL(c, poolID), b, nil, &gophercloud.RequestOpts{OkCodes: []int{202}}) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // DeleteMember will remove and disassociate a Member from a particular Pool. -func DeleteMember(c *gophercloud.ServiceClient, poolID string, memberID string) (r DeleteMemberResult) { - resp, err := c.Delete(memberResourceURL(c, poolID, memberID), nil) +func DeleteMember(ctx context.Context, c *gophercloud.ServiceClient, poolID string, memberID string) (r DeleteMemberResult) { + resp, err := c.Delete(ctx, memberResourceURL(c, poolID, memberID), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/results.go similarity index 86% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/results.go index 44379b6f38b04..bff336ea4a130 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/results.go @@ -4,9 +4,9 @@ import ( "encoding/json" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors" + "github.com/gophercloud/gophercloud/v2/pagination" ) // SessionPersistence represents the session persistence feature of the load @@ -64,7 +64,7 @@ type Pool struct { Description string `json:"description"` // A list of listeners objects IDs. - Listeners []ListenerID `json:"listeners"` //[]map[string]interface{} + Listeners []ListenerID `json:"listeners"` //[]map[string]any // A list of member objects IDs. Members []Member `json:"members"` @@ -95,6 +95,37 @@ type Pool struct { // same Pool member or not. Persistence SessionPersistence `json:"session_persistence"` + // A list of ALPN protocols. Available protocols: http/1.0, http/1.1, + // h2. Available from microversion 2.24. + ALPNProtocols []string `json:"alpn_protocols"` + + // The reference of the key manager service secret containing a PEM + // format CA certificate bundle for tls_enabled pools. Available from + // microversion 2.8. + CATLSContainerRef string `json:"ca_tls_container_ref"` + + // The reference of the key manager service secret containing a PEM + // format CA revocation list file for tls_enabled pools. Available from + // microversion 2.8. + CRLContainerRef string `json:"crl_container_ref"` + + // When true connections to backend member servers will use TLS + // encryption. Default is false. Available from microversion 2.8. + TLSEnabled bool `json:"tls_enabled"` + + // List of ciphers in OpenSSL format (colon-separated). Available from + // microversion 2.15. + TLSCiphers string `json:"tls_ciphers"` + + // The reference to the key manager service secret containing a PKCS12 + // format certificate/key bundle for tls_enabled pools for TLS client + // authentication to the member servers. Available from microversion 2.8. + TLSContainerRef string `json:"tls_container_ref"` + + // A list of TLS protocol versions. Available versions: SSLv3, TLSv1, + // TLSv1.1, TLSv1.2, TLSv1.3. Available from microversion 2.17. + TLSVersions []string `json:"tls_versions"` + // The load balancer provider. Provider string `json:"provider"` diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/urls.go similarity index 93% rename from vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/urls.go index e7443c4f19160..a362f1b957164 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools/urls.go @@ -1,6 +1,6 @@ package pools -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const ( rootPath = "lbaas" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/doc.go similarity index 51% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/doc.go index f34b1e2e30b71..b511a05034b23 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/doc.go @@ -7,31 +7,31 @@ See https://developer.openstack.org/api-ref/network/v2/#standard-attributes-tag- Example to ReplaceAll Resource Tags - network, err := networks.Create(conn, createOpts).Extract() + network, err := networks.Create(context.TODO(), client, createOpts).Extract() tagReplaceAllOpts := attributestags.ReplaceAllOpts{ Tags: []string{"abc", "123"}, } - attributestags.ReplaceAll(conn, "networks", network.ID, tagReplaceAllOpts) + attributestags.ReplaceAll(context.TODO(), client, "networks", network.ID, tagReplaceAllOpts) Example to List all Resource Tags - tags, err = attributestags.List(conn, "networks", network.ID).Extract() + tags, err = attributestags.List(context.TODO(), client, "networks", network.ID).Extract() Example to Delete all Resource Tags - err = attributestags.DeleteAll(conn, "networks", network.ID).ExtractErr() + err = attributestags.DeleteAll(context.TODO(), client, "networks", network.ID).ExtractErr() Example to Add a tag to a Resource - err = attributestags.Add(client, "networks", network.ID, "atag").ExtractErr() + err = attributestags.Add(context.TODO(), client, "networks", network.ID, "atag").ExtractErr() Example to Delete a tag from a Resource - err = attributestags.Delete(client, "networks", network.ID, "atag").ExtractErr() + err = attributestags.Delete(context.TODO(), client, "networks", network.ID, "atag").ExtractErr() Example to confirm if a tag exists on a resource - exists, _ := attributestags.Confirm(client, "networks", network.ID, "atag").Extract() + exists, _ := attributestags.Confirm(context.TODO(), client, "networks", network.ID, "atag").Extract() */ package attributestags diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/requests.go similarity index 56% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/requests.go index 6d49aeaf6cd1b..f22a57385a72b 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/requests.go @@ -1,13 +1,15 @@ package attributestags import ( - "github.com/gophercloud/gophercloud" + "context" + + "github.com/gophercloud/gophercloud/v2" ) // ReplaceAllOptsBuilder allows extensions to add additional parameters to // the ReplaceAll request. type ReplaceAllOptsBuilder interface { - ToAttributeTagsReplaceAllMap() (map[string]interface{}, error) + ToAttributeTagsReplaceAllMap() (map[string]any, error) } // ReplaceAllOpts provides options used to create Tags on a Resource @@ -17,19 +19,19 @@ type ReplaceAllOpts struct { // ToAttributeTagsReplaceAllMap formats a ReplaceAllOpts into the body of the // replace request -func (opts ReplaceAllOpts) ToAttributeTagsReplaceAllMap() (map[string]interface{}, error) { +func (opts ReplaceAllOpts) ToAttributeTagsReplaceAllMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "") } // ReplaceAll updates all tags on a resource, replacing any existing tags -func ReplaceAll(client *gophercloud.ServiceClient, resourceType string, resourceID string, opts ReplaceAllOptsBuilder) (r ReplaceAllResult) { +func ReplaceAll(ctx context.Context, client *gophercloud.ServiceClient, resourceType string, resourceID string, opts ReplaceAllOptsBuilder) (r ReplaceAllResult) { b, err := opts.ToAttributeTagsReplaceAllMap() url := replaceURL(client, resourceType, resourceID) if err != nil { r.Err = err return } - resp, err := client.Put(url, &b, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Put(ctx, url, &b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -37,9 +39,9 @@ func ReplaceAll(client *gophercloud.ServiceClient, resourceType string, resource } // List all tags on a resource -func List(client *gophercloud.ServiceClient, resourceType string, resourceID string) (r ListResult) { +func List(ctx context.Context, client *gophercloud.ServiceClient, resourceType string, resourceID string) (r ListResult) { url := listURL(client, resourceType, resourceID) - resp, err := client.Get(url, &r.Body, &gophercloud.RequestOpts{ + resp, err := client.Get(ctx, url, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -47,9 +49,9 @@ func List(client *gophercloud.ServiceClient, resourceType string, resourceID str } // DeleteAll deletes all tags on a resource -func DeleteAll(client *gophercloud.ServiceClient, resourceType string, resourceID string) (r DeleteResult) { +func DeleteAll(ctx context.Context, client *gophercloud.ServiceClient, resourceType string, resourceID string) (r DeleteResult) { url := deleteAllURL(client, resourceType, resourceID) - resp, err := client.Delete(url, &gophercloud.RequestOpts{ + resp, err := client.Delete(ctx, url, &gophercloud.RequestOpts{ OkCodes: []int{204}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -57,9 +59,9 @@ func DeleteAll(client *gophercloud.ServiceClient, resourceType string, resourceI } // Add a tag on a resource -func Add(client *gophercloud.ServiceClient, resourceType string, resourceID string, tag string) (r AddResult) { +func Add(ctx context.Context, client *gophercloud.ServiceClient, resourceType string, resourceID string, tag string) (r AddResult) { url := addURL(client, resourceType, resourceID, tag) - resp, err := client.Put(url, nil, nil, &gophercloud.RequestOpts{ + resp, err := client.Put(ctx, url, nil, nil, &gophercloud.RequestOpts{ OkCodes: []int{201}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -67,9 +69,9 @@ func Add(client *gophercloud.ServiceClient, resourceType string, resourceID stri } // Delete a tag on a resource -func Delete(client *gophercloud.ServiceClient, resourceType string, resourceID string, tag string) (r DeleteResult) { +func Delete(ctx context.Context, client *gophercloud.ServiceClient, resourceType string, resourceID string, tag string) (r DeleteResult) { url := deleteURL(client, resourceType, resourceID, tag) - resp, err := client.Delete(url, &gophercloud.RequestOpts{ + resp, err := client.Delete(ctx, url, &gophercloud.RequestOpts{ OkCodes: []int{204}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -77,9 +79,9 @@ func Delete(client *gophercloud.ServiceClient, resourceType string, resourceID s } // Confirm if a tag exists on a resource -func Confirm(client *gophercloud.ServiceClient, resourceType string, resourceID string, tag string) (r ConfirmResult) { +func Confirm(ctx context.Context, client *gophercloud.ServiceClient, resourceType string, resourceID string, tag string) (r ConfirmResult) { url := confirmURL(client, resourceType, resourceID, tag) - resp, err := client.Get(url, nil, &gophercloud.RequestOpts{ + resp, err := client.Get(ctx, url, nil, &gophercloud.RequestOpts{ OkCodes: []int{204}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/results.go similarity index 89% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/results.go index cea8045beb017..9114cc7c282f3 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/results.go @@ -1,7 +1,9 @@ package attributestags import ( - "github.com/gophercloud/gophercloud" + "net/http" + + "github.com/gophercloud/gophercloud/v2" ) type tagResult struct { @@ -47,10 +49,8 @@ type ConfirmResult struct { func (r ConfirmResult) Extract() (bool, error) { exists := r.Err == nil - if r.Err != nil { - if _, ok := r.Err.(gophercloud.ErrDefault404); ok { - r.Err = nil - } + if gophercloud.ResponseCodeIs(r.Err, http.StatusNotFound) { + r.Err = nil } return exists, r.Err diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/urls.go similarity index 94% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/urls.go index 973e00c47cd73..94eb2b41d5bf7 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags/urls.go @@ -1,6 +1,6 @@ package attributestags -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const ( tagsPath = "tags" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external/doc.go similarity index 90% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external/doc.go index bec2c0f5f9c16..b8a6565b422b9 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external/doc.go @@ -18,7 +18,7 @@ Example to List Networks with External Information var allNetworks []NetworkWithExternalExt - allPages, err := networks.List(networkClient, listOpts).AllPages() + allPages, err := networks.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -45,7 +45,7 @@ Example to Create a Network with External Information &iTrue, } - network, err := networks.Create(networkClient, createOpts).Extract() + network, err := networks.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external/requests.go similarity index 83% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external/requests.go index ced5efed8d970..c62d992ebfa29 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external/requests.go @@ -4,8 +4,8 @@ import ( "net/url" "strconv" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks" ) // ListOptsExt adds the external network options to the base ListOpts. @@ -42,7 +42,7 @@ type CreateOptsExt struct { // ToNetworkCreateMap adds the router:external options to the base network // creation options. -func (opts CreateOptsExt) ToNetworkCreateMap() (map[string]interface{}, error) { +func (opts CreateOptsExt) ToNetworkCreateMap() (map[string]any, error) { base, err := opts.CreateOptsBuilder.ToNetworkCreateMap() if err != nil { return nil, err @@ -52,7 +52,7 @@ func (opts CreateOptsExt) ToNetworkCreateMap() (map[string]interface{}, error) { return base, nil } - networkMap := base["network"].(map[string]interface{}) + networkMap := base["network"].(map[string]any) networkMap["router:external"] = opts.External return base, nil @@ -67,7 +67,7 @@ type UpdateOptsExt struct { } // ToNetworkUpdateMap casts an UpdateOpts struct to a map. -func (opts UpdateOptsExt) ToNetworkUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOptsExt) ToNetworkUpdateMap() (map[string]any, error) { base, err := opts.UpdateOptsBuilder.ToNetworkUpdateMap() if err != nil { return nil, err @@ -77,7 +77,7 @@ func (opts UpdateOptsExt) ToNetworkUpdateMap() (map[string]interface{}, error) { return base, nil } - networkMap := base["network"].(map[string]interface{}) + networkMap := base["network"].(map[string]any) networkMap["router:external"] = opts.External return base, nil diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external/results.go similarity index 100% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external/results.go diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/doc.go similarity index 76% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/doc.go index a71a3ec88a9b4..ab54042a431f4 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/doc.go @@ -8,7 +8,7 @@ Example to List Floating IPs FloatingNetworkID: "a6917946-38ab-4ffd-a55a-26c0980ce5ee", } - allPages, err := floatingips.List(networkClient, listOpts).AllPages() + allPages, err := floatingips.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -28,7 +28,7 @@ Example to Create a Floating IP FloatingNetworkID: "a6917946-38ab-4ffd-a55a-26c0980ce5ee", } - fip, err := floatingips.Create(networkingClient, createOpts).Extract() + fip, err := floatingips.Create(context.TODO(), networkingClient, createOpts).Extract() if err != nil { panic(err) } @@ -42,7 +42,7 @@ Example to Update a Floating IP PortID: &portID, } - fip, err := floatingips.Update(networkingClient, fipID, updateOpts).Extract() + fip, err := floatingips.Update(context.TODO(), networkingClient, fipID, updateOpts).Extract() if err != nil { panic(err) } @@ -55,7 +55,7 @@ Example to Disassociate a Floating IP with a Port PortID: new(string), } - fip, err := floatingips.Update(networkingClient, fipID, updateOpts).Extract() + fip, err := floatingips.Update(context.TODO(), networkingClient, fipID, updateOpts).Extract() if err != nil { panic(err) } @@ -63,7 +63,7 @@ Example to Disassociate a Floating IP with a Port Example to Delete a Floating IP fipID := "2f245a7b-796b-4f26-9cf9-9e82d248fda7" - err := floatingips.Delete(networkClient, fipID).ExtractErr() + err := floatingips.Delete(context.TODO(), networkClient, fipID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/requests.go similarity index 85% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/requests.go index 2a4ff1aca433d..a3afb0403c91e 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/requests.go @@ -1,8 +1,10 @@ package floatingips import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -63,7 +65,7 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToFloatingIPCreateMap() (map[string]interface{}, error) + ToFloatingIPCreateMap() (map[string]any, error) } // CreateOpts contains all the values needed to create a new floating IP @@ -82,7 +84,7 @@ type CreateOpts struct { // ToFloatingIPCreateMap allows CreateOpts to satisfy the CreateOptsBuilder // interface -func (opts CreateOpts) ToFloatingIPCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToFloatingIPCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "floatingip") } @@ -110,20 +112,20 @@ func (opts CreateOpts) ToFloatingIPCreateMap() (map[string]interface{}, error) { // operation will fail and return a 400 error code. If the PortID and FixedIP // are already associated with another resource, the operation will fail and // returns a 409 error code. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToFloatingIPCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(rootURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, rootURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Get retrieves a particular floating IP resource based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(resourceURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, resourceURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -131,7 +133,7 @@ func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToFloatingIPUpdateMap() (map[string]interface{}, error) + ToFloatingIPUpdateMap() (map[string]any, error) } // UpdateOpts contains the values used when updating a floating IP resource. The @@ -146,13 +148,13 @@ type UpdateOpts struct { // ToFloatingIPUpdateMap allows UpdateOpts to satisfy the UpdateOptsBuilder // interface -func (opts UpdateOpts) ToFloatingIPUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToFloatingIPUpdateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "floatingip") if err != nil { return nil, err } - if m := b["floatingip"].(map[string]interface{}); m["port_id"] == "" { + if m := b["floatingip"].(map[string]any); m["port_id"] == "" { m["port_id"] = nil } @@ -163,13 +165,13 @@ func (opts UpdateOpts) ToFloatingIPUpdateMap() (map[string]interface{}, error) { // "update" a floating IP is to associate it with a new internal port, or // disassociated it from all ports. See UpdateOpts for instructions of how to // do this. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToFloatingIPUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -179,8 +181,8 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r // Delete will permanently delete a particular floating IP resource. Please // ensure this is what you want - you can also disassociate the IP from existing // internal ports. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(resourceURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, resourceURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/results.go similarity index 95% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/results.go index c4c019bca4997..50740ebf30025 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/results.go @@ -4,8 +4,8 @@ import ( "encoding/json" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // FloatingIP represents a floating IP resource. A floating IP is an external @@ -107,7 +107,7 @@ func (r commonResult) Extract() (*FloatingIP, error) { return &s, err } -func (r commonResult) ExtractInto(v interface{}) error { +func (r commonResult) ExtractInto(v any) error { return r.Result.ExtractIntoStructPtr(v, "floatingip") } @@ -176,6 +176,6 @@ func ExtractFloatingIPs(r pagination.Page) ([]FloatingIP, error) { return s.FloatingIPs, err } -func ExtractFloatingIPsInto(r pagination.Page, v interface{}) error { +func ExtractFloatingIPsInto(r pagination.Page, v any) error { return r.(FloatingIPPage).Result.ExtractIntoSlicePtr(v, "floatingips") } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/urls.go similarity index 84% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/urls.go index 1318a184caaa0..4352321a30806 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips/urls.go @@ -1,6 +1,6 @@ package floatingips -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const resourcePath = "floatingips" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/doc.go similarity index 77% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/doc.go index fb20e2ef54851..42ccbcf7cfbd0 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/doc.go @@ -5,7 +5,7 @@ Networking service. Example to List Routers listOpts := routers.ListOpts{} - allPages, err := routers.List(networkClient, listOpts).AllPages() + allPages, err := routers.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -32,7 +32,7 @@ Example to Create a Router GatewayInfo: &gwi, } - router, err := routers.Create(networkClient, createOpts).Extract() + router, err := routers.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -51,7 +51,7 @@ Example to Update a Router Routes: &routes, } - router, err := routers.Update(networkClient, routerID, updateOpts).Extract() + router, err := routers.Update(context.TODO(), networkClient, routerID, updateOpts).Extract() if err != nil { panic(err) } @@ -64,7 +64,7 @@ Example to Update just the Router name, keeping everything else as-is Name: "new_name", } - router, err := routers.Update(networkClient, routerID, updateOpts).Extract() + router, err := routers.Update(context.TODO(), networkClient, routerID, updateOpts).Extract() if err != nil { panic(err) } @@ -79,7 +79,7 @@ Example to Remove all Routes from a Router Routes: &routes, } - router, err := routers.Update(networkClient, routerID, updateOpts).Extract() + router, err := routers.Update(context.TODO(), networkClient, routerID, updateOpts).Extract() if err != nil { panic(err) } @@ -87,7 +87,7 @@ Example to Remove all Routes from a Router Example to Delete a Router routerID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c" - err := routers.Delete(networkClient, routerID).ExtractErr() + err := routers.Delete(context.TODO(), networkClient, routerID).ExtractErr() if err != nil { panic(err) } @@ -100,7 +100,7 @@ Example to Add an Interface to a Router SubnetID: "a2f1f29d-571b-4533-907f-5803ab96ead1", } - interface, err := routers.AddInterface(networkClient, routerID, intOpts).Extract() + interface, err := routers.AddInterface(context.TODO(), networkClient, routerID, intOpts).Extract() if err != nil { panic(err) } @@ -113,7 +113,7 @@ Example to Remove an Interface from a Router SubnetID: "a2f1f29d-571b-4533-907f-5803ab96ead1", } - interface, err := routers.RemoveInterface(networkClient, routerID, intOpts).Extract() + interface, err := routers.RemoveInterface(context.TODO(), networkClient, routerID, intOpts).Extract() if err != nil { panic(err) } @@ -122,7 +122,7 @@ Example to List an L3 agents for a Router routerID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c" - allPages, err := routers.ListL3Agents(networkClient, routerID).AllPages() + allPages, err := routers.ListL3Agents(networkClient, routerID).AllPages(context.TODO()) if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/requests.go similarity index 84% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/requests.go index 81665acef4afc..dcc7977a4607b 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/requests.go @@ -1,8 +1,10 @@ package routers import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOpts allows the filtering and sorting of paginated collections through @@ -49,7 +51,7 @@ func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToRouterCreateMap() (map[string]interface{}, error) + ToRouterCreateMap() (map[string]any, error) } // CreateOpts contains all the values needed to create a new router. There are @@ -66,7 +68,7 @@ type CreateOpts struct { } // ToRouterCreateMap builds a create request body from CreateOpts. -func (opts CreateOpts) ToRouterCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToRouterCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "router") } @@ -78,20 +80,20 @@ func (opts CreateOpts) ToRouterCreateMap() (map[string]interface{}, error) { // GatewayInfo struct. The external gateway for the router must be plugged into // an external network (it is external if its `router:external' field is set to // true). -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToRouterCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(rootURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, rootURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Get retrieves a particular router based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(resourceURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, resourceURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -99,7 +101,7 @@ func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToRouterUpdateMap() (map[string]interface{}, error) + ToRouterUpdateMap() (map[string]any, error) } // UpdateOpts contains the values used when updating a router. @@ -113,7 +115,7 @@ type UpdateOpts struct { } // ToRouterUpdateMap builds an update body based on UpdateOpts. -func (opts UpdateOpts) ToRouterUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToRouterUpdateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "router") } @@ -122,13 +124,13 @@ func (opts UpdateOpts) ToRouterUpdateMap() (map[string]interface{}, error) { // external gateway for a router, see Create. This operation does not enable // the update of router interfaces. To do this, use the AddInterface and // RemoveInterface functions. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToRouterUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -136,8 +138,8 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r } // Delete will permanently delete a particular router based on its unique ID. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(resourceURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, resourceURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -145,7 +147,7 @@ func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { // AddInterfaceOptsBuilder allows extensions to add additional parameters to // the AddInterface request. type AddInterfaceOptsBuilder interface { - ToRouterAddInterfaceMap() (map[string]interface{}, error) + ToRouterAddInterfaceMap() (map[string]any, error) } // AddInterfaceOpts represents the options for adding an interface to a router. @@ -155,7 +157,7 @@ type AddInterfaceOpts struct { } // ToRouterAddInterfaceMap builds a request body from AddInterfaceOpts. -func (opts AddInterfaceOpts) ToRouterAddInterfaceMap() (map[string]interface{}, error) { +func (opts AddInterfaceOpts) ToRouterAddInterfaceMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "") } @@ -180,13 +182,13 @@ func (opts AddInterfaceOpts) ToRouterAddInterfaceMap() (map[string]interface{}, // identifier of a new port created by this operation. After the operation // completes, the device ID of the port is set to the router ID, and the // device owner attribute is set to `network:router_interface'. -func AddInterface(c *gophercloud.ServiceClient, id string, opts AddInterfaceOptsBuilder) (r InterfaceResult) { +func AddInterface(ctx context.Context, c *gophercloud.ServiceClient, id string, opts AddInterfaceOptsBuilder) (r InterfaceResult) { b, err := opts.ToRouterAddInterfaceMap() if err != nil { r.Err = err return } - resp, err := c.Put(addInterfaceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, addInterfaceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -196,7 +198,7 @@ func AddInterface(c *gophercloud.ServiceClient, id string, opts AddInterfaceOpts // RemoveInterfaceOptsBuilder allows extensions to add additional parameters to // the RemoveInterface request. type RemoveInterfaceOptsBuilder interface { - ToRouterRemoveInterfaceMap() (map[string]interface{}, error) + ToRouterRemoveInterfaceMap() (map[string]any, error) } // RemoveInterfaceOpts represents options for removing an interface from @@ -208,7 +210,7 @@ type RemoveInterfaceOpts struct { // ToRouterRemoveInterfaceMap builds a request body based on // RemoveInterfaceOpts. -func (opts RemoveInterfaceOpts) ToRouterRemoveInterfaceMap() (map[string]interface{}, error) { +func (opts RemoveInterfaceOpts) ToRouterRemoveInterfaceMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "") } @@ -225,13 +227,13 @@ func (opts RemoveInterfaceOpts) ToRouterRemoveInterfaceMap() (map[string]interfa // visible to you, the operation will fail and a 404 Not Found error will be // returned. After this operation completes, the port connecting the router // with the subnet is removed from the subnet for the network. -func RemoveInterface(c *gophercloud.ServiceClient, id string, opts RemoveInterfaceOptsBuilder) (r InterfaceResult) { +func RemoveInterface(ctx context.Context, c *gophercloud.ServiceClient, id string, opts RemoveInterfaceOptsBuilder) (r InterfaceResult) { b, err := opts.ToRouterRemoveInterfaceMap() if err != nil { r.Err = err return } - resp, err := c.Put(removeInterfaceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, removeInterfaceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/results.go similarity index 97% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/results.go index 1c93eab506bc3..25e8ab7b597a6 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/results.go @@ -4,8 +4,8 @@ import ( "encoding/json" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // GatewayInfo represents the information of an external gateway for any @@ -214,7 +214,7 @@ type L3Agent struct { // Configurations is a configuration specific key/value pairs that are // determined by the agent binary and type. - Configurations map[string]interface{} `json:"configurations"` + Configurations map[string]any `json:"configurations"` // CreatedAt is a creation timestamp. CreatedAt time.Time `json:"-"` @@ -238,7 +238,7 @@ type L3Agent struct { HAState string `json:"ha_state"` // ResourceVersions is a list agent known objects and version numbers - ResourceVersions map[string]interface{} `json:"resource_versions"` + ResourceVersions map[string]any `json:"resource_versions"` } // UnmarshalJSON helps to convert the timestamps into the time.Time type. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/urls.go similarity index 93% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/urls.go index 7b30f9033c2d4..87815aa6ece34 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers/urls.go @@ -1,6 +1,6 @@ package routers -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const resourcePath = "routers" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/doc.go similarity index 78% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/doc.go index 7d8bbcaacbad0..298d617127a5c 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/doc.go @@ -8,7 +8,7 @@ Example to List Security Groups TenantID: "966b3c7d36a24facaf20b7e458bf2192", } - allPages, err := groups.List(networkClient, listOpts).AllPages() + allPages, err := groups.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -29,7 +29,7 @@ Example to Create a Security Group Description: "A Security Group", } - group, err := groups.Create(networkClient, createOpts).Extract() + group, err := groups.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -42,7 +42,7 @@ Example to Update a Security Group Name: "new_name", } - group, err := groups.Update(networkClient, groupID, updateOpts).Extract() + group, err := groups.Update(context.TODO(), networkClient, groupID, updateOpts).Extract() if err != nil { panic(err) } @@ -50,7 +50,7 @@ Example to Update a Security Group Example to Delete a Security Group groupID := "37d94f8a-d136-465c-ae46-144f0d8ef141" - err := groups.Delete(networkClient, groupID).ExtractErr() + err := groups.Delete(context.TODO(), networkClient, groupID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/requests.go similarity index 80% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/requests.go index 645f87cfa9809..fabb744114f56 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/requests.go @@ -1,8 +1,10 @@ package groups import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOpts allows the filtering and sorting of paginated collections through @@ -44,7 +46,7 @@ func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToSecGroupCreateMap() (map[string]interface{}, error) + ToSecGroupCreateMap() (map[string]any, error) } // CreateOpts contains all the values needed to create a new security group. @@ -68,19 +70,19 @@ type CreateOpts struct { } // ToSecGroupCreateMap builds a request body from CreateOpts. -func (opts CreateOpts) ToSecGroupCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToSecGroupCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "security_group") } // Create is an operation which provisions a new security group with default // security group rules for the IPv4 and IPv6 ether types. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToSecGroupCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(rootURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, rootURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -88,7 +90,7 @@ func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResul // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToSecGroupUpdateMap() (map[string]interface{}, error) + ToSecGroupUpdateMap() (map[string]any, error) } // UpdateOpts contains all the values needed to update an existing security @@ -105,19 +107,19 @@ type UpdateOpts struct { } // ToSecGroupUpdateMap builds a request body from UpdateOpts. -func (opts UpdateOpts) ToSecGroupUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToSecGroupUpdateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "security_group") } // Update is an operation which updates an existing security group. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToSecGroupUpdateMap() if err != nil { r.Err = err return } - resp, err := c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -125,16 +127,16 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r } // Get retrieves a particular security group based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(resourceURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, resourceURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Delete will permanently delete a particular security group based on its // unique ID. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(resourceURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, resourceURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/results.go similarity index 95% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/results.go index f892bcb5c2a48..b3aa2efb48d60 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/results.go @@ -4,9 +4,9 @@ import ( "encoding/json" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules" + "github.com/gophercloud/gophercloud/v2/pagination" ) // SecGroup represents a container for security group rules. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/urls.go similarity index 83% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/urls.go index 104cbcc558dcd..8c445868a6ae4 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups/urls.go @@ -1,6 +1,6 @@ package groups -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const rootPath = "security-groups" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/doc.go similarity index 79% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/doc.go index bf66dc8b40e02..fde5e13055bfa 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/doc.go @@ -8,7 +8,7 @@ Example to List Security Groups Rules Protocol: "tcp", } - allPages, err := rules.List(networkClient, listOpts).AllPages() + allPages, err := rules.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -34,7 +34,7 @@ Example to Create a Security Group Rule SecGroupID: "a7734e61-b545-452d-a3cd-0189cbd9747a", } - rule, err := rules.Create(networkClient, createOpts).Extract() + rule, err := rules.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -42,7 +42,7 @@ Example to Create a Security Group Rule Example to Delete a Security Group Rule ruleID := "37d94f8a-d136-465c-ae46-144f0d8ef141" - err := rules.Delete(networkClient, ruleID).ExtractErr() + err := rules.Delete(context.TODO(), networkClient, ruleID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/requests.go similarity index 89% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/requests.go index 480b1510ca355..f2ea9f2d164f5 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/requests.go @@ -1,8 +1,10 @@ package rules import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOpts allows the filtering and sorting of paginated collections through @@ -81,7 +83,7 @@ const ( // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToSecGroupRuleCreateMap() (map[string]interface{}, error) + ToSecGroupRuleCreateMap() (map[string]any, error) } // CreateOpts contains all the values needed to create a new security group @@ -131,34 +133,34 @@ type CreateOpts struct { } // ToSecGroupRuleCreateMap builds a request body from CreateOpts. -func (opts CreateOpts) ToSecGroupRuleCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToSecGroupRuleCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "security_group_rule") } // Create is an operation which adds a new security group rule and associates it // with an existing security group (whose ID is specified in CreateOpts). -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToSecGroupRuleCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(rootURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, rootURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Get retrieves a particular security group rule based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(resourceURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, resourceURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } // Delete will permanently delete a particular security group rule based on its // unique ID. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(resourceURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, resourceURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/results.go similarity index 97% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/results.go index 1e65f0627ca51..cfdb27fa17e80 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/results.go @@ -1,8 +1,8 @@ package rules import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // SecGroupRule represents a rule to dictate the behaviour of incoming or diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/urls.go similarity index 84% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/urls.go index a5ede0e89b91b..98c9ea7c27aeb 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules/urls.go @@ -1,6 +1,6 @@ package rules -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" const rootPath = "security-group-rules" diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/doc.go similarity index 82% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/doc.go index 9d1dd5a7ea4ee..4f8ce23aec444 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/doc.go @@ -14,7 +14,7 @@ Example to List Networks TenantID: "a99e9b4e620e4db09a2dfb6e42a01e66", } - allPages, err := networks.List(networkClient, listOpts).AllPages() + allPages, err := networks.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -36,7 +36,7 @@ Example to Create a Network AdminStateUp: &iTrue, } - network, err := networks.Create(networkClient, createOpts).Extract() + network, err := networks.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -50,7 +50,7 @@ Example to Update a Network Name: &name, } - network, err := networks.Update(networkClient, networkID, updateOpts).Extract() + network, err := networks.Update(context.TODO(), networkClient, networkID, updateOpts).Extract() if err != nil { panic(err) } @@ -58,7 +58,7 @@ Example to Update a Network Example to Delete a Network networkID := "484cda0e-106f-4f4b-bb3f-d413710bbe78" - err := networks.Delete(networkClient, networkID).ExtractErr() + err := networks.Delete(context.TODO(), networkClient, networkID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/requests.go similarity index 82% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/requests.go index 00c2eae77df35..29d14187ab5a9 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/requests.go @@ -1,10 +1,11 @@ package networks import ( + "context" "fmt" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -61,8 +62,8 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { } // Get retrieves a specific network based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(getURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, getURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -70,7 +71,7 @@ func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToNetworkCreateMap() (map[string]interface{}, error) + ToNetworkCreateMap() (map[string]any, error) } // CreateOpts represents options used to create a network. @@ -85,7 +86,7 @@ type CreateOpts struct { } // ToNetworkCreateMap builds a request body from CreateOpts. -func (opts CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToNetworkCreateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "network") } @@ -96,13 +97,13 @@ func (opts CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) { // The tenant ID that is contained in the URI is the tenant that creates the // network. An admin user, however, has the option of specifying another tenant // ID in the CreateOpts struct. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToNetworkCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(createURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, createURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -110,7 +111,7 @@ func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResul // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToNetworkUpdateMap() (map[string]interface{}, error) + ToNetworkUpdateMap() (map[string]any, error) } // UpdateOpts represents options used to update a network. @@ -127,13 +128,13 @@ type UpdateOpts struct { } // ToNetworkUpdateMap builds a request body from UpdateOpts. -func (opts UpdateOpts) ToNetworkUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToNetworkUpdateMap() (map[string]any, error) { return gophercloud.BuildRequestBody(opts, "network") } // Update accepts a UpdateOpts struct and updates an existing network using the // values provided. For more information, see the Create function. -func Update(c *gophercloud.ServiceClient, networkID string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, networkID string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToNetworkUpdateMap() if err != nil { r.Err = err @@ -149,7 +150,7 @@ func Update(c *gophercloud.ServiceClient, networkID string, opts UpdateOptsBuild h[k] = fmt.Sprintf("revision_number=%s", h[k]) } } - resp, err := c.Put(updateURL(c, networkID), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, updateURL(c, networkID), b, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{200, 201}, }) @@ -158,8 +159,8 @@ func Update(c *gophercloud.ServiceClient, networkID string, opts UpdateOptsBuild } // Delete accepts a unique ID and deletes the network associated with it. -func Delete(c *gophercloud.ServiceClient, networkID string) (r DeleteResult) { - resp, err := c.Delete(deleteURL(c, networkID), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, networkID string) (r DeleteResult) { + resp, err := c.Delete(ctx, deleteURL(c, networkID), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/results.go similarity index 95% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/results.go index 2a020a13f0559..53927bf0c0d2b 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/results.go @@ -4,8 +4,8 @@ import ( "encoding/json" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type commonResult struct { @@ -19,7 +19,7 @@ func (r commonResult) Extract() (*Network, error) { return &s, err } -func (r commonResult) ExtractInto(v interface{}) error { +func (r commonResult) ExtractInto(v any) error { return r.Result.ExtractIntoStructPtr(v, "network") } @@ -172,6 +172,6 @@ func ExtractNetworks(r pagination.Page) ([]Network, error) { return s, err } -func ExtractNetworksInto(r pagination.Page, v interface{}) error { +func ExtractNetworksInto(r pagination.Page, v any) error { return r.(NetworkPage).Result.ExtractIntoSlicePtr(v, "networks") } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/urls.go similarity index 93% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/urls.go index 4a8fb1dc7d3cd..14c352e395941 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/networks/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks/urls.go @@ -1,6 +1,6 @@ package networks -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func resourceURL(c *gophercloud.ServiceClient, id string) string { return c.ServiceURL("networks", id) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/doc.go similarity index 83% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/doc.go index cfb1774fb4b19..025ad4fa9432f 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/doc.go @@ -14,7 +14,7 @@ Example to List Ports DeviceID: "b0b89efe-82f8-461d-958b-adbf80f50c7d", } - allPages, err := ports.List(networkClient, listOpts).AllPages() + allPages, err := ports.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -43,7 +43,7 @@ Example to Create a Port }, } - port, err := ports.Create(networkClient, createOpts).Extract() + port, err := ports.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -57,7 +57,7 @@ Example to Update a Port SecurityGroups: &[]string{}, } - port, err := ports.Update(networkClient, portID, updateOpts).Extract() + port, err := ports.Update(context.TODO(), networkClient, portID, updateOpts).Extract() if err != nil { panic(err) } @@ -65,7 +65,7 @@ Example to Update a Port Example to Delete a Port portID := "c34bae2b-7641-49b6-bf6d-d8e473620ed8" - err := ports.Delete(networkClient, portID).ExtractErr() + err := ports.Delete(context.TODO(), networkClient, portID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/requests.go similarity index 72% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/requests.go index 805f0e5b994de..218c2897f70ef 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/requests.go @@ -1,12 +1,13 @@ package ports import ( + "context" "fmt" "net/url" - "strings" + "slices" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -50,7 +51,7 @@ type FixedIPOpts struct { SubnetID string } -func (f FixedIPOpts) String() string { +func (f FixedIPOpts) toParams() []string { var res []string if f.IPAddress != "" { res = append(res, fmt.Sprintf("ip_address=%s", f.IPAddress)) @@ -61,7 +62,7 @@ func (f FixedIPOpts) String() string { if f.SubnetID != "" { res = append(res, fmt.Sprintf("subnet_id=%s", f.SubnetID)) } - return strings.Join(res, ",") + return res } // ToPortListQuery formats a ListOpts into a query string. @@ -69,7 +70,9 @@ func (opts ListOpts) ToPortListQuery() (string, error) { q, err := gophercloud.BuildQueryString(opts) params := q.Query() for _, fixedIP := range opts.FixedIPs { - params.Add("fixed_ips", fixedIP.String()) + for _, fixedIPParam := range fixedIP.toParams() { + params.Add("fixed_ips", fixedIPParam) + } } q = &url.URL{RawQuery: params.Encode()} return q.String(), err @@ -97,8 +100,8 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { } // Get retrieves a specific port based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(getURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, getURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -106,7 +109,7 @@ func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { // CreateOptsBuilder allows extensions to add additional parameters to the // Create request. type CreateOptsBuilder interface { - ToPortCreateMap() (map[string]interface{}, error) + ToPortCreateMap() (map[string]any, error) } // CreateOpts represents the attributes used when creating a new port. @@ -116,7 +119,7 @@ type CreateOpts struct { Description string `json:"description,omitempty"` AdminStateUp *bool `json:"admin_state_up,omitempty"` MACAddress string `json:"mac_address,omitempty"` - FixedIPs interface{} `json:"fixed_ips,omitempty"` + FixedIPs any `json:"fixed_ips,omitempty"` DeviceID string `json:"device_id,omitempty"` DeviceOwner string `json:"device_owner,omitempty"` TenantID string `json:"tenant_id,omitempty"` @@ -128,19 +131,49 @@ type CreateOpts struct { } // ToPortCreateMap builds a request body from CreateOpts. -func (opts CreateOpts) ToPortCreateMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "port") +func (opts CreateOpts) ToPortCreateMap() (map[string]any, error) { + body, err := gophercloud.BuildRequestBody(opts, "port") + if err != nil { + return nil, err + } + + return AddValueSpecs(body) +} + +// AddValueSpecs expands the 'value_specs' object and removes 'value_specs' +// from the request body. It will return error if the value specs would overwrite +// an existing field or contains forbidden keys. +func AddValueSpecs(body map[string]any) (map[string]any, error) { + // Banned the same as in heat. See https://github.com/openstack/heat/blob/dd7319e373b88812cb18897f742b5196a07227ea/heat/engine/resources/openstack/neutron/neutron.py#L59 + bannedKeys := []string{"shared", "tenant_id"} + port := body["port"].(map[string]any) + + if port["value_specs"] != nil { + for k, v := range port["value_specs"].(map[string]any) { + if slices.Contains(bannedKeys, k) { + return nil, fmt.Errorf("forbidden key in value_specs: %s", k) + } + if _, ok := port[k]; ok { + return nil, fmt.Errorf("value_specs would overwrite key: %s", k) + } + port[k] = v + } + delete(port, "value_specs") + } + body["port"] = port + + return body, nil } // Create accepts a CreateOpts struct and creates a new network using the values // provided. You must remember to provide a NetworkID value. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToPortCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(createURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, createURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -148,7 +181,7 @@ func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResul // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToPortUpdateMap() (map[string]interface{}, error) + ToPortUpdateMap() (map[string]any, error) } // UpdateOpts represents the attributes used when updating an existing port. @@ -156,7 +189,7 @@ type UpdateOpts struct { Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` AdminStateUp *bool `json:"admin_state_up,omitempty"` - FixedIPs interface{} `json:"fixed_ips,omitempty"` + FixedIPs any `json:"fixed_ips,omitempty"` DeviceID *string `json:"device_id,omitempty"` DeviceOwner *string `json:"device_owner,omitempty"` SecurityGroups *[]string `json:"security_groups,omitempty"` @@ -171,13 +204,17 @@ type UpdateOpts struct { } // ToPortUpdateMap builds a request body from UpdateOpts. -func (opts UpdateOpts) ToPortUpdateMap() (map[string]interface{}, error) { - return gophercloud.BuildRequestBody(opts, "port") +func (opts UpdateOpts) ToPortUpdateMap() (map[string]any, error) { + body, err := gophercloud.BuildRequestBody(opts, "port") + if err != nil { + return nil, err + } + return AddValueSpecs(body) } // Update accepts a UpdateOpts struct and updates an existing port using the // values provided. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToPortUpdateMap() if err != nil { r.Err = err @@ -193,7 +230,7 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r h[k] = fmt.Sprintf("revision_number=%s", h[k]) } } - resp, err := c.Put(updateURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, updateURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{200, 201}, }) @@ -202,8 +239,8 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r } // Delete accepts a unique ID and deletes the port associated with it. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(deleteURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, deleteURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/results.go similarity index 94% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/results.go index a39133fc0676e..74a0fa3b49249 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/results.go @@ -4,8 +4,8 @@ import ( "encoding/json" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type commonResult struct { @@ -19,7 +19,7 @@ func (r commonResult) Extract() (*Port, error) { return &s, err } -func (r commonResult) ExtractInto(v interface{}) error { +func (r commonResult) ExtractInto(v any) error { return r.Result.ExtractIntoStructPtr(v, "port") } @@ -114,9 +114,6 @@ type Port struct { // PropagateUplinkStatus enables/disables propagate uplink status on the port. PropagateUplinkStatus bool `json:"propagate_uplink_status"` - // Extra parameters to include in the request. - ValueSpecs map[string]string `json:"value_specs"` - // RevisionNumber optionally set via extensions/standard-attr-revisions RevisionNumber int `json:"revision_number"` @@ -204,6 +201,6 @@ func ExtractPorts(r pagination.Page) ([]Port, error) { return s, err } -func ExtractPortsInto(r pagination.Page, v interface{}) error { +func ExtractPortsInto(r pagination.Page, v any) error { return r.(PortPage).Result.ExtractIntoSlicePtr(v, "ports") } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/urls.go similarity index 93% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/urls.go index 600d6f2fd950e..e52f44f654049 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/ports/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports/urls.go @@ -1,6 +1,6 @@ package ports -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func resourceURL(c *gophercloud.ServiceClient, id string) string { return c.ServiceURL("ports", id) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/doc.go similarity index 84% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/doc.go index 8bb4468c4e185..eef6afd53cc41 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/doc.go @@ -15,7 +15,7 @@ Example to List Subnets IPVersion: 4, } - allPages, err := subnets.List(networkClient, listOpts).AllPages() + allPages, err := subnets.List(networkClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -47,7 +47,7 @@ Example to Create a Subnet With Specified Gateway ServiceTypes: []string{"network:floatingip"}, } - subnet, err := subnets.Create(networkClient, createOpts).Extract() + subnet, err := subnets.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -70,7 +70,7 @@ Example to Create a Subnet With No Gateway DNSNameservers: []string{}, } - subnet, err := subnets.Create(networkClient, createOpts).Extract() + subnet, err := subnets.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -90,7 +90,7 @@ Example to Create a Subnet With a Default Gateway DNSNameservers: []string{}, } - subnet, err := subnets.Create(networkClient, createOpts).Extract() + subnet, err := subnets.Create(context.TODO(), networkClient, createOpts).Extract() if err != nil { panic(err) } @@ -108,7 +108,7 @@ Example to Update a Subnet ServiceTypes: &serviceTypes, } - subnet, err := subnets.Update(networkClient, subnetID, updateOpts).Extract() + subnet, err := subnets.Update(context.TODO(), networkClient, subnetID, updateOpts).Extract() if err != nil { panic(err) } @@ -122,7 +122,7 @@ Example to Remove a Gateway From a Subnet GatewayIP: &noGateway, } - subnet, err := subnets.Update(networkClient, subnetID, updateOpts).Extract() + subnet, err := subnets.Update(context.TODO(), networkClient, subnetID, updateOpts).Extract() if err != nil { panic(err) } @@ -130,7 +130,7 @@ Example to Remove a Gateway From a Subnet Example to Delete a Subnet subnetID := "db77d064-e34f-4d06-b060-f21e28a61c23" - err := subnets.Delete(networkClient, subnetID).ExtractErr() + err := subnets.Delete(context.TODO(), networkClient, subnetID).ExtractErr() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/requests.go similarity index 88% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/requests.go index 50b2bfea1b001..db597d6864c76 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/requests.go @@ -1,10 +1,11 @@ package subnets import ( + "context" "fmt" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the @@ -71,8 +72,8 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { } // Get retrieves a specific subnet based on its unique ID. -func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { - resp, err := c.Get(getURL(c, id), &r.Body, nil) +func Get(ctx context.Context, c *gophercloud.ServiceClient, id string) (r GetResult) { + resp, err := c.Get(ctx, getURL(c, id), &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -80,7 +81,7 @@ func Get(c *gophercloud.ServiceClient, id string) (r GetResult) { // CreateOptsBuilder allows extensions to add additional parameters to the // List request. type CreateOptsBuilder interface { - ToSubnetCreateMap() (map[string]interface{}, error) + ToSubnetCreateMap() (map[string]any, error) } // CreateOpts represents the attributes used when creating a new subnet. @@ -148,13 +149,13 @@ type CreateOpts struct { } // ToSubnetCreateMap builds a request body from CreateOpts. -func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) { +func (opts CreateOpts) ToSubnetCreateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "subnet") if err != nil { return nil, err } - if m := b["subnet"].(map[string]interface{}); m["gateway_ip"] == "" { + if m := b["subnet"].(map[string]any); m["gateway_ip"] == "" { m["gateway_ip"] = nil } @@ -164,13 +165,13 @@ func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) { // Create accepts a CreateOpts struct and creates a new subnet using the values // provided. You must remember to provide a valid NetworkID, CIDR and IP // version. -func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) { b, err := opts.ToSubnetCreateMap() if err != nil { r.Err = err return } - resp, err := c.Post(createURL(c), b, &r.Body, nil) + resp, err := c.Post(ctx, createURL(c), b, &r.Body, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -178,7 +179,7 @@ func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResul // UpdateOptsBuilder allows extensions to add additional parameters to the // Update request. type UpdateOptsBuilder interface { - ToSubnetUpdateMap() (map[string]interface{}, error) + ToSubnetUpdateMap() (map[string]any, error) } // UpdateOpts represents the attributes used when updating an existing subnet. @@ -220,13 +221,13 @@ type UpdateOpts struct { } // ToSubnetUpdateMap builds a request body from UpdateOpts. -func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) { +func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]any, error) { b, err := gophercloud.BuildRequestBody(opts, "subnet") if err != nil { return nil, err } - if m := b["subnet"].(map[string]interface{}); m["gateway_ip"] == "" { + if m := b["subnet"].(map[string]any); m["gateway_ip"] == "" { m["gateway_ip"] = nil } @@ -235,7 +236,7 @@ func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) { // Update accepts a UpdateOpts struct and updates an existing subnet using the // values provided. -func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) { b, err := opts.ToSubnetUpdateMap() if err != nil { r.Err = err @@ -252,7 +253,7 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r } } - resp, err := c.Put(updateURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, updateURL(c, id), b, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{200, 201}, }) @@ -261,8 +262,8 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r } // Delete accepts a unique ID and deletes the subnet associated with it. -func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) { - resp, err := c.Delete(deleteURL(c, id), nil) +func Delete(ctx context.Context, c *gophercloud.ServiceClient, id string) (r DeleteResult) { + resp, err := c.Delete(ctx, deleteURL(c, id), nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/results.go similarity index 98% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/results.go index 422eb428bf316..7d5ba13cc59ca 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/results.go @@ -1,8 +1,8 @@ package subnets import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) type commonResult struct { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/urls.go similarity index 93% rename from vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/urls.go index 7a4f2f7dd4c6e..e4ad4dd0ef127 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets/urls.go @@ -1,6 +1,6 @@ package subnets -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func resourceURL(c *gophercloud.ServiceClient, id string) string { return c.ServiceURL("subnets", id) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/doc.go similarity index 78% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/doc.go index 06290c6bd1130..d3367745ea475 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/doc.go @@ -9,7 +9,7 @@ services. Example to Get an Account - account, err := accounts.Get(objectStorageClient, nil).Extract() + account, err := accounts.Get(context.TODO(), objectStorageClient, nil).Extract() fmt.Printf("%+v\n", account) Example to Update an Account @@ -22,7 +22,7 @@ Example to Update an Account Metadata: metadata, } - updateResult, err := accounts.Update(objectStorageClient, updateOpts).Extract() + updateResult, err := accounts.Update(context.TODO(), objectStorageClient, updateOpts).Extract() fmt.Printf("%+v\n", updateResult) */ package accounts diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/requests.go similarity index 86% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/requests.go index 54b067205accc..be946db4acd85 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/requests.go @@ -1,6 +1,10 @@ package accounts -import "github.com/gophercloud/gophercloud" +import ( + "context" + + "github.com/gophercloud/gophercloud/v2" +) // GetOptsBuilder allows extensions to add additional headers to the Get // request. @@ -23,7 +27,7 @@ func (opts GetOpts) ToAccountGetMap() (map[string]string, error) { // custom metadata, call the ExtractMetadata method on the GetResult. To extract // all the headers that are returned (including the metadata), call the // Extract method on the GetResult. -func Get(c *gophercloud.ServiceClient, opts GetOptsBuilder) (r GetResult) { +func Get(ctx context.Context, c *gophercloud.ServiceClient, opts GetOptsBuilder) (r GetResult) { h := make(map[string]string) if opts != nil { headers, err := opts.ToAccountGetMap() @@ -35,7 +39,7 @@ func Get(c *gophercloud.ServiceClient, opts GetOptsBuilder) (r GetResult) { h[k] = v } } - resp, err := c.Head(getURL(c), &gophercloud.RequestOpts{ + resp, err := c.Head(ctx, getURL(c), &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{204}, }) @@ -80,7 +84,7 @@ func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) { // Update is a function that creates, updates, or deletes an account's metadata. // To extract the headers returned, call the Extract method on the UpdateResult. -func Update(c *gophercloud.ServiceClient, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, opts UpdateOptsBuilder) (r UpdateResult) { h := make(map[string]string) if opts != nil { headers, err := opts.ToAccountUpdateMap() @@ -92,7 +96,7 @@ func Update(c *gophercloud.ServiceClient, opts UpdateOptsBuilder) (r UpdateResul h[k] = v } } - resp, err := c.Request("POST", updateURL(c), &gophercloud.RequestOpts{ + resp, err := c.Request(ctx, "POST", updateURL(c), &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{201, 202, 204}, }) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/results.go similarity index 98% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/results.go index c9b7cb7eb1b81..39175517d35dc 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/results.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) // UpdateResult is returned from a call to the Update function. diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/urls.go similarity index 77% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/urls.go index 71540b1daf3dd..ffa5f5f125ba5 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts/urls.go @@ -1,6 +1,6 @@ package accounts -import "github.com/gophercloud/gophercloud" +import "github.com/gophercloud/gophercloud/v2" func getURL(c *gophercloud.ServiceClient) string { return c.Endpoint diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/doc.go similarity index 84% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/doc.go index ffc4f05297b62..dfad95ec1d4fd 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/doc.go @@ -17,7 +17,7 @@ Example to List Containers Full: true, } - allPages, err := containers.List(objectStorageClient, listOpts).AllPages() + allPages, err := containers.List(objectStorageClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -37,7 +37,7 @@ Example to List Only Container Names Full: false, } - allPages, err := containers.List(objectStorageClient, listOpts).AllPages() + allPages, err := containers.List(objectStorageClient, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -60,7 +60,7 @@ Example to Create a Container }, } - container, err := containers.Create(objectStorageClient, createOpts).Extract() + container, err := containers.Create(context.TODO(), objectStorageClient, createOpts).Extract() if err != nil { panic(err) } @@ -78,7 +78,7 @@ Example to Update a Container }, } - container, err := containers.Update(objectStorageClient, containerName, updateOpts).Extract() + container, err := containers.Update(context.TODO(), objectStorageClient, containerName, updateOpts).Extract() if err != nil { panic(err) } @@ -87,7 +87,7 @@ Example to Delete a Container containerName := "my_container" - container, err := containers.Delete(objectStorageClient, containerName).Extract() + container, err := containers.Delete(context.TODO(), objectStorageClient, containerName).Extract() if err != nil { panic(err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/requests.go similarity index 77% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/requests.go index 095770244792c..f4714d6ff63c1 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/requests.go @@ -1,21 +1,28 @@ package containers import ( - "strings" + "bytes" + "context" + "net/url" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + v1 "github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ListOptsBuilder allows extensions to add additional parameters to the List // request. type ListOptsBuilder interface { - ToContainerListParams() (bool, string, error) + ToContainerListParams() (string, error) } // ListOpts is a structure that holds options for listing containers. type ListOpts struct { - Full bool + // Full has been removed from the Gophercloud API. Gophercloud will now + // always request the "full" (json) listing, because simplified listing + // (plaintext) returns false results when names contain end-of-line + // characters. + Limit int `q:"limit"` Marker string `q:"marker"` EndMarker string `q:"end_marker"` @@ -24,30 +31,25 @@ type ListOpts struct { Delimiter string `q:"delimiter"` } -// ToContainerListParams formats a ListOpts into a query string and boolean -// representing whether to list complete information for each container. -func (opts ListOpts) ToContainerListParams() (bool, string, error) { +// ToContainerListParams formats a ListOpts into a query string. +func (opts ListOpts) ToContainerListParams() (string, error) { q, err := gophercloud.BuildQueryString(opts) - return opts.Full, q.String(), err + return q.String(), err } // List is a function that retrieves containers associated with the account as // well as account metadata. It returns a pager which can be iterated with the // EachPage function. func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { - headers := map[string]string{"Accept": "text/plain", "Content-Type": "text/plain"} + headers := map[string]string{"Accept": "application/json", "Content-Type": "application/json"} url := listURL(c) if opts != nil { - full, query, err := opts.ToContainerListParams() + query, err := opts.ToContainerListParams() if err != nil { return pagination.Pager{Err: err} } url += query - - if full { - headers = map[string]string{"Accept": "application/json", "Content-Type": "application/json"} - } } pager := pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { @@ -96,7 +98,7 @@ func (opts CreateOpts) ToContainerCreateMap() (map[string]string, error) { } // Create is a function that creates a new container. -func Create(c *gophercloud.ServiceClient, containerName string, opts CreateOptsBuilder) (r CreateResult) { +func Create(ctx context.Context, c *gophercloud.ServiceClient, containerName string, opts CreateOptsBuilder) (r CreateResult) { url, err := createURL(c, containerName) if err != nil { r.Err = err @@ -113,7 +115,7 @@ func Create(c *gophercloud.ServiceClient, containerName string, opts CreateOptsB h[k] = v } } - resp, err := c.Request("PUT", url, &gophercloud.RequestOpts{ + resp, err := c.Request(ctx, "PUT", url, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{201, 202, 204}, }) @@ -122,16 +124,19 @@ func Create(c *gophercloud.ServiceClient, containerName string, opts CreateOptsB } // BulkDelete is a function that bulk deletes containers. -func BulkDelete(c *gophercloud.ServiceClient, containers []string) (r BulkDeleteResult) { - // urlencode container names to be on the safe side - // https://github.com/openstack/swift/blob/stable/train/swift/common/middleware/bulk.py#L160 - // https://github.com/openstack/swift/blob/stable/train/swift/common/swob.py#L302 - encodedContainers := make([]string, len(containers)) - for i, v := range containers { - encodedContainers[i] = v +func BulkDelete(ctx context.Context, c *gophercloud.ServiceClient, containers []string) (r BulkDeleteResult) { + var body bytes.Buffer + + for i := range containers { + if err := v1.CheckContainerName(containers[i]); err != nil { + r.Err = err + return + } + body.WriteString(url.PathEscape(containers[i])) + body.WriteRune('\n') } - b := strings.NewReader(strings.Join(encodedContainers, "\n") + "\n") - resp, err := c.Post(bulkDeleteURL(c), b, &r.Body, &gophercloud.RequestOpts{ + + resp, err := c.Post(ctx, bulkDeleteURL(c), &body, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: map[string]string{ "Accept": "application/json", "Content-Type": "text/plain", @@ -143,13 +148,13 @@ func BulkDelete(c *gophercloud.ServiceClient, containers []string) (r BulkDelete } // Delete is a function that deletes a container. -func Delete(c *gophercloud.ServiceClient, containerName string) (r DeleteResult) { +func Delete(ctx context.Context, c *gophercloud.ServiceClient, containerName string) (r DeleteResult) { url, err := deleteURL(c, containerName) if err != nil { r.Err = err return } - resp, err := c.Delete(url, nil) + resp, err := c.Delete(ctx, url, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -200,7 +205,7 @@ func (opts UpdateOpts) ToContainerUpdateMap() (map[string]string, error) { // Update is a function that creates, updates, or deletes a container's // metadata. -func Update(c *gophercloud.ServiceClient, containerName string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, containerName string, opts UpdateOptsBuilder) (r UpdateResult) { url, err := updateURL(c, containerName) if err != nil { r.Err = err @@ -218,7 +223,7 @@ func Update(c *gophercloud.ServiceClient, containerName string, opts UpdateOptsB h[k] = v } } - resp, err := c.Request("POST", url, &gophercloud.RequestOpts{ + resp, err := c.Request(ctx, "POST", url, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{201, 202, 204}, }) @@ -245,7 +250,7 @@ func (opts GetOpts) ToContainerGetMap() (map[string]string, error) { // Get is a function that retrieves the metadata of a container. To extract just // the custom metadata, pass the GetResult response to the ExtractMetadata // function. -func Get(c *gophercloud.ServiceClient, containerName string, opts GetOptsBuilder) (r GetResult) { +func Get(ctx context.Context, c *gophercloud.ServiceClient, containerName string, opts GetOptsBuilder) (r GetResult) { url, err := getURL(c, containerName) if err != nil { r.Err = err @@ -263,7 +268,7 @@ func Get(c *gophercloud.ServiceClient, containerName string, opts GetOptsBuilder h[k] = v } } - resp, err := c.Head(url, &gophercloud.RequestOpts{ + resp, err := c.Head(ctx, url, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{200, 204}, }) diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/results.go similarity index 98% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/results.go index 73de4c013540f..8e71c150639a7 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/results.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // Container represents a container resource. diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/urls.go new file mode 100644 index 0000000000000..2117b3628f095 --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers/urls.go @@ -0,0 +1,35 @@ +package containers + +import ( + "net/url" + + "github.com/gophercloud/gophercloud/v2" + v1 "github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1" +) + +func listURL(c *gophercloud.ServiceClient) string { + return c.Endpoint +} + +func createURL(c *gophercloud.ServiceClient, container string) (string, error) { + if err := v1.CheckContainerName(container); err != nil { + return "", err + } + return c.ServiceURL(url.PathEscape(container)), nil +} + +func getURL(c *gophercloud.ServiceClient, container string) (string, error) { + return createURL(c, container) +} + +func deleteURL(c *gophercloud.ServiceClient, container string) (string, error) { + return createURL(c, container) +} + +func updateURL(c *gophercloud.ServiceClient, container string) (string, error) { + return createURL(c, container) +} + +func bulkDeleteURL(c *gophercloud.ServiceClient) string { + return c.Endpoint + "?bulk-delete=true" +} diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/errors.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/errors.go new file mode 100644 index 0000000000000..ba5cb0ab946cc --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/errors.go @@ -0,0 +1,54 @@ +package v1 + +import ( + "fmt" + "strings" + + "github.com/gophercloud/gophercloud/v2" +) + +func CheckContainerName(s string) error { + if len(s) < 1 { + return ErrEmptyContainerName{} + } + if strings.ContainsRune(s, '/') { + return ErrInvalidContainerName{name: s} + } + return nil +} + +func CheckObjectName(s string) error { + if s == "" { + return ErrEmptyObjectName{} + } + return nil +} + +// ErrInvalidContainerName signals a container name containing an illegal +// character. +type ErrInvalidContainerName struct { + name string + gophercloud.BaseError +} + +func (e ErrInvalidContainerName) Error() string { + return fmt.Sprintf("invalid name %q: a container name cannot contain a slash (/) character", e.name) +} + +// ErrEmptyContainerName signals an empty container name. +type ErrEmptyContainerName struct { + gophercloud.BaseError +} + +func (e ErrEmptyContainerName) Error() string { + return "a container name must not be empty" +} + +// ErrEmptyObjectName signals an empty container name. +type ErrEmptyObjectName struct { + gophercloud.BaseError +} + +func (e ErrEmptyObjectName) Error() string { + return "an object name must not be empty" +} diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/doc.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/doc.go similarity index 80% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/doc.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/doc.go index 7714460aadca3..2a6b00098e5fa 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/doc.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/doc.go @@ -16,7 +16,7 @@ Example to List Objects Full: true, } - allPages, err := objects.List(objectStorageClient, containerName, listOpts).AllPages() + allPages, err := objects.List(objectStorageClient, containerName, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -38,7 +38,7 @@ Example to List Object Names Full: false, } - allPages, err := objects.List(objectStorageClient, containerName, listOpts).AllPages() + allPages, err := objects.List(objectStorageClient, containerName, listOpts).AllPages(context.TODO()) if err != nil { panic(err) } @@ -63,7 +63,7 @@ Example to Create an Object Content: strings.NewReader(content), } - object, err := objects.Create(objectStorageClient, containerName, objectName, createOpts).Extract() + object, err := objects.Create(context.TODO(), objectStorageClient, containerName, objectName, createOpts).Extract() if err != nil { panic(err) } @@ -77,7 +77,7 @@ Example to Copy an Object Destination: "/newContainer/newObject", } - object, err := objects.Copy(objectStorageClient, containerName, objectName, copyOpts).Extract() + object, err := objects.Copy(context.TODO(), objectStorageClient, containerName, objectName, copyOpts).Extract() if err != nil { panic(err) } @@ -87,7 +87,7 @@ Example to Delete an Object objectName := "my_object" containerName := "my_container" - object, err := objects.Delete(objectStorageClient, containerName, objectName).Extract() + object, err := objects.Delete(context.TODO(), objectStorageClient, containerName, objectName).Extract() if err != nil { panic(err) } @@ -97,7 +97,7 @@ Example to Download an Object's Data objectName := "my_object" containerName := "my_container" - object := objects.Download(objectStorageClient, containerName, objectName, nil) + object := objects.Download(context.TODO(), objectStorageClient, containerName, objectName, nil) if object.Err != nil { panic(object.Err) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/requests.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/requests.go similarity index 79% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/requests.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/requests.go index ed9bd180f91f0..abc56f47733a5 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/requests.go @@ -2,6 +2,7 @@ package objects import ( "bytes" + "context" "crypto/hmac" "crypto/md5" "crypto/sha1" @@ -10,14 +11,15 @@ import ( "fmt" "hash" "io" - "io/ioutil" + "net/url" "strings" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts" - "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + v1 "github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1" + "github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts" + "github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers" + "github.com/gophercloud/gophercloud/v2/pagination" ) // ErrTempURLKeyNotFound is an error indicating that the Temp URL key was @@ -42,16 +44,16 @@ func (e ErrTempURLDigestNotValid) Error() string { // ListOptsBuilder allows extensions to add additional parameters to the List // request. type ListOptsBuilder interface { - ToObjectListParams() (bool, string, error) + ToObjectListParams() (string, error) } // ListOpts is a structure that holds parameters for listing objects. type ListOpts struct { - // Full is a true/false value that represents the amount of object information - // returned. If Full is set to true, then the content-type, number of bytes, - // hash date last modified, and name are returned. If set to false or not set, - // then only the object names are returned. - Full bool + // Full has been removed from the Gophercloud API. Gophercloud will now + // always request the "full" (json) listing, because simplified listing + // (plaintext) returns false results when names contain end-of-line + // characters. + Limit int `q:"limit"` Marker string `q:"marker"` EndMarker string `q:"end_marker"` @@ -62,11 +64,10 @@ type ListOpts struct { Versions bool `q:"versions"` } -// ToObjectListParams formats a ListOpts into a query string and boolean -// representing whether to list complete information for each object. -func (opts ListOpts) ToObjectListParams() (bool, string, error) { +// ToObjectListParams formats a ListOpts into a query string. +func (opts ListOpts) ToObjectListParams() (string, error) { q, err := gophercloud.BuildQueryString(opts) - return opts.Full, q.String(), err + return q.String(), err } // List is a function that retrieves all objects in a container. It also returns @@ -79,17 +80,13 @@ func List(c *gophercloud.ServiceClient, containerName string, opts ListOptsBuild return pagination.Pager{Err: err} } - headers := map[string]string{"Accept": "text/plain", "Content-Type": "text/plain"} + headers := map[string]string{"Accept": "application/json", "Content-Type": "application/json"} if opts != nil { - full, query, err := opts.ToObjectListParams() + query, err := opts.ToObjectListParams() if err != nil { return pagination.Pager{Err: err} } url += query - - if full { - headers = map[string]string{"Accept": "application/json", "Content-Type": "application/json"} - } } pager := pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { @@ -144,7 +141,7 @@ func (opts DownloadOpts) ToObjectDownloadParams() (map[string]string, string, er // Download is a function that retrieves the content and metadata for an object. // To extract just the content, call the DownloadResult method ExtractContent, // after checking DownloadResult's Err field. -func Download(c *gophercloud.ServiceClient, containerName, objectName string, opts DownloadOptsBuilder) (r DownloadResult) { +func Download(ctx context.Context, c *gophercloud.ServiceClient, containerName, objectName string, opts DownloadOptsBuilder) (r DownloadResult) { url, err := downloadURL(c, containerName, objectName) if err != nil { r.Err = err @@ -164,7 +161,7 @@ func Download(c *gophercloud.ServiceClient, containerName, objectName string, op url += query } - resp, err := c.Get(url, nil, &gophercloud.RequestOpts{ + resp, err := c.Get(ctx, url, nil, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{200, 206, 304}, KeepResponseBody: true, @@ -232,7 +229,7 @@ func (opts CreateOpts) ToObjectCreateParams() (io.Reader, map[string]string, str // file content into memory first. readSeeker, isReadSeeker := opts.Content.(io.ReadSeeker) if !isReadSeeker { - data, err := ioutil.ReadAll(opts.Content) + data, err := io.ReadAll(opts.Content) if err != nil { return nil, nil, "", err } @@ -244,7 +241,10 @@ func (opts CreateOpts) ToObjectCreateParams() (io.Reader, map[string]string, str if _, err := io.Copy(hash, readSeeker); err != nil { return nil, nil, "", err } - readSeeker.Seek(0, io.SeekStart) + _, err = readSeeker.Seek(0, io.SeekStart) + if err != nil { + return nil, nil, "", err + } h["ETag"] = fmt.Sprintf("%x", hash.Sum(nil)) @@ -252,10 +252,8 @@ func (opts CreateOpts) ToObjectCreateParams() (io.Reader, map[string]string, str } // Create is a function that creates a new object or replaces an existing -// object. If the returned response's ETag header fails to match the local -// checksum, the failed request will automatically be retried up to a maximum -// of 3 times. -func Create(c *gophercloud.ServiceClient, containerName, objectName string, opts CreateOptsBuilder) (r CreateResult) { +// object. +func Create(ctx context.Context, c *gophercloud.ServiceClient, containerName, objectName string, opts CreateOptsBuilder) (r CreateResult) { url, err := createURL(c, containerName, objectName) if err != nil { r.Err = err @@ -276,7 +274,7 @@ func Create(c *gophercloud.ServiceClient, containerName, objectName string, opts b = tmpB } - resp, err := c.Put(url, b, nil, &gophercloud.RequestOpts{ + resp, err := c.Put(ctx, url, b, nil, &gophercloud.RequestOpts{ MoreHeaders: h, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -302,8 +300,12 @@ type CopyOpts struct { ContentDisposition string `h:"Content-Disposition"` ContentEncoding string `h:"Content-Encoding"` ContentType string `h:"Content-Type"` - Destination string `h:"Destination" required:"true"` - ObjectVersionID string `q:"version-id"` + + // Destination is where the object should be copied to, in the form: + // `/container/object`. + Destination string `h:"Destination" required:"true"` + + ObjectVersionID string `q:"version-id"` } // ToObjectCopyMap formats a CopyOpts into a map of headers. @@ -328,13 +330,7 @@ func (opts CopyOpts) ToObjectCopyQuery() (string, error) { } // Copy is a function that copies one object to another. -func Copy(c *gophercloud.ServiceClient, containerName, objectName string, opts CopyOptsBuilder) (r CopyResult) { - url, err := copyURL(c, containerName, objectName) - if err != nil { - r.Err = err - return - } - +func Copy(ctx context.Context, c *gophercloud.ServiceClient, containerName, objectName string, opts CopyOptsBuilder) (r CopyResult) { h := make(map[string]string) headers, err := opts.ToObjectCopyMap() if err != nil { @@ -342,9 +338,34 @@ func Copy(c *gophercloud.ServiceClient, containerName, objectName string, opts C return } for k, v := range headers { + if strings.ToLower(k) == "destination" { + // URL-encode the container name and the object name + // separately before joining them around the `/` slash + // separator. Note that the destination path is also + // expected to start with a slash. + segments := strings.SplitN(v, "/", 3) + if l := len(segments); l != 3 { + r.Err = fmt.Errorf("the destination field is expected to contain at least two slash / characters: the initial one, and the separator between the container name and the object name") + return + } + if segments[0] != "" { + r.Err = fmt.Errorf("the destination field is expected to start with a slash") + return + } + for i := range segments { + segments[i] = url.PathEscape(segments[i]) + } + v = strings.Join(segments, "/") + } h[k] = v } + url, err := copyURL(c, containerName, objectName) + if err != nil { + r.Err = err + return + } + if opts, ok := opts.(CopyOptsQueryBuilder); ok { query, err := opts.ToObjectCopyQuery() if err != nil { @@ -354,7 +375,7 @@ func Copy(c *gophercloud.ServiceClient, containerName, objectName string, opts C url += query } - resp, err := c.Request("COPY", url, &gophercloud.RequestOpts{ + resp, err := c.Request(ctx, "COPY", url, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{201}, }) @@ -381,7 +402,7 @@ func (opts DeleteOpts) ToObjectDeleteQuery() (string, error) { } // Delete is a function that deletes an object. -func Delete(c *gophercloud.ServiceClient, containerName, objectName string, opts DeleteOptsBuilder) (r DeleteResult) { +func Delete(ctx context.Context, c *gophercloud.ServiceClient, containerName, objectName string, opts DeleteOptsBuilder) (r DeleteResult) { url, err := deleteURL(c, containerName, objectName) if err != nil { r.Err = err @@ -395,7 +416,7 @@ func Delete(c *gophercloud.ServiceClient, containerName, objectName string, opts } url += query } - resp, err := c.Delete(url, nil) + resp, err := c.Delete(ctx, url, nil) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } @@ -431,7 +452,7 @@ func (opts GetOpts) ToObjectGetParams() (map[string]string, string, error) { // Get is a function that retrieves the metadata of an object. To extract just // the custom metadata, pass the GetResult response to the ExtractMetadata // function. -func Get(c *gophercloud.ServiceClient, containerName, objectName string, opts GetOptsBuilder) (r GetResult) { +func Get(ctx context.Context, c *gophercloud.ServiceClient, containerName, objectName string, opts GetOptsBuilder) (r GetResult) { url, err := getURL(c, containerName, objectName) if err != nil { r.Err = err @@ -450,7 +471,7 @@ func Get(c *gophercloud.ServiceClient, containerName, objectName string, opts Ge url += query } - resp, err := c.Head(url, &gophercloud.RequestOpts{ + resp, err := c.Head(ctx, url, &gophercloud.RequestOpts{ MoreHeaders: h, OkCodes: []int{200, 204}, }) @@ -495,7 +516,7 @@ func (opts UpdateOpts) ToObjectUpdateMap() (map[string]string, error) { } // Update is a function that creates, updates, or deletes an object's metadata. -func Update(c *gophercloud.ServiceClient, containerName, objectName string, opts UpdateOptsBuilder) (r UpdateResult) { +func Update(ctx context.Context, c *gophercloud.ServiceClient, containerName, objectName string, opts UpdateOptsBuilder) (r UpdateResult) { url, err := updateURL(c, containerName, objectName) if err != nil { r.Err = err @@ -513,7 +534,7 @@ func Update(c *gophercloud.ServiceClient, containerName, objectName string, opts h[k] = v } } - resp, err := c.Post(url, nil, nil, &gophercloud.RequestOpts{ + resp, err := c.Post(ctx, url, nil, nil, &gophercloud.RequestOpts{ MoreHeaders: h, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -570,11 +591,12 @@ type CreateTempURLOpts struct { // CreateTempURL is a function for creating a temporary URL for an object. It // allows users to have "GET" or "POST" access to a particular tenant's object // for a limited amount of time. -func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName string, opts CreateTempURLOpts) (string, error) { +func CreateTempURL(ctx context.Context, c *gophercloud.ServiceClient, containerName, objectName string, opts CreateTempURLOpts) (string, error) { url, err := getURL(c, containerName, objectName) if err != nil { return "", err } + urlToBeSigned := tempURL(c, containerName, objectName) if opts.Split == "" { opts.Split = "/v1/" @@ -593,14 +615,14 @@ func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName strin tempURLKey := opts.TempURLKey if tempURLKey == "" { // fallback to a container TempURL key - getHeader, err := containers.Get(c, containerName, nil).Extract() + getHeader, err := containers.Get(ctx, c, containerName, nil).Extract() if err != nil { return "", err } tempURLKey = getHeader.TempURLKey if tempURLKey == "" { // fallback to an account TempURL key - getHeader, err := accounts.Get(c, nil).Extract() + getHeader, err := accounts.Get(ctx, c, nil).Extract() if err != nil { return "", err } @@ -612,8 +634,10 @@ func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName strin } secretKey := []byte(tempURLKey) - splitPath := strings.SplitN(url, opts.Split, 2) - baseURL, objectPath := splitPath[0], splitPath[1] + _, objectPath, splitFound := strings.Cut(urlToBeSigned, opts.Split) + if !splitFound { + return "", fmt.Errorf("URL prefix %q not found", opts.Split) + } objectPath = opts.Split + objectPath body := fmt.Sprintf("%s\n%d\n%s", opts.Method, expiry, objectPath) var hash hash.Hash @@ -629,7 +653,7 @@ func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName strin } hash.Write([]byte(body)) hexsum := fmt.Sprintf("%x", hash.Sum(nil)) - return fmt.Sprintf("%s%s?temp_url_sig=%s&temp_url_expires=%d", baseURL, objectPath, hexsum, expiry), nil + return fmt.Sprintf("%s?temp_url_sig=%s&temp_url_expires=%d", url, hexsum, expiry), nil } // BulkDelete is a function that bulk deletes objects. @@ -638,26 +662,27 @@ func CreateTempURL(c *gophercloud.ServiceClient, containerName, objectName strin // See: // * https://github.com/openstack/swift/blob/6d3d4197151f44bf28b51257c1a4c5d33411dcae/etc/proxy-server.conf-sample#L1029-L1034 // * https://github.com/openstack/swift/blob/e8cecf7fcc1630ee83b08f9a73e1e59c07f8d372/swift/common/middleware/bulk.py#L309 -func BulkDelete(c *gophercloud.ServiceClient, container string, objects []string) (r BulkDeleteResult) { - err := containers.CheckContainerName(container) - if err != nil { +func BulkDelete(ctx context.Context, c *gophercloud.ServiceClient, container string, objects []string) (r BulkDeleteResult) { + if err := v1.CheckContainerName(container); err != nil { r.Err = err return } + encodedContainer := url.PathEscape(container) + var body bytes.Buffer for i := range objects { - if objects[i] == "" { - r.Err = fmt.Errorf("object names must not be the empty string") + if err := v1.CheckObjectName(objects[i]); err != nil { + r.Err = err return } - body.WriteString(container) + body.WriteString(encodedContainer) body.WriteRune('/') - body.WriteString(objects[i]) + body.WriteString(url.PathEscape(objects[i])) body.WriteRune('\n') } - resp, err := c.Post(bulkDeleteURL(c), &body, &r.Body, &gophercloud.RequestOpts{ + resp, err := c.Post(ctx, bulkDeleteURL(c), &body, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: map[string]string{ "Accept": "application/json", "Content-Type": "text/plain", diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/results.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/results.go similarity index 97% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/results.go index 6d8d5d304cc8c..e98c542960d76 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/results.go @@ -4,13 +4,12 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/url" "strings" "time" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/pagination" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/pagination" ) // Object is a structure that holds information related to a storage object. @@ -163,7 +162,7 @@ func (r *DownloadHeader) UnmarshalJSON(b []byte) error { Date gophercloud.JSONRFC1123 `json:"Date"` DeleteAt gophercloud.JSONUnix `json:"X-Delete-At"` LastModified gophercloud.JSONRFC1123 `json:"Last-Modified"` - StaticLargeObject interface{} `json:"X-Static-Large-Object"` + StaticLargeObject any `json:"X-Static-Large-Object"` } err := json.Unmarshal(b, &s) if err != nil { @@ -212,7 +211,7 @@ func (r *DownloadResult) ExtractContent() ([]byte, error) { return nil, r.Err } defer r.Body.Close() - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { return nil, err } @@ -242,7 +241,7 @@ func (r *GetHeader) UnmarshalJSON(b []byte) error { Date gophercloud.JSONRFC1123 `json:"Date"` DeleteAt gophercloud.JSONUnix `json:"X-Delete-At"` LastModified gophercloud.JSONRFC1123 `json:"Last-Modified"` - StaticLargeObject interface{} `json:"X-Static-Large-Object"` + StaticLargeObject any `json:"X-Static-Large-Object"` } err := json.Unmarshal(b, &s) if err != nil { @@ -330,15 +329,11 @@ func (r *CreateHeader) UnmarshalJSON(b []byte) error { // CreateResult represents the result of a create operation. type CreateResult struct { - checksum string gophercloud.HeaderResult } // Extract will return a struct of headers returned from a call to Create. func (r CreateResult) Extract() (*CreateHeader, error) { - //if r.Header.Get("ETag") != fmt.Sprintf("%x", localChecksum) { - // return nil, ErrWrongChecksum{} - //} var s CreateHeader err := r.ExtractInto(&s) return &s, err diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/urls.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/urls.go similarity index 55% rename from vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/urls.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/urls.go index 172a197bfd4a6..86f58231213b8 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/urls.go @@ -1,22 +1,35 @@ package objects import ( - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers" + "net/url" + + "github.com/gophercloud/gophercloud/v2" + v1 "github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1" ) +// tempURL returns an unescaped virtual path to generate the HMAC signature. +// Names must not be URL-encoded in this case. +// +// See: https://docs.openstack.org/swift/latest/api/temporary_url_middleware.html#hmac-signature-for-temporary-urls +func tempURL(c *gophercloud.ServiceClient, container, object string) string { + return c.ServiceURL(container, object) +} + func listURL(c *gophercloud.ServiceClient, container string) (string, error) { - if err := containers.CheckContainerName(container); err != nil { + if err := v1.CheckContainerName(container); err != nil { return "", err } - return c.ServiceURL(container), nil + return c.ServiceURL(url.PathEscape(container)), nil } func copyURL(c *gophercloud.ServiceClient, container, object string) (string, error) { - if err := containers.CheckContainerName(container); err != nil { + if err := v1.CheckContainerName(container); err != nil { + return "", err + } + if err := v1.CheckObjectName(object); err != nil { return "", err } - return c.ServiceURL(container, object), nil + return c.ServiceURL(url.PathEscape(container), url.PathEscape(object)), nil } func createURL(c *gophercloud.ServiceClient, container, object string) (string, error) { diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/utils/base_endpoint.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/utils/base_endpoint.go similarity index 100% rename from vendor/github.com/gophercloud/gophercloud/openstack/utils/base_endpoint.go rename to vendor/github.com/gophercloud/gophercloud/v2/openstack/utils/base_endpoint.go diff --git a/vendor/github.com/gophercloud/gophercloud/v2/openstack/utils/choose_version.go b/vendor/github.com/gophercloud/gophercloud/v2/openstack/utils/choose_version.go new file mode 100644 index 0000000000000..6c720e57ef95e --- /dev/null +++ b/vendor/github.com/gophercloud/gophercloud/v2/openstack/utils/choose_version.go @@ -0,0 +1,236 @@ +package utils + +import ( + "context" + "fmt" + "strconv" + "strings" + + "github.com/gophercloud/gophercloud/v2" +) + +// Version is a supported API version, corresponding to a vN package within the appropriate service. +type Version struct { + ID string + Suffix string + Priority int +} + +var goodStatus = map[string]bool{ + "current": true, + "supported": true, + "stable": true, +} + +// ChooseVersion queries the base endpoint of an API to choose the identity service version. +// It will pick a version among the recognized, taking into account the priority and avoiding +// experimental alternatives from the published versions. However, if the client specifies a full +// endpoint that is among the recognized versions, it will be used regardless of priority. +// It returns the highest-Priority Version, OR exact match with client endpoint, +// among the alternatives that are provided, as well as its corresponding endpoint. +func ChooseVersion(ctx context.Context, client *gophercloud.ProviderClient, recognized []*Version) (*Version, string, error) { + type linkResp struct { + Href string `json:"href"` + Rel string `json:"rel"` + } + + type valueResp struct { + ID string `json:"id"` + Status string `json:"status"` + Links []linkResp `json:"links"` + } + + type versionsResp struct { + Values []valueResp `json:"values"` + } + + type response struct { + Versions versionsResp `json:"versions"` + } + + normalize := func(endpoint string) string { + if !strings.HasSuffix(endpoint, "/") { + return endpoint + "/" + } + return endpoint + } + identityEndpoint := normalize(client.IdentityEndpoint) + + // If a full endpoint is specified, check version suffixes for a match first. + for _, v := range recognized { + if strings.HasSuffix(identityEndpoint, v.Suffix) { + return v, identityEndpoint, nil + } + } + + var resp response + _, err := client.Request(ctx, "GET", client.IdentityBase, &gophercloud.RequestOpts{ + JSONResponse: &resp, + OkCodes: []int{200, 300}, + }) + + if err != nil { + return nil, "", err + } + + var highest *Version + var endpoint string + + for _, value := range resp.Versions.Values { + href := "" + for _, link := range value.Links { + if link.Rel == "self" { + href = normalize(link.Href) + } + } + + for _, version := range recognized { + if strings.Contains(value.ID, version.ID) { + // Prefer a version that exactly matches the provided endpoint. + if href == identityEndpoint { + if href == "" { + return nil, "", fmt.Errorf("Endpoint missing in version %s response from %s", value.ID, client.IdentityBase) + } + return version, href, nil + } + + // Otherwise, find the highest-priority version with a whitelisted status. + if goodStatus[strings.ToLower(value.Status)] { + if highest == nil || version.Priority > highest.Priority { + highest = version + endpoint = href + } + } + } + } + } + + if highest == nil { + return nil, "", fmt.Errorf("No supported version available from endpoint %s", client.IdentityBase) + } + if endpoint == "" { + return nil, "", fmt.Errorf("Endpoint missing in version %s response from %s", highest.ID, client.IdentityBase) + } + + return highest, endpoint, nil +} + +type SupportedMicroversions struct { + MaxMajor int + MaxMinor int + MinMajor int + MinMinor int +} + +// GetSupportedMicroversions returns the minimum and maximum microversion that is supported by the ServiceClient Endpoint. +func GetSupportedMicroversions(ctx context.Context, client *gophercloud.ServiceClient) (SupportedMicroversions, error) { + type valueResp struct { + ID string `json:"id"` + Status string `json:"status"` + Version string `json:"version"` + MinVersion string `json:"min_version"` + } + + type response struct { + Version valueResp `json:"version"` + Versions []valueResp `json:"versions"` + } + var minVersion, maxVersion string + var supportedMicroversions SupportedMicroversions + var resp response + _, err := client.Get(ctx, client.Endpoint, &resp, &gophercloud.RequestOpts{ + OkCodes: []int{200, 300}, + }) + + if err != nil { + return supportedMicroversions, err + } + + if len(resp.Versions) > 0 { + // We are dealing with an unversioned endpoint + // We only handle the case when there is exactly one, and assume it is the correct one + if len(resp.Versions) > 1 { + return supportedMicroversions, fmt.Errorf("unversioned endpoint with multiple alternatives not supported") + } + minVersion = resp.Versions[0].MinVersion + maxVersion = resp.Versions[0].Version + } else { + minVersion = resp.Version.MinVersion + maxVersion = resp.Version.Version + } + + // Return early if the endpoint does not support microversions + if minVersion == "" && maxVersion == "" { + return supportedMicroversions, fmt.Errorf("microversions not supported by ServiceClient Endpoint") + } + + supportedMicroversions.MinMajor, supportedMicroversions.MinMinor, err = ParseMicroversion(minVersion) + if err != nil { + return supportedMicroversions, err + } + + supportedMicroversions.MaxMajor, supportedMicroversions.MaxMinor, err = ParseMicroversion(maxVersion) + if err != nil { + return supportedMicroversions, err + } + + return supportedMicroversions, nil +} + +// RequireMicroversion checks that the required microversion is supported and +// returns a ServiceClient with the microversion set. +func RequireMicroversion(ctx context.Context, client gophercloud.ServiceClient, required string) (gophercloud.ServiceClient, error) { + supportedMicroversions, err := GetSupportedMicroversions(ctx, &client) + if err != nil { + return client, fmt.Errorf("unable to determine supported microversions: %w", err) + } + supported, err := supportedMicroversions.IsSupported(required) + if err != nil { + return client, err + } + if !supported { + return client, fmt.Errorf("microversion %s not supported. Supported versions: %v", required, supportedMicroversions) + } + client.Microversion = required + return client, nil +} + +// IsSupported checks if a microversion falls in the supported interval. +// It returns true if the version is within the interval and false otherwise. +func (supported SupportedMicroversions) IsSupported(version string) (bool, error) { + // Parse the version X.Y into X and Y integers that are easier to compare. + vMajor, vMinor, err := ParseMicroversion(version) + if err != nil { + return false, err + } + + // Check that the major version number is supported. + if (vMajor < supported.MinMajor) || (vMajor > supported.MaxMajor) { + return false, nil + } + + // Check that the minor version number is supported + if (vMinor <= supported.MaxMinor) && (vMinor >= supported.MinMinor) { + return true, nil + } + + return false, nil +} + +// ParseMicroversion parses the version major.minor into separate integers major and minor. +// For example, "2.53" becomes 2 and 53. +func ParseMicroversion(version string) (major int, minor int, err error) { + parts := strings.Split(version, ".") + if len(parts) != 2 { + return 0, 0, fmt.Errorf("invalid microversion format: %q", version) + } + major, err = strconv.Atoi(parts[0]) + if err != nil { + return 0, 0, err + } + minor, err = strconv.Atoi(parts[1]) + if err != nil { + return 0, 0, err + } + return major, minor, nil +} diff --git a/vendor/github.com/gophercloud/gophercloud/pagination/http.go b/vendor/github.com/gophercloud/gophercloud/v2/pagination/http.go similarity index 76% rename from vendor/github.com/gophercloud/gophercloud/pagination/http.go rename to vendor/github.com/gophercloud/gophercloud/v2/pagination/http.go index 7845cda13b7d9..cf188b89b9b51 100644 --- a/vendor/github.com/gophercloud/gophercloud/pagination/http.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/pagination/http.go @@ -1,13 +1,14 @@ package pagination import ( + "context" "encoding/json" - "io/ioutil" + "io" "net/http" "net/url" "strings" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) // PageResult stores the HTTP response that returned the current page of results. @@ -19,10 +20,10 @@ type PageResult struct { // PageResultFrom parses an HTTP response as JSON and returns a PageResult containing the // results, interpreting it as JSON if the content type indicates. func PageResultFrom(resp *http.Response) (PageResult, error) { - var parsedBody interface{} + var parsedBody any defer resp.Body.Close() - rawBody, err := ioutil.ReadAll(resp.Body) + rawBody, err := io.ReadAll(resp.Body) if err != nil { return PageResult{}, err } @@ -41,7 +42,7 @@ func PageResultFrom(resp *http.Response) (PageResult, error) { // PageResultFromParsed constructs a PageResult from an HTTP response that has already had its // body parsed as JSON (and closed). -func PageResultFromParsed(resp *http.Response, body interface{}) PageResult { +func PageResultFromParsed(resp *http.Response, body any) PageResult { return PageResult{ Result: gophercloud.Result{ Body: body, @@ -53,8 +54,8 @@ func PageResultFromParsed(resp *http.Response, body interface{}) PageResult { } // Request performs an HTTP request and extracts the http.Response from the result. -func Request(client *gophercloud.ServiceClient, headers map[string]string, url string) (*http.Response, error) { - return client.Get(url, nil, &gophercloud.RequestOpts{ +func Request(ctx context.Context, client *gophercloud.ServiceClient, headers map[string]string, url string) (*http.Response, error) { + return client.Get(ctx, url, nil, &gophercloud.RequestOpts{ MoreHeaders: headers, OkCodes: []int{200, 204, 300}, KeepResponseBody: true, diff --git a/vendor/github.com/gophercloud/gophercloud/pagination/linked.go b/vendor/github.com/gophercloud/gophercloud/v2/pagination/linked.go similarity index 85% rename from vendor/github.com/gophercloud/gophercloud/pagination/linked.go rename to vendor/github.com/gophercloud/gophercloud/v2/pagination/linked.go index a664e056738ac..7e4de4f7aec8f 100644 --- a/vendor/github.com/gophercloud/gophercloud/pagination/linked.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/pagination/linked.go @@ -4,7 +4,7 @@ import ( "fmt" "reflect" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) // LinkedPageBase may be embedded to implement a page that provides navigational "Next" and "Previous" links within its result. @@ -31,10 +31,10 @@ func (current LinkedPageBase) NextPageURL() (string, error) { path = current.LinkPath } - submap, ok := current.Body.(map[string]interface{}) + submap, ok := current.Body.(map[string]any) if !ok { err := gophercloud.ErrUnexpectedType{} - err.Expected = "map[string]interface{}" + err.Expected = "map[string]any" err.Actual = fmt.Sprintf("%v", reflect.TypeOf(current.Body)) return "", err } @@ -48,10 +48,10 @@ func (current LinkedPageBase) NextPageURL() (string, error) { } if len(path) > 0 { - submap, ok = value.(map[string]interface{}) + submap, ok = value.(map[string]any) if !ok { err := gophercloud.ErrUnexpectedType{} - err.Expected = "map[string]interface{}" + err.Expected = "map[string]any" err.Actual = fmt.Sprintf("%v", reflect.TypeOf(value)) return "", err } @@ -76,17 +76,17 @@ func (current LinkedPageBase) NextPageURL() (string, error) { // IsEmpty satisifies the IsEmpty method of the Page interface func (current LinkedPageBase) IsEmpty() (bool, error) { - if b, ok := current.Body.([]interface{}); ok { + if b, ok := current.Body.([]any); ok { return len(b) == 0, nil } err := gophercloud.ErrUnexpectedType{} - err.Expected = "[]interface{}" + err.Expected = "[]any" err.Actual = fmt.Sprintf("%v", reflect.TypeOf(current.Body)) return true, err } // GetBody returns the linked page's body. This method is needed to satisfy the // Page interface. -func (current LinkedPageBase) GetBody() interface{} { +func (current LinkedPageBase) GetBody() any { return current.Body } diff --git a/vendor/github.com/gophercloud/gophercloud/pagination/marker.go b/vendor/github.com/gophercloud/gophercloud/v2/pagination/marker.go similarity index 88% rename from vendor/github.com/gophercloud/gophercloud/pagination/marker.go rename to vendor/github.com/gophercloud/gophercloud/v2/pagination/marker.go index 52e53bae85034..1d101fe2db862 100644 --- a/vendor/github.com/gophercloud/gophercloud/pagination/marker.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/pagination/marker.go @@ -4,7 +4,7 @@ import ( "fmt" "reflect" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) // MarkerPage is a stricter Page interface that describes additional functionality required for use with NewMarkerPager. @@ -42,17 +42,17 @@ func (current MarkerPageBase) NextPageURL() (string, error) { // IsEmpty satisifies the IsEmpty method of the Page interface func (current MarkerPageBase) IsEmpty() (bool, error) { - if b, ok := current.Body.([]interface{}); ok { + if b, ok := current.Body.([]any); ok { return len(b) == 0, nil } err := gophercloud.ErrUnexpectedType{} - err.Expected = "[]interface{}" + err.Expected = "[]any" err.Actual = fmt.Sprintf("%v", reflect.TypeOf(current.Body)) return true, err } // GetBody returns the linked page's body. This method is needed to satisfy the // Page interface. -func (current MarkerPageBase) GetBody() interface{} { +func (current MarkerPageBase) GetBody() any { return current.Body } diff --git a/vendor/github.com/gophercloud/gophercloud/pagination/pager.go b/vendor/github.com/gophercloud/gophercloud/v2/pagination/pager.go similarity index 83% rename from vendor/github.com/gophercloud/gophercloud/pagination/pager.go rename to vendor/github.com/gophercloud/gophercloud/v2/pagination/pager.go index 1dec2703ebf58..3581012566b89 100644 --- a/vendor/github.com/gophercloud/gophercloud/pagination/pager.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/pagination/pager.go @@ -1,13 +1,14 @@ package pagination import ( + "context" "errors" "fmt" "net/http" "reflect" "strings" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) var ( @@ -30,7 +31,7 @@ type Page interface { IsEmpty() (bool, error) // GetBody returns the Page Body. This is used in the `AllPages` method. - GetBody() interface{} + GetBody() any } // Pager knows how to advance through a specific resource collection, one page at a time. @@ -69,8 +70,8 @@ func (p Pager) WithPageCreator(createPage func(r PageResult) Page) Pager { } } -func (p Pager) fetchNextPage(url string) (Page, error) { - resp, err := Request(p.client, p.Headers, url) +func (p Pager) fetchNextPage(ctx context.Context, url string) (Page, error) { + resp, err := Request(ctx, p.client, p.Headers, url) if err != nil { return nil, err } @@ -83,9 +84,10 @@ func (p Pager) fetchNextPage(url string) (Page, error) { return p.createPage(remembered), nil } -// EachPage iterates over each page returned by a Pager, yielding one at a time to a handler function. -// Return "false" from the handler to prematurely stop iterating. -func (p Pager) EachPage(handler func(Page) (bool, error)) error { +// EachPage iterates over each page returned by a Pager, yielding one at a time +// to a handler function. Return "false" from the handler to prematurely stop +// iterating. +func (p Pager) EachPage(ctx context.Context, handler func(context.Context, Page) (bool, error)) error { if p.Err != nil { return p.Err } @@ -99,7 +101,7 @@ func (p Pager) EachPage(handler func(Page) (bool, error)) error { p.firstPage = nil } else { var err error - currentPage, err = p.fetchNextPage(currentURL) + currentPage, err = p.fetchNextPage(ctx, currentURL) if err != nil { return err } @@ -113,7 +115,7 @@ func (p Pager) EachPage(handler func(Page) (bool, error)) error { return nil } - ok, err := handler(currentPage) + ok, err := handler(ctx, currentPage) if err != nil { return err } @@ -133,17 +135,17 @@ func (p Pager) EachPage(handler func(Page) (bool, error)) error { // AllPages returns all the pages from a `List` operation in a single page, // allowing the user to retrieve all the pages at once. -func (p Pager) AllPages() (Page, error) { +func (p Pager) AllPages(ctx context.Context) (Page, error) { if p.Err != nil { return nil, p.Err } // pagesSlice holds all the pages until they get converted into as Page Body. - var pagesSlice []interface{} + var pagesSlice []any // body will contain the final concatenated Page body. var body reflect.Value // Grab a first page to ascertain the page body type. - firstPage, err := p.fetchNextPage(p.initialURL) + firstPage, err := p.fetchNextPage(ctx, p.initialURL) if err != nil { return nil, err } @@ -159,21 +161,21 @@ func (p Pager) AllPages() (Page, error) { // store the first page to avoid getting it twice p.firstPage = firstPage - // Switch on the page body type. Recognized types are `map[string]interface{}`, - // `[]byte`, and `[]interface{}`. + // Switch on the page body type. Recognized types are `map[string]any`, + // `[]byte`, and `[]any`. switch pb := firstPage.GetBody().(type) { - case map[string]interface{}: - // key is the map key for the page body if the body type is `map[string]interface{}`. + case map[string]any: + // key is the map key for the page body if the body type is `map[string]any`. 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{}) + err = p.EachPage(ctx, func(_ context.Context, page Page) (bool, error) { + b := page.GetBody().(map[string]any) 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") { - // check the field's type. we only want []interface{} (which is really []map[string]interface{}) + // check the field's type. we only want []any (which is really []map[string]any) switch vt := v.(type) { - case []interface{}: + case []any: key = k pagesSlice = append(pagesSlice, vt...) } @@ -184,12 +186,12 @@ func (p Pager) AllPages() (Page, error) { if err != nil { return nil, err } - // Set body to value of type `map[string]interface{}` + // Set body to value of type `map[string]any` body = reflect.MakeMap(reflect.MapOf(reflect.TypeOf(key), reflect.TypeOf(pagesSlice))) body.SetMapIndex(reflect.ValueOf(key), reflect.ValueOf(pagesSlice)) case []byte: // Iterate over the pages to concatenate the bodies. - err = p.EachPage(func(page Page) (bool, error) { + err = p.EachPage(ctx, func(_ context.Context, page Page) (bool, error) { b := page.GetBody().([]byte) pagesSlice = append(pagesSlice, b) // seperate pages with a comma @@ -211,24 +213,24 @@ func (p Pager) AllPages() (Page, error) { // Set body to value of type `bytes`. body = reflect.New(reflect.TypeOf(b)).Elem() body.SetBytes(b) - case []interface{}: + case []any: // Iterate over the pages to concatenate the bodies. - err = p.EachPage(func(page Page) (bool, error) { - b := page.GetBody().([]interface{}) + err = p.EachPage(ctx, func(_ context.Context, page Page) (bool, error) { + b := page.GetBody().([]any) pagesSlice = append(pagesSlice, b...) return true, nil }) if err != nil { return nil, err } - // Set body to value of type `[]interface{}` + // Set body to value of type `[]any` body = reflect.MakeSlice(reflect.TypeOf(pagesSlice), len(pagesSlice), len(pagesSlice)) for i, s := range pagesSlice { body.Index(i).Set(reflect.ValueOf(s)) } default: err := gophercloud.ErrUnexpectedType{} - err.Expected = "map[string]interface{}/[]byte/[]interface{}" + err.Expected = "map[string]any/[]byte/[]any" err.Actual = fmt.Sprintf("%T", pb) return nil, err } diff --git a/vendor/github.com/gophercloud/gophercloud/pagination/pkg.go b/vendor/github.com/gophercloud/gophercloud/v2/pagination/pkg.go similarity index 100% rename from vendor/github.com/gophercloud/gophercloud/pagination/pkg.go rename to vendor/github.com/gophercloud/gophercloud/v2/pagination/pkg.go diff --git a/vendor/github.com/gophercloud/gophercloud/pagination/single.go b/vendor/github.com/gophercloud/gophercloud/v2/pagination/single.go similarity index 81% rename from vendor/github.com/gophercloud/gophercloud/pagination/single.go rename to vendor/github.com/gophercloud/gophercloud/v2/pagination/single.go index 4251d6491efe1..416621121b5f1 100644 --- a/vendor/github.com/gophercloud/gophercloud/pagination/single.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/pagination/single.go @@ -4,7 +4,7 @@ import ( "fmt" "reflect" - "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/v2" ) // SinglePageBase may be embedded in a Page that contains all of the results from an operation at once. @@ -17,17 +17,17 @@ func (current SinglePageBase) NextPageURL() (string, error) { // IsEmpty satisifies the IsEmpty method of the Page interface func (current SinglePageBase) IsEmpty() (bool, error) { - if b, ok := current.Body.([]interface{}); ok { + if b, ok := current.Body.([]any); ok { return len(b) == 0, nil } err := gophercloud.ErrUnexpectedType{} - err.Expected = "[]interface{}" + err.Expected = "[]any" err.Actual = fmt.Sprintf("%v", reflect.TypeOf(current.Body)) return true, err } // GetBody returns the single page's body. This method is needed to satisfy the // Page interface. -func (current SinglePageBase) GetBody() interface{} { +func (current SinglePageBase) GetBody() any { return current.Body } diff --git a/vendor/github.com/gophercloud/gophercloud/params.go b/vendor/github.com/gophercloud/gophercloud/v2/params.go similarity index 97% rename from vendor/github.com/gophercloud/gophercloud/params.go rename to vendor/github.com/gophercloud/gophercloud/v2/params.go index 5abc2c55899b1..09b322a6a2840 100644 --- a/vendor/github.com/gophercloud/gophercloud/params.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/params.go @@ -32,7 +32,7 @@ BuildRequestBody is used within Gophercloud to more fully understand how it fits within the request process as a whole rather than use it directly as shown above. */ -func BuildRequestBody(opts interface{}, parent string) (map[string]interface{}, error) { +func BuildRequestBody(opts any, parent string) (map[string]any, error) { optsValue := reflect.ValueOf(opts) if optsValue.Kind() == reflect.Ptr { optsValue = optsValue.Elem() @@ -43,7 +43,7 @@ func BuildRequestBody(opts interface{}, parent string) (map[string]interface{}, optsType = optsType.Elem() } - optsMap := make(map[string]interface{}) + optsMap := make(map[string]any) if optsValue.Kind() == reflect.Struct { //fmt.Printf("optsValue.Kind() is a reflect.Struct: %+v\n", optsValue.Kind()) for i := 0; i < optsValue.NumField(); i++ { @@ -180,7 +180,7 @@ func BuildRequestBody(opts interface{}, parent string) (map[string]interface{}, //fmt.Printf("optsMap: %+v\n", optsMap) if parent != "" { - optsMap = map[string]interface{}{parent: optsMap} + optsMap = map[string]any{parent: optsMap} } //fmt.Printf("optsMap after parent added: %+v\n", optsMap) return optsMap, nil @@ -282,10 +282,7 @@ func isZero(v reflect.Value) bool { return z case reflect.Struct: if v.Type() == reflect.TypeOf(t) { - if v.Interface().(time.Time).IsZero() { - return true - } - return false + return v.Interface().(time.Time).IsZero() } z := true for i := 0; i < v.NumField(); i++ { @@ -328,7 +325,7 @@ Slice are handled in one of two ways: Baz []int `q:"baz" format="comma-separated"` // E.g. ?baz=1,2 } */ -func BuildQueryString(opts interface{}) (*url.URL, error) { +func BuildQueryString(opts any) (*url.URL, error) { optsValue := reflect.ValueOf(opts) if optsValue.Kind() == reflect.Ptr { optsValue = optsValue.Elem() @@ -434,7 +431,7 @@ will be converted into: Untagged fields and fields left at their zero values are skipped. Integers, booleans and string values are supported. */ -func BuildHeaders(opts interface{}) (map[string]string, error) { +func BuildHeaders(opts any) (map[string]string, error) { optsValue := reflect.ValueOf(opts) if optsValue.Kind() == reflect.Ptr { optsValue = optsValue.Elem() diff --git a/vendor/github.com/gophercloud/gophercloud/provider_client.go b/vendor/github.com/gophercloud/gophercloud/v2/provider_client.go similarity index 79% rename from vendor/github.com/gophercloud/gophercloud/provider_client.go rename to vendor/github.com/gophercloud/gophercloud/v2/provider_client.go index 7e25882c8733d..007266f6351bc 100644 --- a/vendor/github.com/gophercloud/gophercloud/provider_client.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/provider_client.go @@ -6,7 +6,6 @@ import ( "encoding/json" "errors" "io" - "io/ioutil" "net/http" "strings" "sync" @@ -14,7 +13,7 @@ import ( // DefaultUserAgent is the default User-Agent string set in the request header. const ( - DefaultUserAgent = "gophercloud/v1.14.1" + DefaultUserAgent = "gophercloud/v2.2.0" DefaultMaxBackoffRetries = 60 ) @@ -82,15 +81,12 @@ type ProviderClient struct { // ReauthFunc is the function used to re-authenticate the user if the request // fails with a 401 HTTP response code. This a needed because there may be multiple // authentication functions for different Identity service versions. - ReauthFunc func() error + ReauthFunc func(context.Context) error // Throwaway determines whether if this client is a throw-away client. It's a copy of user's provider client // with the token and reauth func zeroed. Such client can be used to perform reauthorization. Throwaway bool - // Context is the context passed to the HTTP request. - Context context.Context - // Retry backoff func is called when rate limited. RetryBackoffFunc RetryBackoffFunc @@ -269,13 +265,13 @@ func (client *ProviderClient) SetThrowaway(v bool) { // this case, the reauthentication can be skipped if another thread has already // reauthenticated in the meantime. If no previous token is known, an empty // string should be passed instead to force unconditional reauthentication. -func (client *ProviderClient) Reauthenticate(previousToken string) error { +func (client *ProviderClient) Reauthenticate(ctx context.Context, previousToken string) error { if client.ReauthFunc == nil { return nil } if client.reauthmut == nil { - return client.ReauthFunc() + return client.ReauthFunc(ctx) } future := newReauthFuture() @@ -296,7 +292,7 @@ func (client *ProviderClient) Reauthenticate(previousToken string) error { // Perform the actual reauthentication. var err error if previousToken == "" || client.TokenID == previousToken { - err = client.ReauthFunc() + err = client.ReauthFunc(ctx) } else { err = nil } @@ -315,13 +311,13 @@ type RequestOpts struct { // JSONBody, if provided, will be encoded as JSON and used as the body of the HTTP request. The // content type of the request will default to "application/json" unless overridden by MoreHeaders. // It's an error to specify both a JSONBody and a RawBody. - JSONBody interface{} + JSONBody any // RawBody contains an io.Reader that will be consumed by the request directly. No content-type // will be set unless one is provided explicitly by MoreHeaders. RawBody io.Reader // JSONResponse, if provided, will be populated with the contents of the response body parsed as // JSON. - JSONResponse interface{} + JSONResponse any // OkCodes contains a list of numeric HTTP status codes that should be interpreted as success. If // the response has a different code, an error will be returned. OkCodes []int @@ -331,9 +327,6 @@ type RequestOpts struct { // OmitHeaders specifies the HTTP headers which should be omitted. // OmitHeaders will override MoreHeaders OmitHeaders []string - // ErrorContext specifies the resource error type to return if an error is encountered. - // This lets resources override default error messages based on the response status code. - ErrorContext error // KeepResponseBody specifies whether to keep the HTTP response body. Usually used, when the HTTP // response body is considered for further use. Valid when JSONResponse is nil. KeepResponseBody bool @@ -352,15 +345,15 @@ type requestState struct { var applicationJSON = "application/json" -// Request performs an HTTP request using the ProviderClient's current HTTPClient. An authentication -// header will automatically be provided. -func (client *ProviderClient) Request(method, url string, options *RequestOpts) (*http.Response, error) { - return client.doRequest(method, url, options, &requestState{ +// Request performs an HTTP request using the ProviderClient's +// current HTTPClient. An authentication header will automatically be provided. +func (client *ProviderClient) Request(ctx context.Context, method, url string, options *RequestOpts) (*http.Response, error) { + return client.doRequest(ctx, method, url, options, &requestState{ hasReauthenticated: false, }) } -func (client *ProviderClient) doRequest(method, url string, options *RequestOpts, state *requestState) (*http.Response, error) { +func (client *ProviderClient) doRequest(ctx context.Context, method, url string, options *RequestOpts, state *requestState) (*http.Response, error) { var body io.Reader var contentType *string @@ -389,14 +382,10 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts body = options.RawBody } - // Construct the http.Request. - req, err := http.NewRequest(method, url, body) + req, err := http.NewRequestWithContext(ctx, method, url, body) if err != nil { return nil, err } - if client.Context != nil { - req = req.WithContext(client.Context) - } // Populate the request headers. // Apply options.MoreHeaders and options.OmitHeaders, to give the caller the chance to @@ -432,12 +421,12 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts if client.RetryFunc != nil { var e error state.retries = state.retries + 1 - e = client.RetryFunc(client.Context, method, url, options, err, state.retries) + e = client.RetryFunc(ctx, method, url, options, err, state.retries) if e != nil { return nil, e } - return client.doRequest(method, url, options, state) + return client.doRequest(ctx, method, url, options, state) } return nil, err } @@ -458,7 +447,7 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts } if !ok { - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) resp.Body.Close() respErr := ErrUnexpectedResponseCode{ URL: url, @@ -469,16 +458,10 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts ResponseHeader: resp.Header, } - errType := options.ErrorContext switch resp.StatusCode { - case http.StatusBadRequest: - err = ErrDefault400{respErr} - if error400er, ok := errType.(Err400er); ok { - err = error400er.Error400(respErr) - } case http.StatusUnauthorized: if client.ReauthFunc != nil && !state.hasReauthenticated { - err = client.Reauthenticate(prereqtok) + err = client.Reauthenticate(ctx, prereqtok) if err != nil { e := &ErrUnableToReauthenticate{} e.ErrOriginal = respErr @@ -487,60 +470,28 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts } if options.RawBody != nil { if seeker, ok := options.RawBody.(io.Seeker); ok { - seeker.Seek(0, 0) + if _, err := seeker.Seek(0, 0); err != nil { + return nil, err + } } } state.hasReauthenticated = true - resp, err = client.doRequest(method, url, options, state) + resp, err = client.doRequest(ctx, method, url, options, state) if err != nil { - switch err.(type) { + switch e := err.(type) { case *ErrUnexpectedResponseCode: - e := &ErrErrorAfterReauthentication{} - e.ErrOriginal = err.(*ErrUnexpectedResponseCode) - return nil, e + err := &ErrErrorAfterReauthentication{} + err.ErrOriginal = e + return nil, err default: - e := &ErrErrorAfterReauthentication{} - e.ErrOriginal = err - return nil, e + err := &ErrErrorAfterReauthentication{} + err.ErrOriginal = e + return nil, err } } return resp, nil } - err = ErrDefault401{respErr} - if error401er, ok := errType.(Err401er); ok { - err = error401er.Error401(respErr) - } - case http.StatusForbidden: - err = ErrDefault403{respErr} - if error403er, ok := errType.(Err403er); ok { - err = error403er.Error403(respErr) - } - case http.StatusNotFound: - err = ErrDefault404{respErr} - if error404er, ok := errType.(Err404er); ok { - err = error404er.Error404(respErr) - } - case http.StatusMethodNotAllowed: - err = ErrDefault405{respErr} - if error405er, ok := errType.(Err405er); ok { - err = error405er.Error405(respErr) - } - case http.StatusRequestTimeout: - err = ErrDefault408{respErr} - if error408er, ok := errType.(Err408er); ok { - err = error408er.Error408(respErr) - } - case http.StatusConflict: - err = ErrDefault409{respErr} - if error409er, ok := errType.(Err409er); ok { - err = error409er.Error409(respErr) - } case http.StatusTooManyRequests, 498: - err = ErrDefault429{respErr} - if error429er, ok := errType.(Err429er); ok { - err = error429er.Error429(respErr) - } - maxTries := client.MaxBackoffRetries if maxTries == 0 { maxTries = DefaultMaxBackoffRetries @@ -550,33 +501,13 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts var e error state.retries = state.retries + 1 - e = f(client.Context, &respErr, err, state.retries) + e = f(ctx, &respErr, err, state.retries) if e != nil { return resp, e } - return client.doRequest(method, url, options, state) - } - case http.StatusInternalServerError: - err = ErrDefault500{respErr} - if error500er, ok := errType.(Err500er); ok { - err = error500er.Error500(respErr) - } - case http.StatusBadGateway: - err = ErrDefault502{respErr} - if error502er, ok := errType.(Err502er); ok { - err = error502er.Error502(respErr) - } - case http.StatusServiceUnavailable: - err = ErrDefault503{respErr} - if error503er, ok := errType.(Err503er); ok { - err = error503er.Error503(respErr) - } - case http.StatusGatewayTimeout: - err = ErrDefault504{respErr} - if error504er, ok := errType.(Err504er); ok { - err = error504er.Error504(respErr) + return client.doRequest(ctx, method, url, options, state) } } @@ -587,12 +518,12 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts 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) + e = client.RetryFunc(ctx, method, url, options, err, state.retries) if e != nil { return resp, e } - return client.doRequest(method, url, options, state) + return client.doRequest(ctx, method, url, options, state) } return resp, err @@ -604,19 +535,19 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts // Don't decode JSON when there is no content if resp.StatusCode == http.StatusNoContent { // read till EOF, otherwise the connection will be closed and cannot be reused - _, err = io.Copy(ioutil.Discard, resp.Body) + _, err = io.Copy(io.Discard, resp.Body) 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) + e = client.RetryFunc(ctx, method, url, options, err, state.retries) if e != nil { return resp, e } - return client.doRequest(method, url, options, state) + return client.doRequest(ctx, method, url, options, state) } return nil, err } @@ -626,7 +557,7 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts if !options.KeepResponseBody && options.JSONResponse == nil { defer resp.Body.Close() // read till EOF, otherwise the connection will be closed and cannot be reused - if _, err := io.Copy(ioutil.Discard, resp.Body); err != nil { + if _, err := io.Copy(io.Discard, resp.Body); err != nil { return nil, err } } diff --git a/vendor/github.com/gophercloud/gophercloud/results.go b/vendor/github.com/gophercloud/gophercloud/v2/results.go similarity index 96% rename from vendor/github.com/gophercloud/gophercloud/results.go rename to vendor/github.com/gophercloud/gophercloud/v2/results.go index b3ee9d5682dbc..9e6f630abb425 100644 --- a/vendor/github.com/gophercloud/gophercloud/results.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/results.go @@ -28,7 +28,7 @@ provider- or extension-specific information as well. type Result struct { // Body is the payload of the HTTP response from the server. In most cases, // this will be the deserialized JSON structure. - Body interface{} + Body any // StatusCode is the HTTP status code of the original response. Will be // one of the OkCodes defined on the gophercloud.RequestOpts that was @@ -46,7 +46,7 @@ type Result struct { // ExtractInto allows users to provide an object into which `Extract` will extract // the `Result.Body`. This would be useful for OpenStack providers that have // different fields in the response object than OpenStack proper. -func (r Result) ExtractInto(to interface{}) error { +func (r Result) ExtractInto(to any) error { if r.Err != nil { return r.Err } @@ -67,12 +67,12 @@ func (r Result) ExtractInto(to interface{}) error { return err } -func (r Result) extractIntoPtr(to interface{}, label string) error { +func (r Result) extractIntoPtr(to any, label string) error { if label == "" { return r.ExtractInto(&to) } - var m map[string]interface{} + var m map[string]any err := r.ExtractInto(&m) if err != nil { return err @@ -95,7 +95,7 @@ func (r Result) extractIntoPtr(to interface{}, label string) error { if typeOfV.NumField() > 0 && typeOfV.Field(0).Anonymous { newSlice := reflect.MakeSlice(reflect.SliceOf(typeOfV), 0, 0) - if mSlice, ok := m[label].([]interface{}); ok { + if mSlice, ok := m[label].([]any); ok { for _, v := range mSlice { // For each iteration of the slice, we create a new struct. // This is to work around a bug where elements of a slice @@ -171,7 +171,7 @@ func (r Result) extractIntoPtr(to interface{}, label string) error { } // ExtractIntoStructPtr will unmarshal the Result (r) into the provided -// interface{} (to). +// any (to). // // NOTE: For internal use only // @@ -179,7 +179,7 @@ func (r Result) extractIntoPtr(to interface{}, label string) error { // // If provided, `label` will be filtered out of the response // body prior to `r` being unmarshalled into `to`. -func (r Result) ExtractIntoStructPtr(to interface{}, label string) error { +func (r Result) ExtractIntoStructPtr(to any, label string) error { if r.Err != nil { return r.Err } @@ -197,7 +197,7 @@ func (r Result) ExtractIntoStructPtr(to interface{}, label string) error { } // ExtractIntoSlicePtr will unmarshal the Result (r) into the provided -// interface{} (to). +// any (to). // // NOTE: For internal use only // @@ -205,7 +205,7 @@ func (r Result) ExtractIntoStructPtr(to interface{}, label string) error { // // If provided, `label` will be filtered out of the response // body prior to `r` being unmarshalled into `to`. -func (r Result) ExtractIntoSlicePtr(to interface{}, label string) error { +func (r Result) ExtractIntoSlicePtr(to any, label string) error { if r.Err != nil { return r.Err } @@ -267,7 +267,7 @@ type HeaderResult struct { // ExtractInto allows users to provide an object into which `Extract` will // extract the http.Header headers of the result. -func (r HeaderResult) ExtractInto(to interface{}) error { +func (r HeaderResult) ExtractInto(to any) error { if r.Err != nil { return r.Err } diff --git a/vendor/github.com/gophercloud/gophercloud/service_client.go b/vendor/github.com/gophercloud/gophercloud/v2/service_client.go similarity index 75% rename from vendor/github.com/gophercloud/gophercloud/service_client.go rename to vendor/github.com/gophercloud/gophercloud/v2/service_client.go index 94a161e3408c5..11b80108c3a2e 100644 --- a/vendor/github.com/gophercloud/gophercloud/service_client.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/service_client.go @@ -1,6 +1,7 @@ package gophercloud import ( + "context" "io" "net/http" "strings" @@ -47,7 +48,7 @@ func (client *ServiceClient) ServiceURL(parts ...string) string { return client.ResourceBaseURL() + strings.Join(parts, "/") } -func (client *ServiceClient) initReqOpts(JSONBody interface{}, JSONResponse interface{}, opts *RequestOpts) { +func (client *ServiceClient) initReqOpts(JSONBody any, JSONResponse any, opts *RequestOpts) { if v, ok := (JSONBody).(io.Reader); ok { opts.RawBody = v } else if JSONBody != nil { @@ -60,57 +61,57 @@ func (client *ServiceClient) initReqOpts(JSONBody interface{}, JSONResponse inte } // Get calls `Request` with the "GET" HTTP verb. -func (client *ServiceClient) Get(url string, JSONResponse interface{}, opts *RequestOpts) (*http.Response, error) { +func (client *ServiceClient) Get(ctx context.Context, url string, JSONResponse any, opts *RequestOpts) (*http.Response, error) { if opts == nil { opts = new(RequestOpts) } client.initReqOpts(nil, JSONResponse, opts) - return client.Request("GET", url, opts) + return client.Request(ctx, "GET", url, opts) } // Post calls `Request` with the "POST" HTTP verb. -func (client *ServiceClient) Post(url string, JSONBody interface{}, JSONResponse interface{}, opts *RequestOpts) (*http.Response, error) { +func (client *ServiceClient) Post(ctx context.Context, url string, JSONBody any, JSONResponse any, opts *RequestOpts) (*http.Response, error) { if opts == nil { opts = new(RequestOpts) } client.initReqOpts(JSONBody, JSONResponse, opts) - return client.Request("POST", url, opts) + return client.Request(ctx, "POST", url, opts) } // Put calls `Request` with the "PUT" HTTP verb. -func (client *ServiceClient) Put(url string, JSONBody interface{}, JSONResponse interface{}, opts *RequestOpts) (*http.Response, error) { +func (client *ServiceClient) Put(ctx context.Context, url string, JSONBody any, JSONResponse any, opts *RequestOpts) (*http.Response, error) { if opts == nil { opts = new(RequestOpts) } client.initReqOpts(JSONBody, JSONResponse, opts) - return client.Request("PUT", url, opts) + return client.Request(ctx, "PUT", url, opts) } // Patch calls `Request` with the "PATCH" HTTP verb. -func (client *ServiceClient) Patch(url string, JSONBody interface{}, JSONResponse interface{}, opts *RequestOpts) (*http.Response, error) { +func (client *ServiceClient) Patch(ctx context.Context, url string, JSONBody any, JSONResponse any, opts *RequestOpts) (*http.Response, error) { if opts == nil { opts = new(RequestOpts) } client.initReqOpts(JSONBody, JSONResponse, opts) - return client.Request("PATCH", url, opts) + return client.Request(ctx, "PATCH", url, opts) } // Delete calls `Request` with the "DELETE" HTTP verb. -func (client *ServiceClient) Delete(url string, opts *RequestOpts) (*http.Response, error) { +func (client *ServiceClient) Delete(ctx context.Context, url string, opts *RequestOpts) (*http.Response, error) { if opts == nil { opts = new(RequestOpts) } client.initReqOpts(nil, nil, opts) - return client.Request("DELETE", url, opts) + return client.Request(ctx, "DELETE", url, opts) } // Head calls `Request` with the "HEAD" HTTP verb. -func (client *ServiceClient) Head(url string, opts *RequestOpts) (*http.Response, error) { +func (client *ServiceClient) Head(ctx context.Context, url string, opts *RequestOpts) (*http.Response, error) { if opts == nil { opts = new(RequestOpts) } client.initReqOpts(nil, nil, opts) - return client.Request("HEAD", url, opts) + return client.Request(ctx, "HEAD", url, opts) } func (client *ServiceClient) setMicroversionHeader(opts *RequestOpts) { @@ -133,7 +134,7 @@ func (client *ServiceClient) setMicroversionHeader(opts *RequestOpts) { } // Request carries out the HTTP operation for the service client -func (client *ServiceClient) Request(method, url string, options *RequestOpts) (*http.Response, error) { +func (client *ServiceClient) Request(ctx context.Context, method, url string, options *RequestOpts) (*http.Response, error) { if options.MoreHeaders == nil { options.MoreHeaders = make(map[string]string) } @@ -151,7 +152,7 @@ func (client *ServiceClient) Request(method, url string, options *RequestOpts) ( options.MoreHeaders[k] = v } } - return client.ProviderClient.Request(method, url, options) + return client.ProviderClient.Request(ctx, method, url, options) } // ParseResponse is a helper function to parse http.Response to constituents. diff --git a/vendor/github.com/gophercloud/gophercloud/util.go b/vendor/github.com/gophercloud/gophercloud/v2/util.go similarity index 69% rename from vendor/github.com/gophercloud/gophercloud/util.go rename to vendor/github.com/gophercloud/gophercloud/v2/util.go index 2740c301e5111..ad8a7dfaaa5c5 100644 --- a/vendor/github.com/gophercloud/gophercloud/util.go +++ b/vendor/github.com/gophercloud/gophercloud/v2/util.go @@ -1,7 +1,7 @@ package gophercloud import ( - "fmt" + "context" "net/url" "path/filepath" "reflect" @@ -61,8 +61,8 @@ func NormalizeURL(url string) string { // // This is useful for determining the extra fields returned in response bodies // for resources that can contain an arbitrary or dynamic number of fields. -func RemainingKeys(s interface{}, m map[string]interface{}) (extras map[string]interface{}) { - extras = make(map[string]interface{}) +func RemainingKeys(s any, m map[string]any) (extras map[string]any) { + extras = make(map[string]any) for k, v := range m { extras[k] = v } @@ -83,48 +83,27 @@ func RemainingKeys(s interface{}, m map[string]interface{}) (extras map[string]i return } -// WaitFor polls a predicate function, once per second, up to a timeout limit. +// WaitFor polls a predicate function, once per second, up to a context cancellation. // This is useful to wait for a resource to transition to a certain state. -// To handle situations when the predicate might hang indefinitely, the -// predicate will be prematurely cancelled after the timeout. // Resource packages will wrap this in a more convenient function that's // specific to a certain resource, but it can also be useful on its own. -func WaitFor(timeout int, predicate func() (bool, error)) error { - type WaitForResult struct { - Success bool - Error error +func WaitFor(ctx context.Context, predicate func(context.Context) (bool, error)) error { + if done, err := predicate(ctx); done || err != nil { + return err } - start := time.Now().Unix() + ticker := time.NewTicker(1 * time.Second) + defer ticker.Stop() for { - // If a timeout is set, and that's been exceeded, shut it down. - if timeout >= 0 && time.Now().Unix()-start >= int64(timeout) { - return fmt.Errorf("A timeout occurred") - } - - time.Sleep(1 * time.Second) - - var result WaitForResult - ch := make(chan bool, 1) - go func() { - defer close(ch) - satisfied, err := predicate() - result.Success = satisfied - result.Error = err - }() - select { - case <-ch: - if result.Error != nil { - return result.Error - } - if result.Success { - return nil + case <-ticker.C: + if done, err := predicate(ctx); done || err != nil { + return err } - // If the predicate has not finished by the timeout, cancel it. - case <-time.After(time.Duration(timeout) * time.Second): - return fmt.Errorf("A timeout occurred") + + case <-ctx.Done(): + return ctx.Err() } } } diff --git a/vendor/modules.txt b/vendor/modules.txt index afc90b965d756..5611be42088ff 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -734,48 +734,47 @@ github.com/googleapis/gax-go/v2/apierror github.com/googleapis/gax-go/v2/apierror/internal/proto github.com/googleapis/gax-go/v2/callctx github.com/googleapis/gax-go/v2/internal -# github.com/gophercloud/gophercloud v1.14.1 -## explicit; go 1.14 -github.com/gophercloud/gophercloud -github.com/gophercloud/gophercloud/openstack -github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes -github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/attachinterfaces -github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones -github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume -github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs -github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/schedulerhints -github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups -github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach -github.com/gophercloud/gophercloud/openstack/compute/v2/flavors -github.com/gophercloud/gophercloud/openstack/compute/v2/servers -github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets -github.com/gophercloud/gophercloud/openstack/dns/v2/zones -github.com/gophercloud/gophercloud/openstack/identity/v2/tenants -github.com/gophercloud/gophercloud/openstack/identity/v2/tokens -github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/ec2tokens -github.com/gophercloud/gophercloud/openstack/identity/v3/extensions/oauth1 -github.com/gophercloud/gophercloud/openstack/identity/v3/tokens -github.com/gophercloud/gophercloud/openstack/imageservice/v2/images -github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions -github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/l7policies -github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners -github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers -github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors -github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools -github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/attributestags -github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external -github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips -github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers -github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups -github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules -github.com/gophercloud/gophercloud/openstack/networking/v2/networks -github.com/gophercloud/gophercloud/openstack/networking/v2/ports -github.com/gophercloud/gophercloud/openstack/networking/v2/subnets -github.com/gophercloud/gophercloud/openstack/objectstorage/v1/accounts -github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers -github.com/gophercloud/gophercloud/openstack/objectstorage/v1/objects -github.com/gophercloud/gophercloud/openstack/utils -github.com/gophercloud/gophercloud/pagination +# github.com/gophercloud/gophercloud/v2 v2.2.0 +## explicit; go 1.22 +github.com/gophercloud/gophercloud/v2 +github.com/gophercloud/gophercloud/v2/openstack +github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes +github.com/gophercloud/gophercloud/v2/openstack/compute/v2/attachinterfaces +github.com/gophercloud/gophercloud/v2/openstack/compute/v2/availabilityzones +github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors +github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs +github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups +github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers +github.com/gophercloud/gophercloud/v2/openstack/compute/v2/volumeattach +github.com/gophercloud/gophercloud/v2/openstack/dns/v2/recordsets +github.com/gophercloud/gophercloud/v2/openstack/dns/v2/zones +github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tenants +github.com/gophercloud/gophercloud/v2/openstack/identity/v2/tokens +github.com/gophercloud/gophercloud/v2/openstack/identity/v3/ec2tokens +github.com/gophercloud/gophercloud/v2/openstack/identity/v3/oauth1 +github.com/gophercloud/gophercloud/v2/openstack/identity/v3/tokens +github.com/gophercloud/gophercloud/v2/openstack/image/v2/images +github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/apiversions +github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/l7policies +github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/listeners +github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/loadbalancers +github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/monitors +github.com/gophercloud/gophercloud/v2/openstack/loadbalancer/v2/pools +github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags +github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external +github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips +github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers +github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups +github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules +github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks +github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports +github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets +github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1 +github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/accounts +github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/containers +github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects +github.com/gophercloud/gophercloud/v2/openstack/utils +github.com/gophercloud/gophercloud/v2/pagination # github.com/gorilla/mux v1.8.0 ## explicit; go 1.12 github.com/gorilla/mux