Skip to content

Commit

Permalink
fix!: use pointer type for all DNS record comments
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Jan 6, 2023
1 parent 61eed94 commit f2c7416
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
68 changes: 34 additions & 34 deletions dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ func (c DNSRecordComment) MarshalJSON() ([]byte, error) {

// DNSRecord represents a DNS record in a zone.
type DNSRecord struct {
CreatedOn time.Time `json:"created_on,omitempty"`
ModifiedOn time.Time `json:"modified_on,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Content string `json:"content,omitempty"`
Meta interface{} `json:"meta,omitempty"`
Data interface{} `json:"data,omitempty"` // data returned by: SRV, LOC
ID string `json:"id,omitempty"`
ZoneID string `json:"zone_id,omitempty"`
ZoneName string `json:"zone_name,omitempty"`
Priority *uint16 `json:"priority,omitempty"`
TTL int `json:"ttl,omitempty"`
Proxied *bool `json:"proxied,omitempty"`
Proxiable bool `json:"proxiable,omitempty"`
Locked bool `json:"locked,omitempty"`
Comment DNSRecordComment `json:"comment,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedOn time.Time `json:"created_on,omitempty"`
ModifiedOn time.Time `json:"modified_on,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Content string `json:"content,omitempty"`
Meta interface{} `json:"meta,omitempty"`
Data interface{} `json:"data,omitempty"` // data returned by: SRV, LOC
ID string `json:"id,omitempty"`
ZoneID string `json:"zone_id,omitempty"`
ZoneName string `json:"zone_name,omitempty"`
Priority *uint16 `json:"priority,omitempty"`
TTL int `json:"ttl,omitempty"`
Proxied *bool `json:"proxied,omitempty"`
Proxiable bool `json:"proxiable,omitempty"`
Locked bool `json:"locked,omitempty"`
Comment *DNSRecordComment `json:"comment,omitempty"`
Tags []string `json:"tags,omitempty"`
}

// DNSRecordResponse represents the response from the DNS endpoint.
Expand Down Expand Up @@ -138,23 +138,23 @@ func toUTS46ASCII(name string) string {
}

type CreateDNSRecordParams struct {
CreatedOn time.Time `json:"created_on,omitempty" url:"created_on,omitempty"`
ModifiedOn time.Time `json:"modified_on,omitempty" url:"modified_on,omitempty"`
Type string `json:"type,omitempty" url:"type,omitempty"`
Name string `json:"name,omitempty" url:"name,omitempty"`
Content string `json:"content,omitempty" url:"content,omitempty"`
Meta interface{} `json:"meta,omitempty"`
Data interface{} `json:"data,omitempty"` // data returned by: SRV, LOC
ID string `json:"id,omitempty"`
ZoneID string `json:"zone_id,omitempty"`
ZoneName string `json:"zone_name,omitempty"`
Priority *uint16 `json:"priority,omitempty"`
TTL int `json:"ttl,omitempty"`
Proxied *bool `json:"proxied,omitempty" url:"proxied,omitempty"`
Proxiable bool `json:"proxiable,omitempty"`
Locked bool `json:"locked,omitempty"`
Comment DNSRecordComment `json:"comment,omitempty" url:"comment,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedOn time.Time `json:"created_on,omitempty" url:"created_on,omitempty"`
ModifiedOn time.Time `json:"modified_on,omitempty" url:"modified_on,omitempty"`
Type string `json:"type,omitempty" url:"type,omitempty"`
Name string `json:"name,omitempty" url:"name,omitempty"`
Content string `json:"content,omitempty" url:"content,omitempty"`
Meta interface{} `json:"meta,omitempty"`
Data interface{} `json:"data,omitempty"` // data returned by: SRV, LOC
ID string `json:"id,omitempty"`
ZoneID string `json:"zone_id,omitempty"`
ZoneName string `json:"zone_name,omitempty"`
Priority *uint16 `json:"priority,omitempty"`
TTL int `json:"ttl,omitempty"`
Proxied *bool `json:"proxied,omitempty" url:"proxied,omitempty"`
Proxiable bool `json:"proxiable,omitempty"`
Locked bool `json:"locked,omitempty"`
Comment *DNSRecordComment `json:"comment,omitempty" url:"comment,omitempty"`
Tags []string `json:"tags,omitempty"`
}

// CreateDNSRecord creates a DNS record for the zone identifier.
Expand Down
3 changes: 2 additions & 1 deletion dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ func TestDNSRecord(t *testing.T) {
mux.HandleFunc("/zones/"+testZoneID+"/dns_records/"+dnsRecordID, handler)

proxied := false
comment := DNSRecordComment("This is a comment")
createdOn, _ := time.Parse(time.RFC3339, "2014-01-01T05:20:00Z")
modifiedOn, _ := time.Parse(time.RFC3339, "2014-01-01T05:20:00Z")
want := DNSRecord{
Expand All @@ -401,7 +402,7 @@ func TestDNSRecord(t *testing.T) {
"auto_added": true,
"source": "primary",
},
Comment: "This is a comment",
Comment: &comment,
Tags: []string{"tag1", "tag2"},
}

Expand Down

0 comments on commit f2c7416

Please sign in to comment.