Skip to content

Commit

Permalink
Merge pull request #44 from jgraichen/renovate/github.com-gophercloud…
Browse files Browse the repository at this point in the history
…-gophercloud-2.x
  • Loading branch information
jgraichen authored Jul 8, 2024
2 parents 1a9df6b + da047b4 commit d087a50
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 32 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
require (
github.com/coreos/go-systemd/v22 v22.5.0
github.com/docker/go-plugins-helpers v0.0.0-20240701071450-45e2431495c8
github.com/gophercloud/gophercloud v1.12.0
github.com/gophercloud/gophercloud/v2 v2.0.0
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.9.3
)
Expand All @@ -16,6 +16,6 @@ require (
github.com/docker/go-connections v0.4.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/tools v0.6.0 // indirect
)
17 changes: 4 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh
github.com/docker/go-plugins-helpers v0.0.0-20240701071450-45e2431495c8 h1:IMfrF5LCzP2Vhw7j4IIH3HxPsCLuZYjDqFAM/C88ulg=
github.com/docker/go-plugins-helpers v0.0.0-20240701071450-45e2431495c8/go.mod h1:LFyLie6XcDbyKGeVK6bHe+9aJTYCxWLBg5IrJZOaXKA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gophercloud/gophercloud v1.12.0 h1:Jrz16vPAL93l80q16fp8NplrTCp93y7rZh2P3Q4Yq7g=
github.com/gophercloud/gophercloud v1.12.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM=
github.com/gophercloud/gophercloud/v2 v2.0.0 h1:iH0x0Ji79a/ULzmq95fvOBAyie7+M+wUAEu+JrRMsCk=
github.com/gophercloud/gophercloud/v2 v2.0.0/go.mod h1:ZKbcGNjxFTSaP5wlvtLDdsppllD/UGGvXBPqcjeqA8Y=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
Expand All @@ -23,27 +23,18 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
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-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"encoding/json"
"flag"
"io/ioutil"
Expand All @@ -11,8 +12,8 @@ import (
log "github.com/sirupsen/logrus"

"github.com/docker/go-plugins-helpers/volume"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/gophercloud/v2"
"github.com/gophercloud/gophercloud/v2/openstack"
)

type tConfig struct {
Expand Down Expand Up @@ -104,7 +105,7 @@ func main() {
logger := log.WithField("endpoint", opts.IdentityEndpoint)
logger.Info("Connecting...")

provider, err := openstack.AuthenticatedClient(opts)
provider, err := openstack.AuthenticatedClient(context.TODO(), opts)
if err != nil {
logger.WithError(err).Fatal(err.Error())
}
Expand Down
28 changes: 14 additions & 14 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
log "github.com/sirupsen/logrus"

"github.com/docker/go-plugins-helpers/volume"
"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/volumeattach"
"github.com/gophercloud/gophercloud/pagination"
"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/volumeattach"
"github.com/gophercloud/gophercloud/v2/pagination"
)

type plugin struct {
Expand Down Expand Up @@ -98,10 +98,10 @@ func (d plugin) Create(r *volume.CreateRequest) error {
}
}

vol, err := volumes.Create(d.blockClient, volumes.CreateOpts{
vol, err := volumes.Create(context.TODO(), d.blockClient, volumes.CreateOpts{
Size: size,
Name: r.Name,
}).Extract()
}, volumes.SchedulerHintOpts{}).Extract()

if err != nil {
logger.WithError(err).Errorf("Error creating volume: %s", err.Error())
Expand Down Expand Up @@ -142,7 +142,7 @@ func (d plugin) List() (*volume.ListResponse, error) {
var vols []*volume.Volume

pager := volumes.List(d.blockClient, volumes.ListOpts{})
err := pager.EachPage(func(page pagination.Page) (bool, error) {
err := pager.EachPage(context.TODO(), func(ctx context.Context, page pagination.Page) (bool, error) {
vList, _ := volumes.ExtractVolumes(page)

for _, v := range vList {
Expand Down Expand Up @@ -189,7 +189,7 @@ func (d plugin) Mount(r *volume.MountRequest) (*volume.MountResponse, error) {
}
}

if vol, err = volumes.Get(d.blockClient, vol.ID).Extract(); err != nil {
if vol, err = volumes.Get(context.TODO(), d.blockClient, vol.ID).Extract(); err != nil {
return nil, err
}

Expand All @@ -216,7 +216,7 @@ func (d plugin) Mount(r *volume.MountRequest) (*volume.MountResponse, error) {
// Attaching block volume to compute instance

opts := volumeattach.CreateOpts{VolumeID: vol.ID}
_, err = volumeattach.Create(d.computeClient, d.config.MachineID, opts).Extract()
_, err = volumeattach.Create(context.TODO(), d.computeClient, d.config.MachineID, opts).Extract()

if err != nil {
logger.WithError(err).Errorf("Error attaching volume: %s", err.Error())
Expand Down Expand Up @@ -312,7 +312,7 @@ func (d plugin) Remove(r *volume.RemoveRequest) error {

logger.Debug("Deleting block volume...")

err = volumes.Delete(d.blockClient, vol.ID, volumes.DeleteOpts{}).ExtractErr()
err = volumes.Delete(context.TODO(), d.blockClient, vol.ID, volumes.DeleteOpts{}).ExtractErr()
if err != nil {
logger.WithError(err).Errorf("Error deleting volume: %s", err.Error())
return err
Expand Down Expand Up @@ -361,7 +361,7 @@ func (d plugin) getByName(name string) (*volumes.Volume, error) {
var volume *volumes.Volume

pager := volumes.List(d.blockClient, volumes.ListOpts{Name: name})
err := pager.EachPage(func(page pagination.Page) (bool, error) {
err := pager.EachPage(context.TODO(), func(ctx context.Context, page pagination.Page) (bool, error) {
vList, err := volumes.ExtractVolumes(page)

if err != nil {
Expand All @@ -387,7 +387,7 @@ func (d plugin) getByName(name string) (*volumes.Volume, error) {

func (d plugin) detachVolume(ctx context.Context, vol *volumes.Volume) (*volumes.Volume, error) {
for _, att := range vol.Attachments {
err := volumeattach.Delete(d.computeClient, att.ServerID, att.ID).ExtractErr()
err := volumeattach.Delete(ctx, d.computeClient, att.ServerID, att.ID).ExtractErr()
if err != nil {
return nil, err
}
Expand All @@ -404,7 +404,7 @@ func (d plugin) waitOnVolumeState(ctx context.Context, vol *volumes.Volume, stat
for i := 1; i <= 10; i++ {
time.Sleep(500 * time.Millisecond)

vol, err := volumes.Get(d.blockClient, vol.ID).Extract()
vol, err := volumes.Get(ctx, d.blockClient, vol.ID).Extract()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit d087a50

Please sign in to comment.