feat(eng-12001): add metada commands (CRUD)#288
Merged
BartoszBlizniak merged 8 commits intoMay 11, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new cloudsmith metadata CLI command group to manage v2 package metadata entries (list/get/add/update/remove), including slug resolution via the existing packages API.
Changes:
- Introduces
cloudsmith metadatacommand group with CRUD subcommands, JSON/table output, pagination support, and destructive-action confirmation for removals. - Adds
core.api.packages.get_package_slug_perm()helper to resolve a package’s permanent slug for metadata endpoints. - Adds CLI test coverage for help text, list pagination/filters, JSON output, content loading (inline/file/stdin), validation, update behavior, and remove confirmation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cloudsmith_cli/core/api/packages.py |
Adds get_package_slug_perm() to resolve a package slug_perm for downstream calls. |
cloudsmith_cli/cli/commands/metadata.py |
Implements the new metadata command group and its subcommands (CRUD + formatting/content loading). |
cloudsmith_cli/cli/commands/__init__.py |
Registers the new metadata command module so Click loads the group. |
cloudsmith_cli/cli/tests/commands/test_metadata.py |
Adds a comprehensive test suite for the new command group. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cloudsmith-iduffy
approved these changes
May 1, 2026
Member
Author
|
Pausing merge - working on scoping a validation endpoint, which may require some additional changes here. |
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 a new
cloudsmith metadatacommand group for managing metadata entries attached to packages.The command group supports:
cloudsmith metadata list/lsto list metadata for a package, with optional--source-kindand--classificationfilters.cloudsmith metadata list OWNER/REPO/PACKAGE METADATA_SLUG_PERMto retrieve a single metadata entry (filters and pagination flags are ignored in this mode).cloudsmith metadata addto attach metadata from inline JSON, a JSON file, or stdin (--file -).--source-identitydefaults tocloudsmith-cli@<version>.cloudsmith metadata updateto patch metadatacontentand/orsource-identity.content_typeis immutable after creation. Errors out if no patchable field is supplied.cloudsmith metadata remove/rmto delete metadata, guarded by the standard destructive-action confirmation flow and-y/--yes.All subcommands honour
-F json/-F pretty_jsonand route throughmaybe_print_as_jsonso JSON output is consistent with the rest of the CLI.Example: list metadata for a package
Example: list with filters
Both filters accept an integer or the enum name (case-insensitive, hyphens treated as underscores), so
--source-kind third-party,--source-kind THIRD_PARTY, and--source-kind 4are equivalent. Invalid values fail fast with a usage error before the API is called.Example: retrieve a single metadata entry
Example: add inline metadata
cloudsmith metadata add your-org/awesome-repo/better-pkg \ --content-type application/json \ --source-identity ci:release-42 \ --content '{"release":"2026.05","commit":"abc123"}'Example: add build-info or SBOM metadata from a file or stdin
cloudsmith metadata add your-org/awesome-repo/better-pkg \ --content-type application/vnd.jfrog.buildinfo+json \ --source-identity ci:build-info \ --file buildinfo.json cloudsmith metadata add your-org/awesome-repo/better-pkg \ --content-type application/vnd.cyclonedx+json \ --source-identity ci:sbom \ --file sbom.json cat payload.json | cloudsmith metadata add your-org/awesome-repo/better-pkg \ --content-type application/json \ --file -Example: update an existing metadata entry
cloudsmith metadata update your-org/awesome-repo/better-pkg meta789 \ --content '{"release":"2026.05","commit":"def456"}'Updating only
--source-identityis also supported. Callingupdatewith no patchable fields fails fast:Example: remove a metadata entry
Use
-y/--yesto skip confirmation in scripts.Example: invalid JSON returns a usage error before calling the API
cloudsmith metadata add your-org/awesome-repo/better-pkg \ --content-type application/json \ --content '{not json'--fileand--contentare mutually exclusive; passing both also errors out before the API call.Example: JSON output
JSON mode emits the API payload (or, for
remove,{"deleted": true, "slug_perm": "..."}) so the commands compose cleanly withjqand other tooling.Type of Change
Additional Notes
CLI tests cover help text, list pagination and filters, JSON output, single-entry retrieval, inline/file/stdin content loading, invalid JSON handling, update argument validation, and remove confirmation behavior. The underlying v2 metadata API client has its own httpretty-backed test suite covering URL shape, auth header precedence, query-param normalisation, and 404/422 error surfacing.
Local checks and testing completed.