Commit b999e77
authored
auth: suggest ACCOUNT-<id> as default profile name for --skip-workspace (#5339)
## Why
When you run \`databricks auth login --host X --skip-workspace\`, the
profile-name prompt suggests the host's first DNS label (e.g.
\`db-deco-test\`) even though the resulting profile is account-only.
## Changes
\`getProfileName\` already returns \`ACCOUNT-<account-id>\` when
\`AccountID\` is populated, but \`setHostAndAccountId\` (which fills
\`AccountID\` from \`.well-known/databricks-config\`) only runs *after*
the profile-name prompt. So at prompt time, \`AccountID\` was always
empty for the no-\`--profile\` flow.
- Before: \`auth login --host https://db-deco-test... --skip-workspace\`
→ prompt suggests \`db-deco-test\`.
- Now: same command → URL-param extraction + host discovery run eagerly
before the prompt, so the suggestion is \`ACCOUNT-<account-id>\`.
Other login paths are unchanged. The discovery call is redundant with
the one in \`setHostAndAccountId\` later in the flow;
\`runHostDiscovery\` is idempotent for the auth-arguments fields it
touches, so the cost is at most one extra \`.well-known\` round-trip
(≤5s timeout) and only on the \`--skip-workspace\` path.
## Test plan
- [x] New unit tests: \`TestGetProfileName\`,
\`TestSkipWorkspaceProfileNameUsesDiscoveredAccountID\` (uses a mock
\`.well-known\` server)
- [x] \`go test ./cmd/auth/...\` (full package)
- [x] \`./task checks\`
- [x] \`./task lint-q\`1 parent a57fe14 commit b999e77
2 files changed
Lines changed: 66 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
224 | 241 | | |
225 | 242 | | |
226 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
567 | 616 | | |
568 | 617 | | |
569 | 618 | | |
| |||
0 commit comments