feat: add CLOUDSMITH_KEYRING_FILE_PATH and CLOUDSMITH_KEYRING_DIR for keyring file placement - #382
Draft
cloudsmith-iduffy wants to merge 1 commit into
Draft
feat: add CLOUDSMITH_KEYRING_FILE_PATH and CLOUDSMITH_KEYRING_DIR for keyring file placement#382cloudsmith-iduffy wants to merge 1 commit into
cloudsmith-iduffy wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Cloudsmith-scoped environment variables to control where file-based keyring backends store tokens, avoiding the global side effects of XDG_DATA_HOME and aligning with the existing CLOUDSMITH_KEYRING_* alias pattern.
Changes:
- Introduces
CLOUDSMITH_KEYRING_FILE_PATHas an alias forKEYRING_PROPERTY_FILE_PATH, with~/env-var expansion and native-var precedence. - Adds
CLOUDSMITH_KEYRING_DIRsupport to redirect file-backed keyring backends to a chosen directory while preserving each backend’s default filename. - Extends the keyring unit tests and documents the new env vars in the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
cloudsmith_cli/core/keyring.py |
Adds path expansion + env var syncing and applies CLOUDSMITH_KEYRING_DIR to file-backed keyring backends. |
cloudsmith_cli/core/tests/test_keyring.py |
Adds coverage for new env var precedence/expansion and directory behavior. |
CHANGELOG.md |
Documents the new keyring env vars and their precedence/behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ING_DIR Route the bundled file-based keyring backends with CLI-specific env vars instead of XDG_DATA_HOME. CLOUDSMITH_KEYRING_FILE_PATH aliases KEYRING_PROPERTY_FILE_PATH and sets the exact storage file. CLOUDSMITH_KEYRING_DIR sets the storage directory and keeps the backend's default filename. Native keyring variables take precedence. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
cloudsmith-iduffy
force-pushed
the
feat/keyring-file-placement-env-vars
branch
from
August 22, 2026 20:04
9fa6f25 to
141bdcb
Compare
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.
Description
Why: We were previously using
XDG_DATA_HOMEto route where the keyring token files get written. That quickly led to conflicts and unintended consequences for other tools — the variable relocates data for every XDG-aware application in the environment, not just the CLI.What: Introduce
CLOUDSMITH_-prefixed env vars for better scoped control over keyring file placement, extending the pattern from #356 (CLOUDSMITH_KEYRING_BACKEND,CLOUDSMITH_KEYRING_KEY). Two new variables, in priority order:CLOUDSMITH_KEYRING_FILE_PATH— the exact storage file. Aliases the keyring library's nativeKEYRING_PROPERTY_FILE_PATH, which takes precedence if both are set (same rule as the fix: add CLOUDSMITH_KEYRING_* env var aliases to avoid global impact #356 aliases).CLOUDSMITH_KEYRING_DIR— a storage directory; the backend keeps its default filename (e.g.cryptfile_pass.cfg). Ignored when either file path variable is set, and a no-op for backends that don't store to a file (e.g. macOS Keychain).With neither set, behaviour is unchanged.
~and$VARSare expanded in both. Parent directories are created by the backends' own_ensure_file_path()on first write. Everything is applied in_prepare_keyring_backend(), so all keyring entry points (get/set/delete) resolve paths identically.Examples:
Type of Change
Additional Notes
Verified end-to-end with
keyrings.alt.file.PlaintextKeyring: withCLOUDSMITH_KEYRING_DIRset, the token file lands at<dir>/keyring_pass.cfg; withCLOUDSMITH_KEYRING_FILE_PATHset, it lands at the exact path, and stored tokens read back correctly. Unit tests cover the precedence matrix (native over alias, file path over dir), expansion, and the non-file-backend no-op.