Commit dd23604
authored
auth: stop writing workspace_id = none on --skip-workspace (#5338)
## Why
`databricks auth login --skip-workspace` writes a literal `workspace_id
= none` into `.databrickscfg` when no workspace can be discovered. That
string is a CLI-internal sentinel.
## Changes
- Before: `--skip-workspace` (and "Skip" picked in the interactive
workspace prompt) set the in-memory `WorkspaceIDNone` sentinel, which
was then saved to disk as `workspace_id = none`.
- Now: both paths leave `WorkspaceID` empty. `SaveToProfile` already
omits empty fields, so account-only profiles land with no `workspace_id`
key at all. `MatchAccountProfiles` already treats absent and `none`
identically, so legacy profiles that still have `workspace_id = none`
keep working.
`auth.WorkspaceIDNone` stays defined for backwards-compatible parsing.
Re-login regression fix: without the sentinel, an account-only profile
loads back with `WorkspaceID == ""`, which has the same shape as a fresh
login that still needs a workspace pick. Without further changes,
`databricks auth login --profile foo` (no `--skip-workspace`) would
prompt again on every run. Extract `shouldPromptWorkspace` and treat
"existing profile is already account-only" as honoring the user's prior
skip choice. Covers both the new (absent `workspace_id`) and legacy
(`workspace_id = none`) shapes.
## Test plan
- [x] `go test ./cmd/auth/...` (existing tests, including
`TestSetHostAndAccountId_WorkspaceIDNoneSentinelInherited`)
- [x] New `TestShouldPromptWorkspace` table-driven test exercises
re-login into legacy and new-shape account-only profiles, a workspace
profile, `--skip-workspace`, and the no-account-id / known-workspace-id
short-circuits.
- [x] `go test ./acceptance -run
TestAccept/cmd/auth/profiles/spog-account` (legacy `workspace_id = none`
profile still parses as account)
- [x] `./task checks`
- [x] `./task lint-q`1 parent b999e77 commit dd23604
3 files changed
Lines changed: 99 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 331 | + | |
343 | 332 | | |
344 | 333 | | |
345 | 334 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
| 335 | + | |
350 | 336 | | |
351 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
352 | 342 | | |
353 | 343 | | |
354 | 344 | | |
| |||
417 | 407 | | |
418 | 408 | | |
419 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
420 | 430 | | |
421 | 431 | | |
422 | 432 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 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 | + | |
| 616 | + | |
| 617 | + | |
549 | 618 | | |
550 | 619 | | |
551 | 620 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
0 commit comments