Skip to content

fix(p/DNSMADEEASY): ask the sandbox setting as a yes/no question in init - #4877

Merged
TomOnTime merged 1 commit into
DNSControl:mainfrom
cafferata:fix/init-dnsmadeeasy-prompt
Sep 13, 2026
Merged

TomOnTime merged 1 commit into
DNSControl:mainfrom
cafferata:fix/init-dnsmadeeasy-prompt

Conversation

@cafferata

@cafferata cafferata commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

While looking into #4381 (the INWX sandbox question in dnscontrol init being confusing), DNS Made Easy turned out to have the same kind of prompt. The question asks "Use sandbox", and only the ? help explains that any non-empty value enables the sandbox. Because the provider checks for a non-empty value, answering no or false actually enables the sandbox API.

The sandbox setting is now a yes/no question with production as the default. Answering yes writes "sandbox": "1", which the provider already treats as sandbox, so existing configurations keep working.

Before, after typing ? at the sandbox prompt:

API settings for DNS Made Easy: https://cp.dnsmadeeasy.com/
? API key [api_key] (required) [? for help] ***
? Secret key [secret_key] (required) [? for help] ******
? Set to any non-empty value to use the DNS Made Easy sandbox API instead of production.
? Use sandbox (optional) [sandbox] (optional)

After, after typing ? at the sandbox prompt:

API settings for DNS Made Easy: https://cp.dnsmadeeasy.com/
? API key [api_key] (required) [? for help] ***
? Secret key [secret_key] (required) [? for help] ******
? Answer no for normal use. The sandbox needs its own API credentials from https://sandbox.dnsmadeeasy.com/.
? Use the DNS Made Easy sandbox API instead of production? [sandbox] (y/N)

Answering y gives the following, and the creds.json entry is identical to answering 1 before:

API settings for DNS Made Easy: https://cp.dnsmadeeasy.com/
? API key [api_key] (required) [? for help] ***
? Secret key [secret_key] (required) [? for help] ******
? Use the DNS Made Easy sandbox API instead of production? [sandbox] Yes

{
  "example": {
    "TYPE": "DNSMADEEASY",
    "api_key": "key",
    "sandbox": "1",
    "secret_key": "secret"
  }
}

The output above comes from running the DNS Made Easy credential prompts (collectFields() with the real survey prompts) in a pseudo terminal, on main and on this branch. go test ./providers/dnsmadeeasy/ ./commands/ passes.

@vojtad, as the DNS Made Easy maintainer, could you take a look?

Part of #4381

AI-attributie

Assisted-by: Claude Code:claude-opus-5

TomOnTime pushed a commit that referenced this pull request Sep 13, 2026
…ue for yes/no fields (#4875)

This is the first of five pull requests for
#4381, where patschi
found the `sandbox` question in `dnscontrol init` for INWX confusing
(#4293 (comment)).
This one contains the shared `init` changes. The provider specific
prompts follow in four separate pull requests on top of this branch
(INWX, DNSMADEEASY, FORTIGATE and CNR)
#4876,
#4877,
#4878 and
#4879, so each maintainer
can review the part for their own provider.

The first commit fixes the "(optional)" suffix that was shown twice.
`askField()` already appends "(required)" or "(optional)" to every
label, but 18 labels in 11 providers (AUTODNS, CLOUDFLAREAPI, CNR,
DNSIMPLE, DNSMADEEASY, FORTIGATE, HEDNS, INWX, NAMECHEAP, PORKBUN and
ROUTE53) also had it in the label text itself. The suffix is removed
from those labels, and the label construction moved into `fieldLabel()`,
which strips a trailing "(optional)" or "(required)" from the label so
it cannot come back. `writing-providers.md` now mentions that the wizard
adds the `creds.json` key and the suffix itself.

Before, the INWX credential prompts on `main`:

```text
API settings for INWX: https://www.inwx.com/en/customer
? Username (required) demo
? Password (required) [? for help] ******
? Use sandbox (optional) [sandbox] (optional) 1
```

After, on this branch:

```text
API settings for INWX: https://www.inwx.com/en/customer
? Username (required) demo
? Password (required) [? for help] ******
? Use sandbox [sandbox] (optional) 1
```

The second commit adds `ConfirmValue` to `CredsField`. A few settings
are really on or off, but `init` asks for them as free text with a value
that is only explained after typing `?`: `1` for INWX, any non-empty
value for DNS Made Easy and `true` for FortiGate. A field with
`ConfirmValue` is asked as a yes/no question instead. Yes writes
`ConfirmValue` to `creds.json` and no leaves the key out, so the
resulting `creds.json` stays the same as with the free text answer. The
field help is now passed to `Asker.Confirm()` so `?` keeps working, and
the "(optional)" suffix is left out for these prompts because a yes/no
answer is never empty. Nothing uses `ConfirmValue` in this pull request
yet; the provider pull requests do.

`go test ./commands/ ./pkg/providers/...` passes, including new tests
for `fieldLabel()` and for `askField()` and `collectFields()` with
`ConfirmValue`, and so does `go test` over the 11 touched provider
packages. The before and after output comes from running the INWX
credential prompts (`collectFields()` with the real survey prompts) in a
pseudo terminal, on `main` and on this branch.

## AI-attributie

Assisted-by: Claude Code:claude-opus-5
- Replace the free text `sandbox` prompt, which only explained in the `?` help that any non-empty value enables the sandbox, with a yes/no question using `ConfirmValue`.
- Answering yes writes `"sandbox": "1"` to `creds.json`; the provider treats any non-empty value as sandbox, so the result matches existing configurations.

Refs DNSControl#4381
@cafferata
cafferata force-pushed the fix/init-dnsmadeeasy-prompt branch from 3b08aae to 7d4d262 Compare September 13, 2026 19:45
@cafferata cafferata changed the title DNSMADEEASY: Ask the sandbox setting as a yes/no question in init fix(p/DNSMADEEASY): ask the sandbox setting as a yes/no question in init Sep 13, 2026
@cafferata
cafferata requested a review from vojtad September 13, 2026 19:55
@TomOnTime
TomOnTime merged commit df419c5 into DNSControl:main Sep 13, 2026
12 of 13 checks passed
@cafferata
cafferata deleted the fix/init-dnsmadeeasy-prompt branch September 14, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants