Skip to content

Commit

Permalink
Merge pull request cloudflare#595 from jacobbednarz/proxied-to-bool-ptr
Browse files Browse the repository at this point in the history
dns: `Proxied` to become a boolean pointer
  • Loading branch information
jacobbednarz authored Feb 22, 2021
2 parents 2d3f6cd + b619356 commit d346eb5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions cmd/flarectl/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func formatDNSRecord(record cloudflare.DNSRecord) []string {
record.Content,
strconv.FormatInt(int64(record.TTL), 10),
strconv.FormatBool(record.Proxiable),
strconv.FormatBool(record.Proxied),
strconv.FormatBool(*record.Proxied),
strconv.FormatBool(record.Locked),
}
}
Expand All @@ -46,7 +46,7 @@ func dnsCreate(c *cli.Context) error {
Type: strings.ToUpper(rtype),
Content: content,
TTL: ttl,
Proxied: proxy,
Proxied: &proxy,
}
resp, err := api.CreateDNSRecord(context.TODO(), zoneID, record)
if err != nil {
Expand Down Expand Up @@ -102,7 +102,8 @@ func dnsCreateOrUpdate(c *cli.Context) error {
rr.Type = r.Type
rr.Content = content
rr.TTL = ttl
rr.Proxied = proxy
rr.Proxied = &proxy

err := api.UpdateDNSRecord(context.TODO(), zoneID, r.ID, rr)
if err != nil {
fmt.Println("Error updating DNS record:", err)
Expand All @@ -118,7 +119,7 @@ func dnsCreateOrUpdate(c *cli.Context) error {
rr.Type = rtype
rr.Content = content
rr.TTL = ttl
rr.Proxied = proxy
rr.Proxied = &proxy
// TODO: Print the response.
resp, err = api.CreateDNSRecord(context.TODO(), zoneID, rr)
if err != nil {
Expand Down Expand Up @@ -162,7 +163,7 @@ func dnsUpdate(c *cli.Context) error {
Type: strings.ToUpper(rtype),
Content: content,
TTL: ttl,
Proxied: proxy,
Proxied: &proxy,
}
err = api.UpdateDNSRecord(context.TODO(), zoneID, recordID, record)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cmd/flarectl/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"strconv"
"strings"

cloudflare "github.com/cloudflare/cloudflare-go"
Expand Down Expand Up @@ -317,7 +318,7 @@ func zoneRecords(c *cli.Context) error {
r.Type,
r.Name,
r.Content,
fmt.Sprintf("%t", r.Proxied),
fmt.Sprintf("%s", strconv.FormatBool(*r.Proxied)),
fmt.Sprintf("%d", r.TTL),
})
}
Expand Down
2 changes: 1 addition & 1 deletion dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type DNSRecord struct {
Name string `json:"name,omitempty"`
Content string `json:"content,omitempty"`
Proxiable bool `json:"proxiable,omitempty"`
Proxied bool `json:"proxied,omitempty"`
Proxied *bool `json:"proxied,omitempty"`
TTL int `json:"ttl,omitempty"`
Locked bool `json:"locked,omitempty"`
ZoneID string `json:"zone_id,omitempty"`
Expand Down

0 comments on commit d346eb5

Please sign in to comment.