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
75 changes: 36 additions & 39 deletions commands/getZones.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,57 +24,52 @@ var _ = cmd(catUtils, func() *cli.Command {
Aliases: []string{"get-zone"},
Usage: "gets a zone from a provider (stand-alone)",
Action: func(ctx context.Context, c *cli.Command) error {
if c.NArg() < 3 {
return cli.Exit("Arguments should be: credskey providername zone(s) (Ex: r53 ROUTE53 example.com)", 1)
if c.NArg() < 2 {
return cli.Exit("Arguments should be: credskey zone(s) (Ex: my_cloudflare example.com)", 1)
}
args.CredName = c.Args().Get(0)
arg1 := c.Args().Get(1)
args.ProviderName = arg1
// In v4.0, skip the first args.ZoneNames if it equals "-".
args.ZoneNames = c.Args().Slice()[2:]

if arg1 != "" && arg1 != "-" {
// NB(tlim): In v4.0 this "if" can be removed.
fmt.Fprintf(os.Stderr, "WARNING: To retain compatibility in future versions, please change %q to %q. See %q\n",
arg1, "-",
"https://docs.dnscontrol.org/commands/get-zones",
)
if c.NArg() == 2 || c.Args().Get(1) == "-" {
args.ProviderName = ""
if c.Args().Get(1) == "-" {
args.ZoneNames = c.Args().Slice()[2:]
} else {
args.ZoneNames = c.Args().Slice()[1:]
}
} else {
arg1 := c.Args().Get(1)
if _, ok := providers.DNSProviderTypes[arg1]; ok {
// Deprecated form: credkey provider zone [...]
args.ProviderName = arg1
args.ZoneNames = c.Args().Slice()[2:]
fmt.Fprintf(os.Stderr, "WARNING: The provider name argument is deprecated. Please use \"dnscontrol get-zones %s %s\" instead. See %q\n",
args.CredName, strings.Join(args.ZoneNames, " "),
"https://docs.dnscontrol.org/commands/get-zones",
)
} else {
// New form with multiple zones: credkey zone1 zone2 [...]
args.ProviderName = ""
args.ZoneNames = c.Args().Slice()[1:]
}
}

return exit(GetZone(args))
},
Flags: args.flags(),
UsageText: "dnscontrol get-zones [command options] credkey provider zone [...]",
UsageText: "dnscontrol get-zones [command options] credkey zone [...]",
Description: `Download a zone from a provider. This is a stand-alone utility.

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)
credkey: The name used in creds.json
zone: One or more zones (domains) to download; or "all".

FORMATS:
--format=js dnsconfig.js format (not perfect, just a decent first draft)
--format=djs js with disco commas (leading commas)
--format=zone BIND zonefile format
--format=tsv TAB separated value (useful for AWK)
--format=nameonly Just print the zone names

The columns in --format=tsv are:
FQDN (the label with the domain)
ShortName (just the label, "@" if it is the naked domain)
TTL
Record Type (A, AAAA, CNAME, etc.)
Target and arguments (quoted like in a zonefile)
Either empty or a comma-separated list of properties like "cloudflare_proxy=true"

The --ttl flag only applies to zone/js/djs formats.

EXAMPLES:
dnscontrol get-zones myr53 ROUTE53 example.com
dnscontrol get-zones gmain GANDI_V5 example.com other.com
dnscontrol get-zones cfmain CLOUDFLAREAPI all
dnscontrol get-zones --format=tsv bind BIND example.com
dnscontrol get-zones --format=djs --out=draft.js gcloud GCLOUD example.com`,
dnscontrol get-zones my_route53 example.com
dnscontrol get-zones my_gandi example.com other.com
dnscontrol get-zones my_cloudflare all
dnscontrol get-zones --format=tsv my_bind example.com
dnscontrol get-zones --format=djs --out=draft.js my_gcloud example.com

Documentation: https://docs.dnscontrol.org/commands/get-zones`,
}
}())

Expand Down Expand Up @@ -120,7 +115,9 @@ ARGUMENTS:
EXAMPLES:
dnscontrol check-creds myr53 ROUTE53 # Pre v3.16, or pre-v4.0 for backwards-compatibility
dnscontrol check-creds myr53
dnscontrol check-creds --out=/dev/null myr53 && echo Success`,
dnscontrol check-creds --out=/dev/null myr53 && echo Success

Documentation: https://docs.dnscontrol.org/commands/check-creds`,
}
}())

