Repository navigation
feat: honor --use-keyring together with --global-config - #32392
Merged
Merged
Conversation
EhabY
force-pushed
the
feat/cli-1-keyring-with-global-config
branch
from
November 18, 2026 21:55
1940f51 to
e5fe4b2
Compare
An explicit --use-keyring flag or CODER_USE_KEYRING value now selects the keyring backend even when --global-config points at a custom directory. When --use-keyring is left at its default, a custom --global-config still selects file storage so existing callers keep finding <dir>/session. Removes the test-only RootCmd.UseKeyringWithGlobalConfig override and the duplicate clitest.NewWithDefaultKeyringCommand helper. Refs CLI-1, #29105
EhabY
force-pushed
the
feat/cli-1-keyring-with-global-config
branch
from
November 19, 2026 10:52
e5fe4b2 to
557d1ab
Compare
jeremyruppel
approved these changes
Nov 20, 2026
This branch had an error being deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
An explicit
--use-keyringflag orCODER_USE_KEYRINGvalue now picks where the session token is stored, even when--global-configpoints at a custom directory. Previously a custom--global-configalways forced file storage, and--use-keyring=truewas silently ignored.When
--use-keyringis left at its default, a custom--global-configstill uses<global-config>/session, so existing callers that rely on that file keep working.--global-config--use-keyringtrue(flag or env)falseLinux and other platforms keep using file storage.
The test-only
RootCmd.UseKeyringWithGlobalConfig()override and the duplicateclitest.NewWithDefaultKeyringCommandhelper are removed;cli/keyring_test.gois now one table-driven test over a shared server that covers unset, flag, env, andfalsevalues. Each case checks that login stores a working token in exactly one backend,coder login tokenreads it back, and logout removes it.Closes #29105. Per-caller keyring namespaces (the second half of the issue) are tracked separately in CLI-83.
Implementation plan and decisions
Selection rule (
ensureTokenBackendincli/root.go):--use-keyringset by flag orCODER_USE_KEYRING: use that value.--global-configis not the default directory, keyring otherwise."Set explicitly" means
CODER_USE_KEYRINGis present in the environment or the leaf command's parsed flags reportuse-keyringas changed. Serpent applies defaults throughValue.Set, so the value itself cannot tell a default from an explicit setting.Why keep the file default for a custom
--global-config: CLI-1 requires existing callers to be unaffected unless they opt in. vscode-coder and JetBrains Toolbox already pass--use-keyringexplicitly, but older extension versions and scripts may pass only--global-configand read<dir>/session.Keyring keys: unchanged. All callers still share the
coder-v2-credentialsentry (keyed by host for https, full origin for http), so a keyring login with a custom--global-configshares its token with Coder Desktop and Toolbox.Deferred to CLI-83: opt-in
--keyring-namespacepersisted in<global-config>/keyring-namespace, so callers can hold independent tokens without passing the namespace every time. Deriving the namespace from the config path was rejected (orphaned entries, breaks on move or rename, leaks paths into the keyring UI).Verification:
go test ./cli/...passes on Linux. Keyring-backed expectations inTestUseKeyringare exercised on macOS and Windows CI.FlagandEnvselect the keyring,Unset/FlagFalse/EnvFalseselect the file, and removing the default-file fallback makesUnsetfail.--use-keyringbefore or after the subcommand, andCODER_USE_KEYRING=true, select the keyring;--use-keyring=falseuses the file.golangci-lintclean for linux, darwin, and windows; help goldens anddocs/reference/cli/index.mdregenerated.Generated by Coder Agents on behalf of @EhabY.