Skip to content

Commit

Permalink
Merge branch 'master' into release-v2.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ponbiki authored Oct 11, 2023
2 parents 0cc313c + 222d94c commit b2a4e81
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ ENHANCEMENTS
BUG FIX
* Updated test host names

## 2.0.8 (October 5, 2023)
BUG FIX

* `ns1-go` client version bump fixes removing filter chains from records

## 2.0.7 (September 19, 2023)
ENHANCEMENTS
* Added support for more record types (CERT, CSYNC, DHCID, HTTPS, SMIMEA, SVCB & TLSA)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/stretchr/testify v1.8.1
gopkg.in/ns1/ns1-go.v2 v2.7.12

)

require (
Expand Down
9 changes: 2 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJE
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
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/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
Expand All @@ -40,7 +38,6 @@ github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down Expand Up @@ -253,10 +250,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.7.8 h1:1ocy22Xb+KF4g6JNlPFoivyYRdJfeQjs+omb/wIzQAU=
gopkg.in/ns1/ns1-go.v2 v2.7.8/go.mod h1:pfaU0vECVP7DIOr453z03HXS6dFJpXdNRwOyRzwmPSc=
gopkg.in/ns1/ns1-go.v2 v2.7.9 h1:enj8dKPIoElOIv8cSzRHd5sTHsLgHapvOIKK8uLXK7c=
gopkg.in/ns1/ns1-go.v2 v2.7.9/go.mod h1:pfaU0vECVP7DIOr453z03HXS6dFJpXdNRwOyRzwmPSc=
gopkg.in/ns1/ns1-go.v2 v2.7.11 h1:fs8fkDjfdWdR2Gg//HO+LHrtC38+Z+xpUs3z4iojsn8=
gopkg.in/ns1/ns1-go.v2 v2.7.11/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=
Expand Down
2 changes: 1 addition & 1 deletion ns1/resource_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ func recordStateFunc(d *schema.ResourceData, meta interface{}) ([]*schema.Resour
return []*schema.ResourceData{d}, nil
}

// ignores case difference between state and resoruce written in terraform file
// ignores case difference between state and resource written in terraform file
// so we can keep data consistency between tf state and ddi since ddi is case insensitive
func caseSensitivityDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
return strings.EqualFold(old, new)
Expand Down
69 changes: 69 additions & 0 deletions ns1/resource_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,41 @@ func TestAccRecord_updated(t *testing.T) {
})
}

func TestAccRecord_remove_all_filters(t *testing.T) {
var record dns.Record
rString := acctest.RandStringFromCharSet(15, acctest.CharSetAlphaNum)
zoneName := fmt.Sprintf("terraform-test-%s.io", rString)
domainName := fmt.Sprintf("test.%s", zoneName)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRecordDestroy,
Steps: []resource.TestStep{
{
Config: testAccRecordBasic(rString),
Check: resource.ComposeTestCheckFunc(
testAccCheckRecordExists("ns1_record.it", &record),
testAccCheckRecordFilterCount(&record, 3),
),
},
{
Config: testAccRecordUpdatedNoFilters(rString),
Check: resource.ComposeTestCheckFunc(
testAccCheckRecordExists("ns1_record.it", &record),
testAccCheckRecordFilterCount(&record, 0),
),
},
{
ResourceName: "ns1_record.it",
ImportState: true,
ImportStateId: fmt.Sprintf("%s/%s/CNAME", zoneName, domainName),
ImportStateVerify: true,
},
},
})
}

func TestAccRecord_meta(t *testing.T) {
var record dns.Record
rString := acctest.RandStringFromCharSet(15, acctest.CharSetAlphaNum)
Expand Down Expand Up @@ -820,6 +855,16 @@ func testAccCheckRecordExists(n string, record *dns.Record) resource.TestCheckFu
}
}

func testAccCheckRecordFilterCount(r *dns.Record, expected int) resource.TestCheckFunc {
return func(s *terraform.State) error {
if len(r.Filters) != expected {
return fmt.Errorf("r.Filters, got: %d, want: %d", len(r.Filters), expected)
}

return nil
}
}

func testAccCheckRecordDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*ns1.Client)

Expand Down Expand Up @@ -1212,6 +1257,30 @@ resource "ns1_zone" "test" {
`, rString)
}

func testAccRecordUpdatedNoFilters(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}"
region = "cal"
}
regions {
name = "cal"
}
}
resource "ns1_zone" "test" {
zone = "terraform-test-%s.io"
}
`, rString)
}

func testAccRecordAnswerMeta(rString string) string {
return fmt.Sprintf(`
resource "ns1_record" "it" {
Expand Down

0 comments on commit b2a4e81

Please sign in to comment.