Expand Down
34 changes: 2 additions & 32 deletions commands/types/dnscontrol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2783,26 +2783,11 @@ declare function NS(name: string, target: string, ...modifiers: RecordModifier[]
* answers on port 53 to queries related to the zone).
*
* * `name` must match the name of an entry in `creds.json`.
* * `type` specifies a valid DNS provider type identifier listed on the [provider page](../../provider/index.md).
* * Starting with [v3.16](../../release/v316.md), the type is optional. If it is absent, the `TYPE` field in `creds.json` is used instead. You can leave it out. (Thanks to JavaScript magic, you can leave it out even when there are more fields).
* * Starting with v4.0, specifying the type may be an error. Please add the `TYPE` field to `creds.json` and remove this parameter from `dnsconfig.js` to prepare.
* * `type` is deprecated. The provider type is read from the `TYPE` field in `creds.json`.
* * `meta` is a way to send additional parameters to the provider. It is optional and only certain providers use it. See the [individual provider docs](../../provider/index.md) for details.
*
* This function will return an opaque string that should be assigned to a variable name for use in [D](D.md) directives.
*
* Prior to [v3.16](../../release/v316.md):
*
* ```javascript
* var REG_MYNDC = NewRegistrar("mynamedotcom", "NAMEDOTCOM");
* var DNS_MYAWS = NewDnsProvider("myaws", "ROUTE53");
*
* D("example.com", REG_MYNDC, DnsProvider(DNS_MYAWS),
* A("@","1.2.3.4"),
* );
* ```
*
* In [v3.16](../../release/v316.md) and later:
*
* ```javascript
* var REG_MYNDC = NewRegistrar("mynamedotcom");
* var DNS_MYAWS = NewDnsProvider("myaws");
Expand All @@ -2822,26 +2807,11 @@ declare function NewDnsProvider(name: string, meta?: object): string;
* nameservers for the domain). DNSControl only manages the delegation.
*
* * `name` must match the name of an entry in `creds.json`.
* * `type` specifies a valid DNS provider type identifier listed on the [provider page](../../provider/index.md).
* * Starting with [v3.16](../../release/v316.md), the type is optional. If it is absent, the `TYPE` field in `creds.json` is used instead. You can leave it out. (Thanks to JavaScript magic, you can leave it out even when there are more fields).
* * Starting with v4.0, specifying the type may be an error. Please add the `TYPE` field to `creds.json` and remove this parameter from `dnsconfig.js` to prepare.
* * `type` is deprecated. The provider type is read from the `TYPE` field in `creds.json`.
* * `meta` is a way to send additional parameters to the provider. It is optional and only certain providers use it. See the [individual provider docs](../../provider/index.md) for details.
*
* This function will return an opaque string that should be assigned to a variable name for use in [D](D.md) directives.
*
* Prior to [v3.16](../../release/v316.md):
*
* ```javascript
* var REG_MYNDC = NewRegistrar("mynamedotcom", "NAMEDOTCOM");
* var DNS_MYAWS = NewDnsProvider("myaws", "ROUTE53");
*
* D("example.com", REG_MYNDC, DnsProvider(DNS_MYAWS),
* A("@","1.2.3.4"),
* );
* ```
*
* In [v3.16](../../release/v316.md) and later:
*
* ```javascript
* var REG_MYNDC = NewRegistrar("mynamedotcom");
* var DNS_MYAWS = NewDnsProvider("myaws");
Expand Down
1 change: 0 additions & 1 deletion documentation/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,4 @@
## Release

