Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update govultr to v3.0.2 #228

Merged
merged 4 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion builder/vultr/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

registryimage "github.com/hashicorp/packer-plugin-sdk/packer/registry/image"

"github.com/vultr/govultr/v2"
"github.com/vultr/govultr/v3"
)

type Artifact struct {
Expand Down
2 changes: 1 addition & 1 deletion builder/vultr/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps"
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/vultr/govultr/v2"
"github.com/vultr/govultr/v3"
)

// BuilderID is the unique ID for the builder
Expand Down
6 changes: 3 additions & 3 deletions builder/vultr/step_create_iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/vultr/govultr/v2"
"github.com/vultr/govultr/v3"
)

type stepCreateISO struct {
Expand All @@ -26,7 +26,7 @@ func (s *stepCreateISO) Run(ctx context.Context, state multistep.StateBag) multi
URL: c.ISOURL,
}

iso, err := s.client.ISO.Create(ctx, isoReq)
iso, _, err := s.client.ISO.Create(ctx, isoReq)
if err != nil {
err = errors.New("Error creating ISO: " + err.Error())
state.Put("error", err)
Expand All @@ -46,7 +46,7 @@ func (s *stepCreateISO) Run(ctx context.Context, state multistep.StateBag) multi
return multistep.ActionHalt
}

