diff --git a/digitalocean/reservedipv6/resource_reserved_ipv6_assignment.go b/digitalocean/reservedipv6/resource_reserved_ipv6_assignment.go index f5fb427dd..49423033b 100644 --- a/digitalocean/reservedipv6/resource_reserved_ipv6_assignment.go +++ b/digitalocean/reservedipv6/resource_reserved_ipv6_assignment.go @@ -65,6 +65,7 @@ func resourceDigitalOceanReservedIPV6AssignmentCreate(ctx context.Context, d *sc d.SetId(id.PrefixedUniqueId(fmt.Sprintf("%d-%s-", dropletID, ipAddress))) return resourceDigitalOceanReservedIPV6AssignmentRead(ctx, d, meta) + } func resourceDigitalOceanReservedIPV6AssignmentRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/digitalocean/reservedipv6/resource_reserved_ipv6_assignment_test.go b/digitalocean/reservedipv6/resource_reserved_ipv6_assignment_test.go index 29fd6a3a4..71d80bcbb 100644 --- a/digitalocean/reservedipv6/resource_reserved_ipv6_assignment_test.go +++ b/digitalocean/reservedipv6/resource_reserved_ipv6_assignment_test.go @@ -75,6 +75,39 @@ func TestAccDigitalOceanReservedIPV6Assignment_createBeforeDestroy(t *testing.T) }) } +func TestAccDigitalOceanReservedIPV6Assignment_unassignAndAssignToNewDroplet(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.TestAccPreCheck(t) }, + ProviderFactories: acceptance.TestAccProviderFactories, + CheckDestroy: testAccCheckDigitalOceanReservedIPV6Destroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckDigitalOceanReservedIPV6AssignmentConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckDigitalOceanReservedIPV6AttachmentExists("digitalocean_reserved_ipv6_assignment.foobar"), + resource.TestMatchResourceAttr( + "digitalocean_reserved_ipv6_assignment.foobar", "ip", regexp.MustCompile(ipv6Regex)), + resource.TestMatchResourceAttr( + "digitalocean_reserved_ipv6_assignment.foobar", "droplet_id", regexp.MustCompile("[0-9]+")), + ), + }, + { + Config: testAccCheckDigitalOceanReservedIPV6AssignmentUnAssign, + }, + { + Config: testAccCheckDigitalOceanReservedIPV6ReAssignmentConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckDigitalOceanReservedIPV6AttachmentExists("digitalocean_reserved_ipv6_assignment.foobar"), + resource.TestMatchResourceAttr( + "digitalocean_reserved_ipv6_assignment.foobar", "ip", regexp.MustCompile(ipv6Regex)), + resource.TestMatchResourceAttr( + "digitalocean_reserved_ipv6_assignment.foobar", "droplet_id", regexp.MustCompile("[0-9]+")), + ), + }, + }, + }) +} + func testAccCheckDigitalOceanReservedIPV6AttachmentExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -114,7 +147,7 @@ resource "digitalocean_reserved_ipv6" "foobar" { resource "digitalocean_droplet" "foobar" { count = 1 - name = "tf-acc-test-${count.index}" + name = "tf-acc-test-assign" size = "s-1vcpu-1gb" image = "ubuntu-22-04-x64" region = "nyc3" @@ -127,6 +160,50 @@ resource "digitalocean_reserved_ipv6_assignment" "foobar" { } ` +var testAccCheckDigitalOceanReservedIPV6AssignmentUnAssign = ` +resource "digitalocean_reserved_ipv6" "foobar" { + region_slug = "nyc3" +} + +resource "digitalocean_droplet" "foobar" { + count = 1 + image = "ubuntu-22-04-x64" + name = "tf-acc-test-assign" + region = "nyc3" + size = "s-1vcpu-1gb" + ipv6 = true +} + +` + +var testAccCheckDigitalOceanReservedIPV6ReAssignmentConfig = ` +resource "digitalocean_reserved_ipv6" "foobar" { + region_slug = "nyc3" +} + +resource "digitalocean_droplet" "foobar1" { + count = 1 + name = "tf-acc-test-reassign" + size = "s-1vcpu-1gb" + image = "ubuntu-22-04-x64" + region = "nyc3" + ipv6 = true +} +resource "digitalocean_droplet" "foobar" { + count = 1 + name = "tf-acc-test-assign" + size = "s-1vcpu-1gb" + image = "ubuntu-22-04-x64" + region = "nyc3" + ipv6 = true +} + +resource "digitalocean_reserved_ipv6_assignment" "foobar" { + ip = digitalocean_reserved_ipv6.foobar.ip + droplet_id = digitalocean_droplet.foobar1.0.id +} +` + var testAccCheckDigitalOceanReservedIPV6AssignmentDeleteAssignment = ` resource "digitalocean_reserved_ipv6" "foobar" { region_slug = "nyc3" @@ -139,7 +216,6 @@ resource "digitalocean_droplet" "foobar" { image = "ubuntu-22-04-x64" region = "nyc3" ipv6 = true - private_networking = true } ` diff --git a/go.mod b/go.mod index 2a2151d16..1f0a5e244 100644 --- a/go.mod +++ b/go.mod @@ -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.131.1-0.20241127211050-a97e39731918 + github.com/digitalocean/godo v1.131.1 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 diff --git a/go.sum b/go.sum index c7d6398bd..6fa43ba64 100644 --- a/go.sum +++ b/go.sum @@ -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.131.1-0.20241127211050-a97e39731918 h1:7xOw7i5AFH1n5vIMMH7HtR87jdxV8XnLKOBafNbVetM= -github.com/digitalocean/godo v1.131.1-0.20241127211050-a97e39731918/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc= +github.com/digitalocean/godo v1.131.1 h1:2QsRwjNukKgOQbflMxOsTDoC05o5UKBpqQMFKXegYKE= +github.com/digitalocean/godo v1.131.1/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= diff --git a/vendor/github.com/digitalocean/godo/CHANGELOG.md b/vendor/github.com/digitalocean/godo/CHANGELOG.md index 3fb2a160c..8b177989d 100644 --- a/vendor/github.com/digitalocean/godo/CHANGELOG.md +++ b/vendor/github.com/digitalocean/godo/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## [v1.131.1] - 2024-12-10 +- #762 - @imaskm - Updated list ipv6 response + ## [v1.131.0] - 2024-11-25 - #760 - @jvasilevsky - LBAAS: add ipv6 field to loadbalancer model diff --git a/vendor/github.com/digitalocean/godo/godo.go b/vendor/github.com/digitalocean/godo/godo.go index 62498fc44..94d31631a 100644 --- a/vendor/github.com/digitalocean/godo/godo.go +++ b/vendor/github.com/digitalocean/godo/godo.go @@ -21,7 +21,7 @@ import ( ) const ( - libraryVersion = "1.131.0" + libraryVersion = "1.131.1" defaultBaseURL = "https://api.digitalocean.com/" userAgent = "godo/" + libraryVersion mediaType = "application/json" diff --git a/vendor/github.com/digitalocean/godo/reserved_ipv6.go b/vendor/github.com/digitalocean/godo/reserved_ipv6.go index ff6e8cfaa..119c6bde3 100644 --- a/vendor/github.com/digitalocean/godo/reserved_ipv6.go +++ b/vendor/github.com/digitalocean/godo/reserved_ipv6.go @@ -34,7 +34,6 @@ type ReservedIPV6 struct { ReservedAt time.Time `json:"reserved_at"` Droplet *Droplet `json:"droplet,omitempty"` } - type reservedIPV6Root struct { ReservedIPV6 *ReservedIPV6 `json:"reserved_ipv6"` } @@ -77,8 +76,7 @@ func (r *ReservedIPV6sServiceOp) List(ctx context.Context, opt *ListOptions) ([] if err != nil { return nil, nil, err } - - if root.Meta != nil { + if root.Meta != nil { resp.Meta = root.Meta } if root.Links != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 1a2d97ae0..13fa4e7be 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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.131.1-0.20241127211050-a97e39731918 +# github.com/digitalocean/godo v1.131.1 ## explicit; go 1.22 github.com/digitalocean/godo github.com/digitalocean/godo/metrics