* [How to build and ship a release](release/release-engineering.md)
* [Changelog v3.16.0](release/v316.md)
* [GitHub releases](https://github.com/DNSControl/dnscontrol/releases/latest)
25 changes: 4 additions & 21 deletions documentation/commands/check-creds.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,21 @@ successful, a list of zones will be output (which may be an empty list). If the
```text
Syntax:

dnscontrol check-creds [command options] credkey provider
dnscontrol check-creds [command options] credkey

--creds value Provider credentials JSON file (default: "creds.json")
--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)
credkey: The name used in creds.json
```

Starting in [v3.16](../release/v316.md), "provider" is optional. If it is omitted (or the placeholder value `-` is used), the `TYPE` specified in `creds.json` will be used instead. A warning will be displayed with advice on how to remain compatible with v4.0.

Starting in v4.0, the "provider" argument is expected to go away.
The provider type is read from the `TYPE` field in `creds.json`.

## Examples

```shell
dnscontrol check-creds myr53 ROUTE53
```

Starting in [v3.16](../release/v316.md):

```shell
dnscontrol check-creds myr53
dnscontrol check-creds myr53 -
dnscontrol check-creds myr53 ROUTE53
```

Starting in v4.0:

```shell
dnscontrol check-creds myr53
dnscontrol check-creds my_route53
```

This command is the same as `get-zones` with `--format=nameonly`
Expand Down
16 changes: 3 additions & 13 deletions documentation/commands/creds-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,9 @@ Here's a sample file:
* ...may include any JSON string value including the empty string.
* If a subkey starts with `$`, it is taken as an env variable. In the above example, `$CNR_APILOGIN` would be replaced by the value of the environment variable `CNR_APILOGIN` or the empty string if no such environment variable exists.

## New in v3.16
## The TYPE subkey

The special subkey "TYPE" is used to indicate the provider type (NONE, CLOUDFLAREAPI, GCLOUD, etc).

Prior to [v3.16](../release/v316.md), the provider type is specified as the second argument to `NewRegistrar()` and `NewDnsProvider()` in `dnsconfig.js` or as a command-line argument in tools such as `dnscontrol get-zones`.

Starting in [v3.16](../release/v316.md), `NewRegistrar()`, and `NewDnsProvider()` no longer require the provider type to be specified. It may be specified for backwards compatibility, but a warning will be generated with a suggestion of how to upgrade to the 4.0 format. Likewise, command-line tools no longer require the provider type to be specified, but for backwards compatibility one may specify `-` since the parameter is positional.

In 4.0, DNSControl will require the "TYPE" subkey in each `creds.json` entry. Command line tools will have a backwards-incompatible change to remove the provider-type as a positional argument. Prior to 4.0, the various commands will output warnings and suggestions to avoid compatibility issues during the transition.
The special subkey "TYPE" is required in each `creds.json` entry. It indicates the provider type (NONE, CLOUDFLAREAPI, GCLOUD, etc).

## Error messages

Expand Down Expand Up @@ -114,11 +108,7 @@ Examples:
```
{% endcode %}

Starting with [v3.16](../release/v316.md) use of an OLD format will trigger warnings with suggestions on how to adopt the NEW format.

Starting with v4.0 support for the OLD format may be reported as an error.

Please adopt the NEW format when your installation has eliminated any use of DNSControl pre-3.16.
Use of the OLD format will trigger warnings with suggestions on how to adopt the NEW format.

### mismatch

Expand Down
52 changes: 8 additions & 44 deletions documentation/commands/get-zones.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ If a provider supports it, `--format=nameonly` lists the names of the zones at t
## Syntax

```shell
dnscontrol get-zones [command options] credkey provider zone [...]
dnscontrol get-zones [command options] credkey zone [...]

--creds value Provider credentials JSON file (default: "creds.json")
--format value Output format: js djs zone tsv nameonly (default: "zone")
Expand All @@ -42,13 +42,10 @@ dnscontrol get-zones [command options] credkey provider zone [...]

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".
```

As of [v3.16](../release/v316.md), `provider` can be `-` to indicate that the provider name is listed in `creds.json` in the `TYPE` field. Doing this will be backwards compatible with an (otherwise) breaking change due in v4.0.

As of v4.0 (BREAKING CHANGE), you must not specify `provider`. That value is found in the `TYPE` field of the credkey's `creds.json` file. For backwards compatibility, if the first `zone` is `-`, it will be skipped.
The provider type is read from the `TYPE` field in `creds.json`. For backwards compatibility, you may still specify the provider name explicitly as a second argument (e.g. `dnscontrol get-zones my_route53 ROUTE53 example.com`), but this is deprecated.

```shell
FORMATS:
Expand All @@ -73,50 +70,17 @@ The `--ttl` flag only applies to zone/js/djs formats.
## Examples

```shell
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=djs --out=draft.js glcoud GCLOUD example.com
```

As of [v3.16](../release/v316.md):

```shell
# NOTE: When "-" appears as the 2nd argument, it is assumed that the
# creds.json entry has a field TYPE with the provider's type name.
dnscontrol get-zones gmain GANDI_V5 example.comn other.com
dnscontrol get-zones gmain - example.comn other.com
dnscontrol get-zones cfmain CLOUDFLAREAPI all
dnscontrol get-zones cfmain - all
dnscontrol get-zones --format=tsv bind BIND example.com
dnscontrol get-zones --format=tsv bind - example.com
dnscontrol get-zones --format=djs --out=draft.js glcoud GCLOUD example.com
dnscontrol get-zones --format=djs --out=draft.js glcoud - example.com
```

As of v4.0:

```shell
dnscontrol get-zones gmain example.comn other.com
dnscontrol get-zones cfmain all
dnscontrol get-zones --format=tsv bind example.com
dnscontrol get-zones --format=djs --out=draft.js glcoud example.com
```

For backwards compatibility, these are valid until at least v5.0

```shell
dnscontrol get-zones gmain - example.comn other.com
dnscontrol get-zones cfmain - all
dnscontrol get-zones --format=tsv bind - example.com
dnscontrol get-zones --format=djs --out=draft.js glcoud - example.com
dnscontrol get-zones my_route53 example.com
dnscontrol get-zones my_gandi example.com other.com
dnscontrol get-zones my_cloudflare all
dnscontrol get-zones --format=tsv my_bind example.com
dnscontrol get-zones --format=djs --out=draft.js my_gcloud example.com
```

Read a zonefile, generate a JS file, then use the JS file to see how different it is from the zonefile:

```shell
dnscontrol get-zone --format=djs -out=foo.djs bind - example.com
dnscontrol get-zones --format=djs --out=foo.djs my_bind example.com
dnscontrol preview --config foo.js
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,11 @@ A DSP stores a DNS zone's records and provides DNS service for the zone (i.e.
answers on port 53 to queries related to the zone).

* `name` must match the name of an entry in `creds.json`.
* `type` specifies a valid DNS provider type identifier listed on the [provider page](../../provider/index.md).
* Starting with [v3.16](../../release/v316.md), the type is optional. If it is absent, the `TYPE` field in `creds.json` is used instead. You can leave it out. (Thanks to JavaScript magic, you can leave it out even when there are more fields).
* Starting with v4.0, specifying the type may be an error. Please add the `TYPE` field to `creds.json` and remove this parameter from `dnsconfig.js` to prepare.
* `type` is deprecated. The provider type is read from the `TYPE` field in `creds.json`.
* `meta` is a way to send additional parameters to the provider. It is optional and only certain providers use it. See the [individual provider docs](../../provider/index.md) for details.

This function will return an opaque string that should be assigned to a variable name for use in [D](D.md) directives.

Prior to [v3.16](../../release/v316.md):

{% code title="dnsconfig.js" %}
```javascript
var REG_MYNDC = NewRegistrar("mynamedotcom", "NAMEDOTCOM");
var DNS_MYAWS = NewDnsProvider("myaws", "ROUTE53");

D("example.com", REG_MYNDC, DnsProvider(DNS_MYAWS),
A("@","1.2.3.4"),
);
```
{% endcode %}

In [v3.16](../../release/v316.md) and later:

{% code title="dnsconfig.js" %}
```javascript
var REG_MYNDC = NewRegistrar("mynamedotcom");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,11 @@ A registrar maintains the domain's registration and delegation (i.e. the
nameservers for the domain). DNSControl only manages the delegation.

