mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Rename get-zones formats as pretty/dsl/tsv to zone/js/tsv (#687)
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
@@ -38,17 +38,17 @@ ARGUMENTS:
|
||||
zone: One or more zones (domains) to download; or "all".
|
||||
|
||||
FORMATS:
|
||||
--format=dsl dnsconfig.js format (not perfect, but a decent first draft)
|
||||
--format=nameonly Just print the zone names
|
||||
--format=pretty BIND Zonefile format
|
||||
--format=tsv TAB separated value (useful for AWK)
|
||||
--format=js dnsconfig.js format (not perfect, but a decent first draft)
|
||||
--format=zone BIND Zonefile format
|
||||
--format=tsv TAB separated value (useful for AWK)
|
||||
--format=nameonly Just print the zone names
|
||||
|
||||
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`,
|
||||
dnscontrol get-zones -format=js -out=draft.js glcoud GCLOUD example.com`,
|
||||
}
|
||||
}())
|
||||
|
||||
@@ -104,8 +104,8 @@ func (args *GetZoneArgs) flags() []cli.Flag {
|
||||
flags = append(flags, &cli.StringFlag{
|
||||
Name: "format",
|
||||
Destination: &args.OutputFormat,
|
||||
Value: "pretty",
|
||||
Usage: `Output format: dsl pretty tsv nameonly`,
|
||||
Value: "zone",
|
||||
Usage: `Output format: js zone tsv nameonly`,
|
||||
})
|
||||
flags = append(flags, &cli.StringFlag{
|
||||
Name: "out",
|
||||
@@ -177,7 +177,7 @@ func GetZone(args GetZoneArgs) error {
|
||||
|
||||
// Write it out:
|
||||
|
||||
if args.OutputFormat == "dsl" {
|
||||
if args.OutputFormat == "js" {
|
||||
fmt.Fprintf(w, `var %s = NewDnsProvider("%s", "%s");`+"\n",
|
||||
args.CredName, args.CredName, args.ProviderName)
|
||||
}
|
||||
@@ -189,12 +189,12 @@ func GetZone(args GetZoneArgs) error {
|
||||
z := prettyzone.PrettySort(recs, zoneName, 0, nil)
|
||||
switch args.OutputFormat {
|
||||
|
||||
case "pretty":
|
||||
case "zone":
|
||||
fmt.Fprintf(w, "$ORIGIN %s.\n", zoneName)
|
||||
prettyzone.WriteZoneFileRC(w, z.Records, zoneName, uint32(args.DefaultTTL), nil)
|
||||
fmt.Fprintln(w)
|
||||
|
||||
case "dsl":
|
||||
case "js":
|
||||
fmt.Fprintf(w, `D("%s", REG_CHANGEME,`, zoneName)
|
||||
fmt.Fprintf(w, "\n\tDnsProvider(%s)", args.CredName)
|
||||
defaultTTL := uint32(args.DefaultTTL)
|
||||
|
@@ -19,7 +19,7 @@ Syntax:
|
||||
dnscontrol get-zones [command options] credkey provider zone [...]
|
||||
|
||||
--creds value Provider credentials JSON file (default: "creds.json")
|
||||
--format value Output format: dsl pretty tsv nameonly (default: "pretty")
|
||||
--format value Output format: js zone tsv nameonly (default: "zone")
|
||||
--out value Instead of stdout, write to this file
|
||||
--ttl value Default TTL (0 picks the zone's most common TTL) (default: 0)
|
||||
|
||||
@@ -29,10 +29,10 @@ ARGUMENTS:
|
||||
zone: One or more zones (domains) to download; or "all".
|
||||
|
||||
FORMATS:
|
||||
--format=dsl dnsconfig.js format (not perfect, but a decent first draft)
|
||||
--format=nameonly Just print the zone names
|
||||
--format=pretty BIND Zonefile format
|
||||
--format=tsv TAB separated value (useful for AWK)
|
||||
--format=js dnsconfig.js format (not perfect, but a decent first draft)
|
||||
--format=zone BIND Zonefile format
|
||||
--format=tsv TAB separated value (useful for AWK)
|
||||
--format=nameonly Just print the zone names
|
||||
|
||||
When using `tsv`, the columns are:
|
||||
FQDN (the label with the domain)
|
||||
@@ -41,14 +41,14 @@ When using `tsv`, the columns are:
|
||||
Record Type (A, AAAA, CNAME, etc.)
|
||||
Target and arguments (quoted like in a zonefile)
|
||||
|
||||
The --ttl flag applies to pretty and dsl formats.
|
||||
The --ttl flag applies to zone and js formats.
|
||||
|
||||
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`,
|
||||
dnscontrol get-zones -format=js -out=draft.js glcoud GCLOUD example.com`,
|
||||
|
||||
|
||||
# Example commands
|
||||
|
@@ -56,8 +56,8 @@ Example 1: Read a BIND zonefile
|
||||
Most DNS Service Providers have an 'export to zonefile' feature.
|
||||
|
||||
```
|
||||
dnscontrol get-zones -format=dsl bind BIND example.com
|
||||
dnscontrol get-zones -format=dsl -out=draft.js bind BIND example.com
|
||||
dnscontrol get-zones -format=js bind BIND example.com
|
||||
dnscontrol get-zones -format=js -out=draft.js bind BIND example.com
|
||||
```
|
||||
|
||||
This will read the file `zones/example.com.zone`. The system is a bit
|
||||
@@ -75,8 +75,8 @@ Suppose your `creds.json` file has the name `global_aws`
|
||||
for the provider `ROUTE53`. Your command would look like this:
|
||||
|
||||
```
|
||||
dnscontrol get-zones -format=dsl global_aws ROUTE53 example.com
|
||||
dnscontrol get-zones -format=dsl -out=draft.js global_aws ROUTE53 example.com
|
||||
dnscontrol get-zones -format=js global_aws ROUTE53 example.com
|
||||
dnscontrol get-zones -format=js -out=draft.js global_aws ROUTE53 example.com
|
||||
```
|
||||
|
||||
Add the contents of `draft.js` to `dnsconfig.js` and edit it as needed.
|
||||
@@ -108,7 +108,7 @@ to convert a zone. Lines that start with `#` are comments.
|
||||
|
||||
# Note this command uses ">>" to append to dnsconfig.js. Do
|
||||
# not use ">" as that will erase the existing file.
|
||||
dnscontrol get-zones -format=dsl -out=draft.js bind BIND foo.com
|
||||
dnscontrol get-zones -format=js -out=draft.js bind BIND foo.com
|
||||
cat >>dnsconfig.js draft.js # Append to dnsconfig.js
|
||||
#
|
||||
dnscontrol preview
|
||||
|
Reference in New Issue
Block a user