* Add GetZoneRecords to DNSProvider interface * dnscontrol now uses ufave/cli/v2 * NEW: get-zones.md * HasRecordTypeName should be a method on models.Records not models.DomainConfig * Implement BIND's GetZoneRecords * new WriteZoneFile implemented * go mod vendor * Update docs to use get-zone instead of convertzone * Add CanGetZone capability and update all providers. * Get all zones for a provider at once (#626) * implement GetZoneRecords for cloudflare * munge cloudflare ttls * Implement GetZoneRecords for cloudflare (#625) Co-authored-by: Craig Peterson <192540+captncraig@users.noreply.github.com>
2.6 KiB
layout | title |
---|---|
default | Get-Zones subcommand |
get-zones (was "convertzone")
DNSControl has a stand-alone utility that will contact a provider, download the records of one or more zones, and output them to a file in a variety of formats.
The original purpose of this command is to help convert legacy domains
to DNScontrol (bootstrapping). Since bootstrapping can not depend on
dnsconfig.js
, get-zones
relies on command line parameters and
creds.json
exclusively.
Syntax:
dnscontrol get-zones [command options] credkey provider zone [...]
--creds value Provider credentials JSON file (default: "creds.json") --format value Output format: dsl tsv pretty (default: "pretty") --out value Instead of stdout, write to this file
ARGUMENTS: credkey: The name used in creds.json (first parameter to NewDnsProvider() in dnsconfig.js) provider: The name of the provider (second parameter to NewDnsProvider() in dnsconfig.js) zone: One or more zones (domains) to download; or "all".
EXAMPLES: dnscontrol get-zones myr53 ROUTE53 example.com dnscontrol get-zones gmain GANDI_V5 example.comn other.com dnscontrol get-zones cfmain CLOUDFLAREAPI all dnscontrol get-zones -format=tsv bind BIND example.com dnscontrol get-zones -format=dsl -out=draft.js glcoud GCLOUD example.com`,
Example commands
dnscontrol get-zone
Developer Note
This command is not implemented for all providers.
To add this to a provider:
- Document the feature
In the *Provider.go
file, change the setting to implemented.
- OLD:
providers.CanGetZones: providers.Unimplemented(),
- NEW:
providers.CanGetZones: providers.Can(),
- Update the docs
go generate
- Implement the
GetZoneRecords
function
Find the GetZoneRecords
function in the *Provider.go
file.
If currently returns fmt.Errorf("not implemented")
.
Instead, it should gather the records from the provider and return them as a list of RecordConfig structs.
The code to do that already exists in GetDomainCorrections
.
You should extract it into its own function (GetZoneRecords
), rather
than having it be burried in the middle of GetDomainCorrections
.
GetDomainCorrections
should call GetZoneRecords
.
Once that is done the get-zone
subcommand should work.
- Optionally implemement the
ListZones
function
If the ListZones
function is implemented, the command will activate
the ability to specify all
as the zone, at which point all zones
will be downloaded.
(Technically what is happening is by implementing the ListZones
function, you are completing the ZoneLister
interface for that
provider.)