Extract shared SelectProfile helper to eliminate duplicate profile pickers#4647
Merged
mihaimitrea-db merged 34 commits intomainfrom Mar 12, 2026
Merged
Conversation
This was referenced Mar 3, 2026
0f9a04c to
c6d25f1
Compare
Collaborator
|
Commit: a48290e
16 interesting tests: 7 KNOWN, 7 SKIP, 2 flaky
Top 21 slowest tests (at least 2 minutes):
|
c6d25f1 to
c9512bf
Compare
8a5d258 to
b40887a
Compare
b40887a to
16de011
Compare
16de011 to
3116cbb
Compare
3116cbb to
634b7b9
Compare
634b7b9 to
40c98ed
Compare
40c98ed to
76e7b0e
Compare
c6a2f23 to
3c8e18a
Compare
76e7b0e to
109b1ca
Compare
3c8e18a to
c37cac0
Compare
109b1ca to
336ab51
Compare
c37cac0 to
6a3a446
Compare
8e3d5e7 to
ed5be7c
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.
…ckers Four places built nearly identical promptui.Select prompts for interactive profile selection (auth logout, auth token, root auth, root bundle). Extract a reusable profile.SelectProfile function that takes a declarative SelectConfig with label, profiles, and template strings. Also: add AccountID to Profiles.SearchCaseInsensitive so all pickers support searching by account ID, and remove the redundant not-found guard in DeleteProfile (ini.DeleteSection is already a no-op for missing sections).
Extract writeConfigFile helper to consolidate the repeated default-comment, backup, and save sequence shared by SaveToProfile and DeleteProfile. Also switch auth login from os.Getenv to env.Get(ctx, ...) for DATABRICKS_CONFIG_FILE so it respects context-level env overrides, consistent with the rest of the codebase.
- Restore StartInSearchMode for logout picker so profiles with 6+ entries auto-activate search, matching the previous behavior. - Improve empty-profiles error to suggest running 'databricks auth login' instead of the generic "no profiles to select from".
ed5be7c to
51f14b5
Compare
… coupling - Only preserve host-keyed OAuth tokens when another U2M profile shares the host. Non-U2M profiles (PAT, M2M) never use the OAuth cache, so they should not prevent token cleanup on logout. - Add m2m token entries to test fixtures and assert they are preserved after logout, verifying the isCreatedByLogin guard works correctly. - Fix inMemoryTokenCache.Store(nil) to delete the key (matching production FileTokenCache behavior) instead of storing a nil value. - Build the promptui Searcher from the items slice directly in SelectProfile to avoid implicit coupling with the original Profiles slice.
mihaimitrea-db
added a commit
that referenced
this pull request
Mar 12, 2026
The auth logout feature (PRs #4613, #4616, #4647) was squashed into a single commit cb3c326 titled after #4647 only, losing traceability for the new command itself. This followup: - Adds a comment block to logout.go linking each original PR with its commit range and purpose. - Adds a NEXT_CHANGELOG entry for auth logout under CLI. - Removes Hidden: true so the command appears in help and completion. - Aligns the Long description with the public documentation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🥞 Stacked PR
Use this link to review incremental changes.
Four places built nearly identical
promptui.Selectprompts for interactive profile selection (auth logout,auth token,cmd/root/auth.go,cmd/root/bundle.go). This PR extracts a reusableprofile.SelectProfilefunction that accepts a declarativeSelectConfigwith label, profiles, and template strings, replacing all four implementations.Changes
profile.SelectProfileinlibs/databrickscfg/profile/select.go— a shared interactive profile picker that accepts aSelectConfig(label, profiles, template strings) and returns the selected profile name.promptui.Selectimplementations incmd/auth/logout.go,cmd/auth/token.go,cmd/root/auth.go, andcmd/root/bundle.gowith calls toSelectProfile.AccountIDtoProfiles.SearchCaseInsensitiveso all pickers support searching by account ID, not just name and host.writeConfigFilehelper inlibs/databrickscfg/ops.goto consolidate the repeated default-comment / backup / save sequence shared bySaveToProfileandDeleteProfile.Why
The four profile pickers each duplicated the same prompt setup, searcher wiring, and result extraction. This made it easy for behavior to diverge (e.g., only the logout picker searched by account ID). A single shared helper keeps the UX consistent and reduces the surface area for future changes.
Tests
auth logout,auth token, workspace/account profile selection, and bundle profile resolution continue to pass — the refactor is behavior-preserving.SelectProfilehelper is exercised indirectly through all existing callers.