From 78fc38c072fa9d8382a27d333c2f33841df5c4cd Mon Sep 17 00:00:00 2001 From: Ferdinando Formica Date: Thu, 17 Oct 2024 10:45:38 +0100 Subject: [PATCH] Fix answer groups not wiped out --- CHANGELOG.md | 4 ++++ go.mod | 2 +- go.sum | 4 ++-- ns1/config.go | 2 +- ns1/resource_record_test.go | 45 +++++++++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab73db57..b0784792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.4.5 (October 17, 2024) +BUGFIX +* `ns1-go` client version bump to allow wiping out record regions + ## 2.4.4 (October 10, 2024) BUGFIX * Adds support for setting override_address_records for ALIAS records diff --git a/go.mod b/go.mod index 26988204..41856e92 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.7 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 github.com/stretchr/testify v1.8.1 - gopkg.in/ns1/ns1-go.v2 v2.12.0 + gopkg.in/ns1/ns1-go.v2 v2.12.2 ) require ( diff --git a/go.sum b/go.sum index d47e7df7..03026863 100644 --- a/go.sum +++ b/go.sum @@ -251,8 +251,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/ns1/ns1-go.v2 v2.12.0 h1:cqdqQoTx17JmTusfxh5m3e2b36jfUzFAZedv89pFX18= -gopkg.in/ns1/ns1-go.v2 v2.12.0/go.mod h1:pfaU0vECVP7DIOr453z03HXS6dFJpXdNRwOyRzwmPSc= +gopkg.in/ns1/ns1-go.v2 v2.12.2 h1:SPM5BTTMJ1zVBhMMiiPFdF7l6Y3fq5o7bKM7jDqsUfM= +gopkg.in/ns1/ns1-go.v2 v2.12.2/go.mod h1:pfaU0vECVP7DIOr453z03HXS6dFJpXdNRwOyRzwmPSc= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/ns1/config.go b/ns1/config.go index 03b85db8..2e4bd2e8 100644 --- a/ns1/config.go +++ b/ns1/config.go @@ -19,7 +19,7 @@ import ( ) var ( - clientVersion = "2.4.4" + clientVersion = "2.4.5" providerUserAgent = "tf-ns1" + "/" + clientVersion defaultRetryMax = 3 ) diff --git a/ns1/resource_record_test.go b/ns1/resource_record_test.go index b1eb329a..866d9cdc 100644 --- a/ns1/resource_record_test.go +++ b/ns1/resource_record_test.go @@ -565,6 +565,19 @@ func TestAccRecord_updatedWithRegions(t *testing.T) { ), ), }, + { + Config: testAccRecordUpdatedWithNoRegions(rString), + Check: resource.ComposeTestCheckFunc( + testAccCheckRecordExists("ns1_record.it", &record), + testAccCheckRecordDomain(&record, domainName), + testAccCheckRecordTTL(&record, 60), + testAccCheckRecordUseClientSubnet(&record, true), + testAccCheckRecordRegionName(&record, []string{}), + testAccCheckRecordAnswerRdata( + t, &record, 0, []string{fmt.Sprintf("test1.%s", zoneName)}, + ), + ), + }, { ResourceName: "ns1_record.it", ImportState: true, @@ -1961,6 +1974,38 @@ resource "ns1_zone" "test" { `, rString) } +func testAccRecordUpdatedWithNoRegions(rString string) string { + return fmt.Sprintf(` + resource "ns1_record" "it" { + zone = "${ns1_zone.test.zone}" + domain = "test.${ns1_zone.test.zone}" + type = "CNAME" + ttl = 60 + + answers { + answer = "test1.${ns1_zone.test.zone}" + } + + filters { + filter = "geotarget_country" + } + + filters { + filter = "select_first_n" + config = {N=1} + } + + filters { + filter = "up" + } + } + + resource "ns1_zone" "test" { + zone = "terraform-test-%s.io" + } + `, rString) +} + // zone and domain have leading and trailing dots and should fail validation. func testAccRecordInvalid(rString string) string { return fmt.Sprintf(`