Skip to content

Commit

Permalink
update godo
Browse files Browse the repository at this point in the history
  • Loading branch information
loosla committed Nov 5, 2024
1 parent 8080ecc commit 10f0f9a
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 16 deletions.
12 changes: 6 additions & 6 deletions digitalocean/droplet/resource_droplet.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func resourceDigitalOceanDropletCreate(ctx context.Context, d *schema.ResourceDa
if !ok {
return diag.FromErr(errors.New("backup_policy hour is not an int"))
}
opts.BackupPolicy.Hour = hour
opts.BackupPolicy.Hour = &hour
}
}

Expand Down Expand Up @@ -653,22 +653,22 @@ func resourceDigitalOceanDropletUpdate(ctx context.Context, d *schema.ResourceDa
}

if d.HasChange("backup_policy") {
var newPolicy map[string]interface{}
var newPolicy godo.DropletBackupPolicyRequest
bp, ok := d.GetOk("backup_policy")
if ok && bp != nil { // backup_policy must be set.
_, new := d.GetChange("backup_policy")
if newList, ok := new.([]interface{}); ok && len(newList) != 0 {
newPolicy = new.([]interface{})[0].(map[string]interface{})
newPolicy = new.([]interface{})[0].(godo.DropletBackupPolicyRequest)
}

action, _, err := client.DropletActions.EnableBackupsWithPolicy(context.Background(), id, newPolicy)
action, _, err := client.DropletActions.ChangeBackupPolicy(context.Background(), id, &newPolicy)
if err != nil {
return diag.Errorf(
"Error enabling backups with policy on droplet (%s): %s", d.Id(), err)
"Error changing backup policy on droplet (%s): %s", d.Id(), err)
}

if err := util.WaitForAction(client, action); err != nil {
return diag.Errorf("Error waiting for backups to be enabled with policy for droplet (%s): %s", d.Id(), err)
return diag.Errorf("Error waiting for backup policy to be changed for droplet (%s): %s", d.Id(), err)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions digitalocean/droplet/resource_droplet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func TestAccDigitalOceanDroplet_ChangeBackupPolicy(t *testing.T) {
CheckDestroy: acceptance.TestAccCheckDigitalOceanDropletDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckDigitalOceanDropletConfig_EnableBackupsWithPolicy(name),
Config: testAccCheckDigitalOceanDropletConfig_ChangeBackupPolicy(name),
Check: resource.ComposeTestCheckFunc(
acceptance.TestAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -1053,7 +1053,7 @@ resource "digitalocean_droplet" "foobar" {
}`, name, defaultSize, defaultImage)
}

func testAccCheckDigitalOceanDropletConfig_EnableBackupsWithPolicy(name string) string {
func testAccCheckDigitalOceanDropletConfig_ChangeBackupPolicy(name string) string {
return fmt.Sprintf(`
resource "digitalocean_droplet" "foobar" {
name = "%s"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/digitalocean/terraform-provider-digitalocean

require (
github.com/aws/aws-sdk-go v1.42.18
github.com/digitalocean/godo v1.128.1-0.20241101193706-e886602c9e0c
github.com/digitalocean/godo v1.128.1-0.20241105142035-a379869c286c
github.com/hashicorp/awspolicyequivalence v1.5.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-uuid v1.0.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/digitalocean/godo v1.128.1-0.20241101193706-e886602c9e0c h1:701F+MG+3bwyBCEez9q8OKpgQ9fmkOVPrXTRIoI/MZI=
github.com/digitalocean/godo v1.128.1-0.20241101193706-e886602c9e0c/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc=
github.com/digitalocean/godo v1.128.1-0.20241105142035-a379869c286c h1:Z1Osn3VmAR5FtPgrdi2VTxa069CnKc/DCXX1U2qpNpM=
github.com/digitalocean/godo v1.128.1-0.20241105142035-a379869c286c/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
Expand Down
37 changes: 34 additions & 3 deletions vendor/github.com/digitalocean/godo/droplet_actions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/digitalocean/godo/droplets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ github.com/aws/aws-sdk-go/service/sts/stsiface
# github.com/davecgh/go-spew v1.1.1
## explicit
github.com/davecgh/go-spew/spew
# github.com/digitalocean/godo v1.128.1-0.20241101193706-e886602c9e0c
# github.com/digitalocean/godo v1.128.1-0.20241105142035-a379869c286c
## explicit; go 1.22
github.com/digitalocean/godo
github.com/digitalocean/godo/metrics
Expand Down

0 comments on commit 10f0f9a

Please sign in to comment.