Add interactive profile picker to auth logout#4616
Add interactive profile picker to auth logout#4616mihaimitrea-db wants to merge 24 commits intomainfrom
Conversation
|
Commit: 4bd2e44
26 interesting tests: 8 FAIL, 7 SKIP, 6 RECOVERED, 3 flaky, 1 KNOWN, 1 BUG
Top 21 slowest tests (at least 2 minutes):
|
simonfaltum
left a comment
There was a problem hiding this comment.
Looks good! I left some comments
f374e5a to
c903ed8
Compare
c903ed8 to
889b7ca
Compare
889b7ca to
7a39778
Compare
7a39778 to
67eff3f
Compare
cmd/auth/logout.go
Outdated
| slices.SortFunc(allProfiles, func(a, b profile.Profile) int { | ||
| return strings.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name)) | ||
| }) |
There was a problem hiding this comment.
do we always sort profiles alphabetically? I'd think we just want to show them in the order they were added (or alternatively last used or most used but we don't log that anywhere..)
There was a problem hiding this comment.
My personal preference is to have lists sorted, but you are right, no other picker in the codebase does this so for consistency let's go wth the order in which they were added.
| // promptForLogoutProfile shows an interactive profile picker for logout. | ||
| // Account profiles are displayed as "name (account: id)", workspace profiles | ||
| // as "name (host)". | ||
| func promptForLogoutProfile(ctx context.Context, profiler profile.Profiler) (string, error) { |
There was a problem hiding this comment.
I think this is good work but did you look through the codebase for similar patterns?
I think the closest existing pattern is promptForProfileSelection in cmd/auth/token.go (line ~368), which already handles an "all profiles" picker with search by name/host and the StartInSearchMode: len(profiles) > 5 pattern.
I think we are re-implementing much of this logic, which maybe is justified but it might be worth it to make a component we could re-use broadly as selecting profile interactively is something we will have to do multiple times. I think in auth token it lets you create a new profile also, which is probably not something we want to do in logout 😃
There was a problem hiding this comment.
I tried fixing that in the next PR on this stack. Check that out: #4647
a87d5a2 to
bcf6e70
Compare
bcf6e70 to
e536cc8
Compare
Replace manual strings.TrimRight(host, /) with the SDK's config.Config.CanonicalHostName(), which handles scheme normalization, trailing slashes, and empty hosts consistently with how the SDK itself computes token cache keys.
- Make Long description static to avoid calling logger and GetPath at command construction time before the logger is initialized. - Remove empty test.toml files from acceptance tests. - Add \n to error-case titles so errors appear on a separate line. - Use .tokens | keys in jq queries for token cache to reduce verbosity. - Switch test profiles from PAT to auth_type=databricks-cli (U2M) so token cache tests exercise a realistic OAuth logout flow. - Add AuthType field to profile.Profile to detect non-U2M profiles; skip token cache cleanup and adjust success message accordingly. - Add delete-m2m-profiles acceptance test covering PAT profile logout with and without --delete. - Fix DeleteProfile to clear DEFAULT section keys instead of deleting and recreating it, preserving its position in the file.
d5746db to
865c3b0
Compare
c6a2f23 to
3c8e18a
Compare
- Rename isU2MProfile to isCreatedByLogin to accurately reflect that the check is specific to profiles created by . - Tighten success and error messages: drop "Successfully", add actionable suggestions (e.g. "Use --delete to also remove it"), and include retry guidance on partial failures. - Return errors instead of logging on DeleteProfile failure so callers see a non-zero exit code. - Fix token-only acceptance test: use OIDC-style cache key (host/oidc/accounts/<id>) for account profiles so both token cache entries are correctly cleaned up.
3c8e18a to
c37cac0
Compare
c37cac0 to
6a3a446
Compare
When --profile is not specified in an interactive terminal, show a searchable prompt listing all configured profiles. Profiles are sorted alphabetically and displayed with their host or account ID. The picker supports fuzzy search by name, host, or account ID.
Document the four interaction modes (explicit profile, interactive picker, non-interactive error, and --force) in the command's long help text.
369f620 to
4bd2e44
Compare
🥞 Stacked PR
Use this link to review incremental changes.
When --profile is not specified in an interactive terminal, show a searchable prompt listing all configured profiles. Profiles are sorted alphabetically and displayed with their host or account ID. The picker supports fuzzy search by name, host, or account ID.
Changes
Tests