Repository: favonia/cloudflare-ddns (go)

Issue:
Use DNS record comments in a creative way
Maybe add `Created by cloudflare-ddns 😺` as the comment of newly created DNS records.

- [ ] cloudflare/cloudflare-go#1166

Announcement of the new API: https://developers.cloudflare.com/dns/manage-dns-records/reference/record-attributes/

Pull request description:
feat: annotate newly created DNS records
Close #354.

Patch:
diff --git a/internal/api/cloudflare.go b/internal/api/cloudflare.go
index 0b4e8c7..6617148 100644
--- a/internal/api/cloudflare.go
+++ b/internal/api/cloudflare.go
@@ -279,6 +279,7 @@ func (h *CloudflareHandle) CreateRecord(ctx context.Context, ppfmt pp.PP,
 		Content: ip.String(),
 		TTL:     ttl.Int(),
 		Proxied: &proxied,
+		Comment: "Created by cloudflare-ddns",
 	}
 
 	res, err := h.cf.CreateDNSRecord(ctx, cloudflare.ZoneIdentifier(zone), params)


Test patch:
diff --git a/internal/api/cloudflare_test.go b/internal/api/cloudflare_test.go
index 8a24a06..a91b8c2 100644
--- a/internal/api/cloudflare_test.go
+++ b/internal/api/cloudflare_test.go
@@ -1023,6 +1023,7 @@ func TestCreateRecordValid(t *testing.T) {
 				require.Equal(t, "::1", record.Content)
 				require.Equal(t, 100, record.TTL)
 				require.Equal(t, false, *record.Proxied)
+				require.Equal(t, "Created by cloudflare-ddns", record.Comment)
 				record.ID = "record1"
 
 				w.Header().Set("content-type", "application/json")