diff --git a/providers/cloudns/cloudnsProvider.go b/providers/cloudns/cloudnsProvider.go index fd8c273156..920c3a725d 100644 --- a/providers/cloudns/cloudnsProvider.go +++ b/providers/cloudns/cloudnsProvider.go @@ -406,7 +406,7 @@ func toRc(domain string, r *domainRecord) (*models.RecordConfig, error) { rc.DsDigest = r.Target err = rc.SetTarget(r.Target) case "CLOUD_WR": - rc.Type = "WR" + rc.Type = "CLOUDNS_WR" err = rc.SetTarget(r.Target) case "LOC": loc := fmt.Sprintf("%s %s %s %s %s %s %s %s %s %s %s %s", @@ -459,7 +459,7 @@ func toReq(rc *models.RecordConfig) (requestParams, error) { } switch rc.Type { // #rtype_variations - case "A", "AAAA", "NS", "PTR", "TXT", "SOA", "ALIAS", "CNAME", "WR", "DNAME": + case "A", "AAAA", "NS", "PTR", "TXT", "SOA", "ALIAS", "CNAME", "DNAME": // Nothing special. case "CLOUDNS_WR": req["record-type"] = "WR" diff --git a/providers/cloudns/cloudnsProvider_test.go b/providers/cloudns/cloudnsProvider_test.go new file mode 100644 index 0000000000..af7e6179f7 --- /dev/null +++ b/providers/cloudns/cloudnsProvider_test.go @@ -0,0 +1,27 @@ +package cloudns + +import ( + "testing" +) + +func TestToRcConvertsCloudWRToCloudnsWR(t *testing.T) { + // ClouDNS API returns "CLOUD_WR" as the type for web redirect records. + // dnscontrol uses "CLOUDNS_WR" as the custom record type. + // Verify that toRc maps "CLOUD_WR" -> "CLOUDNS_WR" so that fetched + // records match desired records and are not destroyed/recreated every push. + r := &domainRecord{ + ID: "123", + Type: "CLOUD_WR", + Host: "www", + Target: "https://example.com", + TTL: "3600", + } + + rc, err := toRc("example.com", r) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if rc.Type != "CLOUDNS_WR" { + t.Errorf("expected type CLOUDNS_WR, got %s", rc.Type) + } +}