* `name` must match the name of an entry in `creds.json`.
* `type` specifies a valid DNS provider type identifier listed on the [provider page](../../provider/index.md).
* Starting with [v3.16](../../release/v316.md), the type is optional. If it is absent, the `TYPE` field in `creds.json` is used instead. You can leave it out. (Thanks to JavaScript magic, you can leave it out even when there are more fields).
* Starting with v4.0, specifying the type may be an error. Please add the `TYPE` field to `creds.json` and remove this parameter from `dnsconfig.js` to prepare.
* `type` is deprecated. The provider type is read from the `TYPE` field in `creds.json`.
* `meta` is a way to send additional parameters to the provider. It is optional and only certain providers use it. See the [individual provider docs](../../provider/index.md) for details.

This function will return an opaque string that should be assigned to a variable name for use in [D](D.md) directives.

Prior to [v3.16](../../release/v316.md):

{% code title="dnsconfig.js" %}
```javascript
var REG_MYNDC = NewRegistrar("mynamedotcom", "NAMEDOTCOM");
var DNS_MYAWS = NewDnsProvider("myaws", "ROUTE53");

D("example.com", REG_MYNDC, DnsProvider(DNS_MYAWS),
A("@","1.2.3.4"),
);
```
{% endcode %}

In [v3.16](../../release/v316.md) and later:

{% code title="dnsconfig.js" %}
```javascript
var REG_MYNDC = NewRegistrar("mynamedotcom");
Expand Down
Loading
Loading