feat(eng-14008): add cloudsmith repos privileges command group - #393
Merged
BartoszBlizniak merged 6 commits intoAug 26, 2026
Conversation
Adds list/set/revoke/replace for the explicit team, user and service account privileges on a repository. Only revoke and replace can take access away, so only those two confirm before writing. The API returns every privilege in one response and ignores page parameters, so list offers no page options. It also has no way to delete a single privilege, so revoke reads the current set and writes back what is being kept. confirm_operation() now accepts an explicit empty prefix so these commands can ask their question directly, and handle_api_exceptions() takes an optional summarise_error callable so the API's field-indexed 422 reads as one sentence naming the repository. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
6 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Adds repository privilege management commands for teams, users, and service accounts.
Changes:
- Adds
list,set,revoke, andreplacecommands. - Adds API wrappers, validation, confirmations, and concise API errors.
- Adds comprehensive CLI/API tests and changelog documentation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
CHANGELOG.md |
Documents privilege commands. |
cloudsmith_cli/cli/commands/repos.py |
Implements the command group. |
cloudsmith_cli/cli/exceptions.py |
Adds optional error summarization. |
cloudsmith_cli/cli/utils.py |
Supports confirmation prompts without a prefix. |
cloudsmith_cli/cli/tests/commands/test_repos_privileges.py |
Tests command behavior. |
cloudsmith_cli/cli/tests/test_exceptions.py |
Tests summarized errors. |
cloudsmith_cli/cli/tests/test_utils.py |
Tests confirmation prompts. |
cloudsmith_cli/core/api/repos.py |
Adds privilege API wrappers. |
cloudsmith_cli/core/tests/test_repos_privileges.py |
Tests API requests and errors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The privileges PATCH endpoint sets a named target to whatever level it is given, in either direction, so `set --privilege read` on a team holding Admin was a revoke with no confirmation, contradicting the documented "adds or raises only" behaviour. Verified against a live org. set now reads the current privileges, and asks before lowering one, naming who drops from what. Granting or raising is unchanged and never asks. -y skips the prompt like it does on revoke and replace. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
BartoszBlizniak
marked this pull request as ready for review
August 25, 2026 16:28
Contributor
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: cloudsmith-iduffy <178375997+cloudsmith-iduffy@users.noreply.github.com>
Contributor
Resolved the merge conflicts by merging |
cloudsmith-iduffy
approved these changes
Aug 26, 2026
tigh-latte
approved these changes
Aug 26, 2026
tigh-latte
left a comment
Contributor
There was a problem hiding this comment.
pulled down, working well in my testing
- privilege_rank now ranks an unrecognised non-empty level above Admin instead of below Read, so `set` over an unexpressible level always confirms rather than silently lowering it - the opposite of what the original ranking did. - `set` skips the pre-write GET entirely when `-y` is passed, since its only purpose is powering the lowering confirmation that `-y` bypasses. - `set`'s docstring now documents the same read-confirm-write race that `revoke`'s docstring already calls out. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…s-command' into eng-14008-cli-add-repo-privileges-command
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
Adds
cloudsmith repos privilegesfor managing who has explicit access to a repository. Teams, users and service accounts are all grantable, revocable and listed side by side.listsetrevokereplaceAnything that can take access away confirms first, and nothing else does. All three writing commands take
-y.Changes outside the privileges commands
Two shared files change. Both are additive and no existing caller is affected, but they are worth a look because they sit outside the new command group.
cli/utils.py-confirm_operation()now accepts an explicit emptyprefix, so a command can ask its question directly instead of through the shared "Are you absolutely certain you want to..." preamble. No existing caller passesprefix, so every other prompt is unchanged.cli/exceptions.py-handle_api_exceptions()takes an optionalsummarise_errorcallable that can replace the context/detail/fields block with one sentence, or decline by returningNone. Only the three new mutating commands pass it, and it is scoped to the API's field-indexed 422; a 403, a 404, or a 422 with no field detail all keep their status code and hint.Worth knowing before reviewing
setcan lower access, so it reads before it writes. The PATCH endpoint sets a named target to whatever level it is given, in either direction, soset --privilege readon a team holdingAdminis a revoke in all but name.settherefore reads the current privileges and asks before lowering one, naming who drops from what. Granting or raising never asks.list. The endpoint returns everything in one response and ignores page parameters, so the command deliberately offers no page options.revokeis read-modify-write. The API cannot delete a single privilege, so revoking reads the current set and writes back what is kept. A concurrent change by someone else can be lost, and an entry the CLI cannot express stops the command rather than being dropped silently.replacefile revokes everything, including your own access. The confirmation says that in those words rather than the misleading "replace all 0 privileges".Type of Change
Additional Notes
Exercised end to end against a live organisation, which is where the two bugs the mocked tests could not have caught turned up: a listed privilege carries an explicit
nullfor the kinds that do not apply and the write endpoints reject those nulls, andreplace OWNER/REPO -consumed stdin for the document, leaving the confirmation with nothing to read so it aborted with no explanation. Writes now send only the key that applies, and reading from stdin asks for-yup front.setdoes not report that a target already had the privilege it was given. The PATCH returns 204 with no after-state, so saying so would mean a GET before every write to produce an advisory line nobody acts on. It prints the entries it wrote;listis there for the resulting state.