Skip to content

Commit

Permalink
Merge pull request cloudflare#98 from cloudflare/jamesog/97-updatedns…
Browse files Browse the repository at this point in the history
…record

Bugfix for UpdateDNSRecord
  • Loading branch information
jamesog authored Dec 21, 2016
2 parents 48f0a50 + d70046a commit 6cfcb7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/flarectl/flarectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ func dnsUpdate(c *cli.Context) {
}
zone := c.String("zone")
recordID := c.String("id")
name := c.String("name")
content := c.String("content")
ttl := c.Int("ttl")
proxy := c.Bool("proxy")
Expand All @@ -418,6 +419,7 @@ func dnsUpdate(c *cli.Context) {

record := cloudflare.DNSRecord{
ID: recordID,
Name: name,
Content: content,
TTL: ttl,
Proxied: proxy,
Expand Down Expand Up @@ -718,6 +720,10 @@ func main() {
Name: "id",
Usage: "record id",
},
cli.StringFlag{
Name: "name",
Usage: "record name",
},
cli.StringFlag{
Name: "content",
Usage: "record content",
Expand Down
6 changes: 5 additions & 1 deletion dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ func (api *API) UpdateDNSRecord(zoneID, recordID string, rr DNSRecord) error {
if err != nil {
return err
}
rr.Name = rec.Name
// Populate the record name from the existing one if the update didn't
// specify it.
if rr.Name == "" {
rr.Name = rec.Name
}
rr.Type = rec.Type
uri := "/zones/" + zoneID + "/dns_records/" + recordID
res, err := api.makeRequest("PUT", uri, rr)
Expand Down

0 comments on commit 6cfcb7e

Please sign in to comment.