1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

CLOUDFLARE: Use cloudflare-go (#1267)

* First pass at moving to cloudflare-go vs hand made implementation of cloudflare's API

* Final changes to use cloudflare-go

* Fix for proxy configuration failing

Forgot to set the ID when we created a new records.  This didn't fail in the integrations tests so I missed it.

* Add integration test

To prevent something like what I did from happening in the future.

* Fix bad messaging
This commit is contained in:
Brian Hartvigsen
2021-09-30 05:09:42 -06:00
committed by GitHub
parent 414f57274d
commit d8941a04bc
5 changed files with 121 additions and 390 deletions

View File

@ -385,6 +385,20 @@ func cfRedirTemp(pattern, target string) *models.RecordConfig {
return r
}
func cfProxyA(name, target, status string) *models.RecordConfig {
r := a(name, target)
r.Metadata = make(map[string]string)
r.Metadata["cloudflare_proxy"] = status
return r
}
func cfProxyCNAME(name, target, status string) *models.RecordConfig {
r := cname(name, target)
r.Metadata = make(map[string]string)
r.Metadata["cloudflare_proxy"] = status
return r
}
func ns(name, target string) *models.RecordConfig {
return makeRec(name, target, "NS")
}
@ -1359,6 +1373,17 @@ func makeTests(t *testing.T) []*TestGroup {
// cfRedirTemp("nytimes.**current-domain-no-trailing**/*", "https://www.nytimes.com/$1"),
//),
),
testgroup("CF_PROXY",
only("CLOUDFLAREAPI"),
tc("proxyon", cfProxyA("proxyme", "1.2.3.4", "on")),
tc("proxychangetarget", cfProxyA("proxyme", "1.2.3.5", "on")),
tc("proxychangeproxy", cfProxyA("proxyme", "1.2.3.5", "off")),
clear(),
tc("proxycname", cfProxyCNAME("anewproxy", "example.com.", "on")),
tc("proxycnamechange", cfProxyCNAME("anewproxy", "example.com.", "off")),
clear(),
),
}
return tests