Skip to content

Commit

Permalink
Upgrade to Gophercloud v2
Browse files Browse the repository at this point in the history
Essentially:

* Add a context argument to Gophercloud functions
* Refactor scheduler hints for server creation
  • Loading branch information
pierreprinetti committed Oct 22, 2024
1 parent 458758e commit b883fc2
Show file tree
Hide file tree
Showing 284 changed files with 6,307 additions and 4,508 deletions.
2 changes: 1 addition & 1 deletion cloudmock/openstack/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"net/http"
"net/http/httptest"

"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/v2"
)

type MockOpenstackServer struct {
Expand Down
4 changes: 2 additions & 2 deletions cloudmock/openstack/mockblockstorage/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
"github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/availabilityzones"
cinderv3 "github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumes"
"k8s.io/kops/cloudmock/openstack"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mockblockstorage/availabilityzones.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"net/http"

"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones"
"github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/availabilityzones"
)

type availabilityZoneListResponse struct {
Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mockblockstorage/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions cloudmock/openstack/mockcompute/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mockcompute/flavors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mockcompute/keypairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mockcompute/servergroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions cloudmock/openstack/mockcompute/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
Expand All @@ -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),
})

Expand Down
4 changes: 2 additions & 2 deletions cloudmock/openstack/mockdns/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
4 changes: 2 additions & 2 deletions cloudmock/openstack/mockdns/zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mockimage/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mockimage/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions cloudmock/openstack/mockloadbalancer/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mockloadbalancer/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions cloudmock/openstack/mockloadbalancer/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mockloadbalancer/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions cloudmock/openstack/mocknetworking/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mocknetworking/floatingips.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mocknetworking/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cloudmock/openstack/mocknetworking/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mocknetworking/securitygrouprules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mocknetworking/securitygroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cloudmock/openstack/mocknetworking/subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -93,15 +93,15 @@ 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(),
TTL: int(upsert.Ttl()),
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
}
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
Loading

0 comments on commit b883fc2

Please sign in to comment.