Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions providers/cloudns/cloudnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
27 changes: 27 additions & 0 deletions providers/cloudns/cloudnsProvider_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}