Skip to content

Commit

Permalink
Merge pull request #219 - INBOX-2625 - Remove omitempty for filters
Browse files Browse the repository at this point in the history
  • Loading branch information
pburrows-ns1 authored Oct 5, 2023
2 parents 8e2e04b + 4980c75 commit b69b849
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.7.11 (October 5th, 2023)

BUG FIXES:

* Remove `omitempty` from filters to allow removal of filters

## 2.7.10 (September 29th, 2023)

FEATURES:
Expand Down
2 changes: 1 addition & 1 deletion rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

const (
clientVersion = "2.7.10"
clientVersion = "2.7.11"

defaultEndpoint = "https://api.nsone.net/v1/"
defaultShouldFollowPagination = true
Expand Down
2 changes: 1 addition & 1 deletion rest/model/dns/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Record struct {
// Answers must all be of the same type as the record.
Answers []*Answer `json:"answers"`
// The records' filter chain.
Filters []*filter.Filter `json:"filters,omitempty"`
Filters []*filter.Filter `json:"filters"`
// The records' regions.
Regions data.Regions `json:"regions,omitempty"`

Expand Down
16 changes: 8 additions & 8 deletions rest/model/dns/record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var marshalRecordCases = []struct {
"marshalCAARecord",
NewRecord("example.com", "caa.example.com", "CAA"),
[]*Answer{NewCAAAnswer(0, "issue", "letsencrypt.org")},
[]byte(`{"meta":{},"zone":"example.com","domain":"caa.example.com","type":"CAA","answers":[{"meta":{},"answer":["0","issue","letsencrypt.org"]}]}`),
[]byte(`{"meta":{},"zone":"example.com","domain":"caa.example.com","type":"CAA","answers":[{"meta":{},"answer":["0","issue","letsencrypt.org"]}],"filters":[]}`),
},
{
"marshalURLFWDRecord",
Expand All @@ -27,7 +27,7 @@ var marshalRecordCases = []struct {
NewURLFWDAnswer("/net", "https://example.net", 301, 1, 1),
NewURLFWDAnswer("/org", "https://example.org", 302, 2, 0),
},
[]byte(`{"answers":[{"answer":["/net","https://example.net",301,1,1],"meta":{}},{"answer":["/org","https://example.org",302,2,0],"meta":{}}],"meta":{},"zone":"example.com","domain":"fwd.example.com","type":"URLFWD"}`),
[]byte(`{"answers":[{"answer":["/net","https://example.net",301,1,1],"meta":{}},{"answer":["/org","https://example.org",302,2,0],"meta":{}}],"meta":{},"zone":"example.com","domain":"fwd.example.com","type":"URLFWD","filters":[]}`),
},
}

Expand Down Expand Up @@ -60,19 +60,19 @@ func TestMarshalRecordsOverrideTTL(t *testing.T) {
"marshalOverrideTTLNil",
NewRecord("example.com", "example.com", "ALIAS"),
nil,
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","answers":[]}`),
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","answers":[],"filters":[]}`),
},
{
"marshalOverrideTTLTrue",
NewRecord("example.com", "example.com", "ALIAS"),
&trueb,
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":true,"answers":[]}`),
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":true,"answers":[],"filters":[]}`),
},
{
"marshalOverrideTTLFalse",
NewRecord("example.com", "example.com", "ALIAS"),
&falseb,
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":false,"answers":[]}`),
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":false,"answers":[],"filters":[]}`),
},
}
for _, tt := range marshalALIASRecordCases {
Expand Down Expand Up @@ -104,21 +104,21 @@ func TestMarshalRecordsOverrideAddressRecords(t *testing.T) {
NewRecord("example.com", "example.com", "ALIAS"),
nil,
nil,
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","answers":[]}`),
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","answers":[],"filters":[]}`),
},
{
"marshalOverrideAddressRecordsTrue",
NewRecord("example.com", "example.com", "ALIAS"),
&trueb,
&trueb,
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":true,"override_address_records":true,"answers":[]}`),
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":true,"override_address_records":true,"answers":[],"filters":[]}`),
},
{
"marshalOverrideAddressRecordsFalse",
NewRecord("example.com", "example.com", "ALIAS"),
&falseb,
&falseb,
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":false,"override_address_records":false,"answers":[]}`),
[]byte(`{"meta":{},"zone":"example.com","domain":"example.com","type":"ALIAS","override_ttl":false,"override_address_records":false,"answers":[],"filters":[]}`),
},
}
for _, tt := range marshalALIASRecordCases {
Expand Down
5 changes: 0 additions & 5 deletions rest/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"

"gopkg.in/ns1/ns1-go.v2/rest/model/dns"
"gopkg.in/ns1/ns1-go.v2/rest/model/filter"
)

// RecordsService handles 'zones/ZONE/DOMAIN/TYPE' endpoint.
Expand Down Expand Up @@ -35,10 +34,6 @@ func (s *RecordsService) Get(zone, domain, t string) (*dns.Record, *http.Respons
return nil, resp, err
}

if r.Filters == nil {
r.Filters = make([]*filter.Filter, 0)
}

return &r, resp, nil
}

Expand Down

0 comments on commit b69b849

Please sign in to comment.