plugin/clouddns: add refresh directive (#8616)

Brings clouddns to parity with route53, which already exposes a
refresh directive to control how often zones are re-synced. clouddns
currently hardcodes this to 1 minute (delay := 1 * time.Minute in Run)
with no way to change it.

Adds a refresh field to the CloudDNS struct, threads it through New(),
and has Run() use h.refresh instead of the hardcoded delay. Parses the
refresh directive in setup() mirroring route53's exact validation
(accepts a plain number as seconds or a duration string, must be
greater than 0).

Extends TestSetupCloudDNS with refresh coverage (valid duration, valid
plain number, missing arg, non-numeric, zero, negative). Verified it
fails without the setup.go change (unknown property error) and passes
with it.

Signed-off-by: stackedbyaradhya <aradhyaj736@gmail.com>
This commit is contained in:
Aradhya Jain
2026-10-09 07:17:32 +05:30
committed by GitHub
parent 45ac7fe659
commit 538c3554bc
5 changed files with 67 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ the hosted zone.
clouddns [ZONE:PROJECT_ID:HOSTED_ZONE_NAME...] {
credentials [FILENAME]
fallthrough [ZONES...]
refresh DURATION
}
~~~
@@ -45,6 +46,12 @@ clouddns [ZONE:PROJECT_ID:HOSTED_ZONE_NAME...] {
authoritative. If specific zones are listed (for example `in-addr.arpa` and `ip6.arpa`), then
only queries for those zones will be subject to fallthrough.
* `refresh` can be used to control how long between record retrievals from Cloud DNS. It requires
a duration string as a parameter to specify the duration between update cycles. Each update
cycle may result in many Cloud DNS API calls depending on how many domains use this plugin and
how many records are in each. Adjusting the update frequency may help reduce the potential of
API throttling by Google Cloud. If not provided the default refresh is 1 minute.
## Examples
Enable clouddns with implicit GCP credentials and resolve CNAMEs via 10.0.0.1:
@@ -73,3 +80,13 @@ Enable clouddns with multiple hosted zones with the same domain:
clouddns example.org.:gcp-example-project:example-zone example.com.:gcp-example-project:other-example-zone
}
~~~
Enable clouddns and refresh records every 3 minutes:
~~~ txt
example.org {
clouddns example.org.:gcp-example-project:example-zone {
refresh 3m
}
}
~~~