if _, err = s.client.ISO.Get(context.Background(), iso.ID); err != nil {
if _, _, err = s.client.ISO.Get(context.Background(), iso.ID); err != nil {
err := fmt.Errorf("error getting ISO: %s", err)
state.Put("error", err)
ui.Error(err.Error())
Expand Down
16 changes: 8 additions & 8 deletions builder/vultr/step_create_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/vultr/govultr/v2"
"github.com/vultr/govultr/v3"
)

type stepCreateServer struct {
Expand Down Expand Up @@ -53,7 +53,7 @@ func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu
Tag: c.Tag,
}

instance, err := s.client.Instance.Create(ctx, instanceReq)
instance, _, err := s.client.Instance.Create(ctx, instanceReq)
if err != nil {
err = errors.New("Error creating server: " + err.Error())
state.Put("error", err)
Expand All @@ -73,7 +73,7 @@ func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu
return multistep.ActionHalt
}

if instance, err = s.client.Instance.Get(context.Background(), instance.ID); err != nil {
if instance, _, err = s.client.Instance.Get(context.Background(), instance.ID); err != nil {
err := fmt.Errorf("error getting server: %s", err)
state.Put("error", err)
ui.Error(err.Error())
Expand All @@ -97,14 +97,14 @@ func (s *stepCreateServer) Cleanup(state multistep.StateBag) {

// If an ISO was uploaded as part of this build, detach from the instance before destroying
if iso, ok := state.GetOk("iso"); ok {
iso_status, iso_status_err := s.client.Instance.ISOStatus(context.Background(), instance.ID)
if iso_status_err != nil {
state.Put("error", iso_status_err)
iso_status, _, err := s.client.Instance.ISOStatus(context.Background(), instance.ID)
if err != nil {
state.Put("error", err)
}

if iso_status.State == "isomounted" && iso_status.IsoID == iso.(*govultr.ISO).ID {
if detach_err := s.client.Instance.DetachISO(context.Background(), instance.ID); detach_err != nil {
state.Put("error", detach_err)
if _, err := s.client.Instance.DetachISO(context.Background(), instance.ID); err != nil {
state.Put("error", err)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions builder/vultr/step_create_ssh_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer-plugin-sdk/uuid"
"github.com/vultr/govultr/v2"
"github.com/vultr/govultr/v3"
"golang.org/x/crypto/ssh"
)

Expand Down Expand Up @@ -66,7 +66,7 @@ func (s *stepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) mult
Name: name,
SSHKey: string(config.Comm.SSHPublicKey),
}
key, err := s.client.SSHKey.Create(context.Background(), sshKeyReq)
key, _, err := s.client.SSHKey.Create(context.Background(), sshKeyReq)
if err != nil {
err := fmt.Errorf("error creating temporary SSH key: %s", err)
state.Put("error", err)
Expand Down
2 changes: 1 addition & 1 deletion builder/vultr/step_shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/vultr/govultr/v2"
"github.com/vultr/govultr/v3"
)

// shutdown delays
Expand Down
4 changes: 2 additions & 2 deletions builder/vultr/step_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/vultr/govultr/v2"
"github.com/vultr/govultr/v3"
)

type stepCreateSnapshot struct {
Expand All @@ -29,7 +29,7 @@ func (s *stepCreateSnapshot) Run(ctx context.Context, state multistep.StateBag)
InstanceID: instance.ID,
Description: c.Description,
}
snapshot, err := s.client.Snapshot.Create(ctx, snapshotReq)
snapshot, _, err := s.client.Snapshot.Create(ctx, snapshotReq)
if err != nil {
err := fmt.Errorf("error creating snapshot: %s", err)
state.Put("error", err)
Expand Down
4 changes: 2 additions & 2 deletions builder/vultr/vultr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/hashicorp/packer-plugin-sdk/version"
"github.com/vultr/govultr/v2"
"github.com/vultr/govultr/v3"
"golang.org/x/oauth2"
)

Expand All @@ -16,7 +16,7 @@ func newVultrClient(apiKey string) *govultr.Client {
ts := config.TokenSource(ctx, &oauth2.Token{AccessToken: apiKey})

client := govultr.NewClient(oauth2.NewClient(ctx, ts))
userAgent := fmt.Sprintf("Packer/%s/govultr-v2", version.SDKVersion)
userAgent := fmt.Sprintf("Packer/%s/govultr-v3", version.SDKVersion)
client.SetUserAgent(userAgent)
return client
}
8 changes: 4 additions & 4 deletions builder/vultr/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"time"

"github.com/vultr/govultr/v2"
"github.com/vultr/govultr/v3"
)

func waitForISOState(state string, isoID string, client *govultr.Client, timeout time.Duration) error {
Expand All @@ -19,7 +19,7 @@ func waitForISOState(state string, isoID string, client *govultr.Client, timeout
attempts++
log.Printf("Checking ISO status... (attempt: %d)", attempts)

iso, err := client.ISO.Get(context.Background(), isoID)
iso, _, err := client.ISO.Get(context.Background(), isoID)
if err != nil {
result <- err
return
Expand Down Expand Up @@ -59,7 +59,7 @@ func waitForServerState(state string, power string, serverID string, client *gov
for {
attempts++
log.Printf("Checking server status... (attempt: %d)", attempts)
serverInfo, err := client.Instance.Get(context.Background(), serverID)
serverInfo, _, err := client.Instance.Get(context.Background(), serverID)
if err != nil {
result <- err
return
Expand Down Expand Up @@ -100,7 +100,7 @@ func waitForSnapshotState(state string, snapshotID string, client *govultr.Clien
attempts++
log.Printf("Checking snapshot status... (attempt: %d)", attempts)

snapshot, err := client.Snapshot.Get(context.Background(), snapshotID)
snapshot, _, err := client.Snapshot.Get(context.Background(), snapshotID)
if err != nil {
result <- err
return
Expand Down
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.20
require (
github.com/hashicorp/hcl/v2 v2.14.0
github.com/hashicorp/packer-plugin-sdk v0.4.0
github.com/vultr/govultr/v2 v2.17.2
github.com/vultr/govultr/v3 v3.0.2
github.com/zclconf/go-cty v1.10.0
golang.org/x/crypto v0.7.0
golang.org/x/oauth2 v0.6.0
Expand Down Expand Up @@ -45,7 +45,7 @@ require (
github.com/hashicorp/go-hclog v0.16.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
github.com/hashicorp/go-retryablehttp v0.6.2/go.mod h1:gEx6HMUGxYYhJScX7W1Il64m6cc2C1mDaW3NQ9sY1FY=
github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ=
github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0=
github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
Expand Down Expand Up @@ -407,8 +407,8 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o
github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/vultr/govultr/v2 v2.17.2 h1:gej/rwr91Puc/tgh+j33p/BLR16UrIPnSr+AIwYWZQs=
github.com/vultr/govultr/v2 v2.17.2/go.mod h1:ZFOKGWmgjytfyjeyAdhQlSWwTjh2ig+X49cAp50dzXI=
github.com/vultr/govultr/v3 v3.0.2 h1:rrYiuF9adB3rjnhp0ev+mkJXKEzuYa/AGfezYPr3EMs=
github.com/vultr/govultr/v3 v3.0.2/go.mod h1:Pd3D6VKmQKyKWsdV1xLx4VKclEV23adMs3YoI7rh7gA=
github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0=
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
Expand Down
Loading