refactor(no-ticket): refactor metadata to shared util#292
Open
BartoszBlizniak wants to merge 1 commit into
Open
refactor(no-ticket): refactor metadata to shared util#292BartoszBlizniak wants to merge 1 commit into
BartoszBlizniak wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the cloudsmith metadata CLI command by extracting shared metadata content parsing/validation logic into a reusable module, with accompanying test updates and help-text/example tweaks.
Changes:
- Added
cli/metadata_common.pywith helpers to resolve/parse JSON metadata content and attach related options. - Updated
cli/commands/metadata.pyto use the new shared helpers and refreshed help text/output strings. - Added/updated tests to cover the new helpers and ensure
metadatacommand behavior around non-object JSON content.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| cloudsmith_cli/cli/metadata_common.py | New shared helpers for resolving/parsing metadata JSON and attaching option defaults. |
| cloudsmith_cli/cli/commands/metadata.py | Refactor to use shared helpers; adjusts help text and user-facing messages. |
| cloudsmith_cli/cli/tests/test_metadata_common.py | New unit tests for the shared metadata helper module. |
| cloudsmith_cli/cli/tests/commands/test_metadata.py | Updates help-text assertions and adds command-level tests for rejecting non-object JSON. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6 tasks
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
Extracts the JSON-content resolution and source-identity defaulting logic out of
cloudsmith metadatainto a new shared module,cloudsmith_cli/cli/metadata_common.py, so push-time metadata flags (follow-up PR).No behavior change for
cloudsmith metadata— same flags, same errors, same output.Type of Change
Additional Notes
What moved into
cli/metadata_common.pyResolvedMetadatadataclass — carries parsed content plus source labels through the command.resolve_metadata_content(...)— enforces XOR between--fileand--content, reads stdin/file/inline, parses JSON, validates it is an object. Replaces the private_load_contentincli/commands/metadata.py.require_metadata_content_type(...)— guards the--content-typerequirement when content is supplied.attach_metadata_options(...)— folds content type and source identity onto a resolved payload.default_metadata_source_identity()— replaces the private_default_source_identity(wascloudsmith-cli@<version>).source_label_for(...)— human-readable label forstdin/ filename /inline.MetadataContentError—ClickExceptionsubclass that carriessource_labelso callers can render structured error context.Verification
pytest cloudsmith_cli/cli/tests/test_metadata_common.py cloudsmith_cli/cli/tests/commands/test_metadata.py— green.pre-commit run -a— clean.cloudsmith metadata add/update/list/removeagainst a test repo, both--fileand--contentpaths, with valid + invalid JSON.