You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BUG: Fix get-zones argument parsing to match documentation (#4240)
I ran into this same issue while working on #4208 and can confirm the
behavior @stefanwascoding describes. The only form that works requires
the provider name explicitly:
```shell
dnscontrol get-zones transip TRANSIP all
```
```text
WARNING: To retain compatibility in future versions, please change "TRANSIP" to "-". See "https://docs.dnscontrol.org/commands/get-zones"
```
But following that suggestion also fails:
```shell
dnscontrol get-zones transip - all
```
```text
Arguments should be: credskey providername zone(s) (Ex: r53 ROUTE53 example.com)
```
So neither the documented 2 argument form (`transip all`) nor the
suggested dash form (`transip - all`) works.
This pull request fixes the argument parsing so that `get-zones` accepts
2 arguments (`credkey zone`), resolving the provider type from the
`TYPE` field in `creds.json`. The old 3 argument form still works but
now shows a deprecation warning with the correct command:
```shell
dnscontrol get-zones transip TRANSIP all
```
```text
WARNING: The provider name argument is deprecated. Please use "dnscontrol get-zones transip all" instead. See "https://docs.dnscontrol.org/commands/get-zones"
```
With 3+ arguments, the code now detects whether the second argument is a
registered provider type to distinguish the deprecated form (`credkey
provider zone...`) from the new multi-zone form (`credkey zone1
zone2...`):
```shell
dnscontrol get-zones --format=nameonly transip dnscontrol.org dnscontrol.nl
```
```text
dnscontrol.org
dnscontrol.nl
```
Additionally:
- CLI help is shortened and links to online documentation
- Examples use descriptive `credkey` names (`my_route53` instead of
`myr53`) so they are self-explanatory without the provider name
- `Documentation:` links are added to `get-zones` and `check-creds`
- `documentation/commands/get-zones.md` is updated to match
Tested against the TransIP provider with the `dnscontrol.org` zone from
#4204.
- [x] `go test ./commands/`
- [x] `dnscontrol get-zones transip all` (2 args, new style)
- [x] `dnscontrol get-zones transip dnscontrol.org` (specific zone)
- [x] `dnscontrol get-zones transip dnscontrol.org dnscontrol.nl`
(multiple zones, new style)
- [x] `dnscontrol get-zones transip TRANSIP all` (3 args, deprecation
warning)
- [x] `dnscontrol get-zones transip` (too few args, error message)
- [x] `dnscontrol get-zones --format=zone transip dnscontrol.org`
- [x] `dnscontrol get-zones --format=tsv transip dnscontrol.org`
- [x] `dnscontrol get-zones --format=nameonly transip all`
<details>
<summary>CLI diff</summary>
```diff
--- before (v4.37.1)
+++ after
@@ -2,7 +2,7 @@
dnscontrol get-zones - gets a zone from a provider (stand-alone)
USAGE:
- dnscontrol get-zones [command options] credkey provider zone [...]
+ dnscontrol get-zones [command options] credkey zone [...]
CATEGORY:
utility
@@ -11,34 +11,18 @@
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)
+ credkey: The name used in creds.json
- provider: The name of the provider (second parameter to NewDnsProvider() in dnsconfig.js)
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
+
OPTIONS:
--creds string Provider credentials JSON file (or !program to execute program that outputs json) (default: "creds.json")
--format string Output format: js djs zone tsv nameonly (default: "zone")
```
</details>
Fixes#4235
* answers on port 53 to queries related to the zone).
2784
2784
*
2785
2785
* * `name` must match the name of an entry in `creds.json`.
2786
-
* * `type` specifies a valid DNS provider type identifier listed on the [provider page](../../provider/index.md).
2787
-
* * 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).
2788
-
* * 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.
2786
+
* * `type` is deprecated. The provider type is read from the `TYPE` field in `creds.json`.
2789
2787
* * `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.
2790
2788
*
2791
2789
* This function will return an opaque string that should be assigned to a variable name for use in [D](D.md) directives.
2792
2790
*
2793
-
* Prior to [v3.16](../../release/v316.md):
2794
-
*
2795
-
* ```javascript
2796
-
* var REG_MYNDC = NewRegistrar("mynamedotcom", "NAMEDOTCOM");
2797
-
* var DNS_MYAWS = NewDnsProvider("myaws", "ROUTE53");
* nameservers for the domain). DNSControl only manages the delegation.
2823
2808
*
2824
2809
* * `name` must match the name of an entry in `creds.json`.
2825
-
* * `type` specifies a valid DNS provider type identifier listed on the [provider page](../../provider/index.md).
2826
-
* * 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).
2827
-
* * 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.
2810
+
* * `type` is deprecated. The provider type is read from the `TYPE` field in `creds.json`.
2828
2811
* * `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.
2829
2812
*
2830
2813
* This function will return an opaque string that should be assigned to a variable name for use in [D](D.md) directives.
2831
2814
*
2832
-
* Prior to [v3.16](../../release/v316.md):
2833
-
*
2834
-
* ```javascript
2835
-
* var REG_MYNDC = NewRegistrar("mynamedotcom", "NAMEDOTCOM");
2836
-
* var DNS_MYAWS = NewDnsProvider("myaws", "ROUTE53");
--creds value Provider credentials JSON file (default: "creds.json")
14
14
--out value Instead of stdout, write to this file
15
15
16
16
ARGUMENTS:
17
-
credkey: The name used in creds.json (first parameter to NewDnsProvider() in dnsconfig.js)
18
-
provider: The name of the provider (second parameter to NewDnsProvider() in dnsconfig.js)
17
+
credkey: The name used in creds.json
19
18
```
20
19
21
-
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.
22
-
23
-
Starting in v4.0, the "provider" argument is expected to go away.
20
+
The provider type is read from the `TYPE` field in `creds.json`.
24
21
25
22
## Examples
26
23
27
24
```shell
28
-
dnscontrol check-creds myr53 ROUTE53
29
-
```
30
-
31
-
Starting in [v3.16](../release/v316.md):
32
-
33
-
```shell
34
-
dnscontrol check-creds myr53
35
-
dnscontrol check-creds myr53 -
36
-
dnscontrol check-creds myr53 ROUTE53
37
-
```
38
-
39
-
Starting in v4.0:
40
-
41
-
```shell
42
-
dnscontrol check-creds myr53
25
+
dnscontrol check-creds my_route53
43
26
```
44
27
45
28
This command is the same as `get-zones` with `--format=nameonly`
Copy file name to clipboardExpand all lines: documentation/commands/creds-json.md
+3-13Lines changed: 3 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,15 +42,9 @@ Here's a sample file:
42
42
* ...may include any JSON string value including the empty string.
43
43
* 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.
44
44
45
-
## New in v3.16
45
+
## The TYPE subkey
46
46
47
-
The special subkey "TYPE" is used to indicate the provider type (NONE, CLOUDFLAREAPI, GCLOUD, etc).
48
-
49
-
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`.
50
-
51
-
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.
52
-
53
-
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.
47
+
The special subkey "TYPE" is required in each `creds.json` entry. It indicates the provider type (NONE, CLOUDFLAREAPI, GCLOUD, etc).
54
48
55
49
## Error messages
56
50
@@ -114,11 +108,7 @@ Examples:
114
108
```
115
109
{% endcode %}
116
110
117
-
Starting with [v3.16](../release/v316.md) use of an OLD format will trigger warnings with suggestions on how to adopt the NEW format.
118
-
119
-
Starting with v4.0 support for the OLD format may be reported as an error.
120
-
121
-
Please adopt the NEW format when your installation has eliminated any use of DNSControl pre-3.16.
111
+
Use of the OLD format will trigger warnings with suggestions on how to adopt the NEW format.
credkey: The name used in creds.json (first parameter to NewDnsProvider() in dnsconfig.js)
45
-
provider: The name of the provider (second parameter to NewDnsProvider() in dnsconfig.js)
46
45
zone: One or more zones (domains) to download; or "all".
47
46
```
48
47
49
-
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.
50
-
51
-
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.
48
+
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.
52
49
53
50
```shell
54
51
FORMATS:
@@ -73,50 +70,17 @@ The `--ttl` flag only applies to zone/js/djs formats.
Copy file name to clipboardExpand all lines: documentation/language-reference/top-level-functions/NewDnsProvider.md
+1-18Lines changed: 1 addition & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,28 +14,11 @@ A DSP stores a DNS zone's records and provides DNS service for the zone (i.e.
14
14
answers on port 53 to queries related to the zone).
15
15
16
16
*`name` must match the name of an entry in `creds.json`.
17
-
*`type` specifies a valid DNS provider type identifier listed on the [provider page](../../provider/index.md).
18
-
* 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).
19
-
* 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.
17
+
*`type` is deprecated. The provider type is read from the `TYPE` field in `creds.json`.
20
18
*`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.
21
19
22
20
This function will return an opaque string that should be assigned to a variable name for use in [D](D.md) directives.
Copy file name to clipboardExpand all lines: documentation/language-reference/top-level-functions/NewRegistrar.md
+1-18Lines changed: 1 addition & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,28 +16,11 @@ A registrar maintains the domain's registration and delegation (i.e. the
16
16
nameservers for the domain). DNSControl only manages the delegation.
17
17
18
18
*`name` must match the name of an entry in `creds.json`.
19
-
*`type` specifies a valid DNS provider type identifier listed on the [provider page](../../provider/index.md).
20
-
* 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).
21
-
* 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.
19
+
*`type` is deprecated. The provider type is read from the `TYPE` field in `creds.json`.
22
20
*`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.
23
21
24
22
This function will return an opaque string that should be assigned to a variable name for use in [D](D.md) directives.
0 commit comments