Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds tag filtering capability to the cloudsmith download command, enabling users to filter packages by tags alongside existing filters (version, format, architecture, OS). The implementation treats various package metadata fields as "tags" beyond just the explicit tags field.
Key Changes:
- Added
--tagoption to the download command with support for filtering by actual tags, format, architecture, distribution, and components - Enhanced package resolution logic with the new
_matches_tag_filter()helper function - Updated documentation with comprehensive download command examples
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| cloudsmith_cli/core/download.py | Added _matches_tag_filter() function and integrated tag filtering into resolve_package() |
| cloudsmith_cli/cli/commands/download.py | Added --tag CLI option and updated command documentation with tag filtering example |
| cloudsmith_cli/core/tests/test_download.py | Added unit test covering tag filtering for actual tags, format, architecture, and distro fields |
| README.md | Added download command to features list and created new "Downloading Packages" section with examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
b5cf8ac to
628c873
Compare
BartoszBlizniak
left a comment
There was a problem hiding this comment.
Overall looks good - Got a few questions:
- I can see we're starting to use a lot of "filters" for the download command. All of these are essentially being passed to the query parameter for listing packages. From code maintenance and usability, perhaps adding
package_queryinstead of filters could allow for a better user experience (see package list command). -> This would require some re-working as it would be a breaking change, removing the filters (Future PR). - Integration test for the tag appears to be missing (you have core tests ✅)
- The
--tag,--osand--archappear to be case sensitive, while--nameisn't, should this be the case (no pun intended 😄)?
| if isinstance(tag_category, list) and tag_filter in tag_category: | ||
| return True | ||
|
|
||
| # Check other metadata fields that appear as tags in the UI (case-sensitive) |
There was a problem hiding this comment.
Might be worthwhile double-checking if Cloudsmith Tags are actually case-sensitive in the API
There was a problem hiding this comment.
They are. Just retested by adding some and the API returned:
"tags": { "info": [ "RANJAN", "RanJan", "Ranjan", "trivy", "upstream" ] }
|
Thanks @BartoszBlizniak
|
| if ( | ||
| pkg.get("format") == tag_filter | ||
| or any(arch.get("name") == tag_filter for arch in pkg.get("architectures", [])) | ||
| or pkg.get("identifiers", {}).get("deb_component") == tag_filter | ||
| ): | ||
| return True | ||
|
|
||
| # Check distro-related fields | ||
| distro_name_raw = pkg.get("distro", {}).get("name") | ||
| distro_version_raw = pkg.get("distro_version", {}).get("name") | ||
| distro_combo = "" | ||
| if distro_name_raw and distro_version_raw: | ||
| # Only build combined tag when both parts are present | ||
| distro_combo = f"{distro_name_raw}/{distro_version_raw}" | ||
|
|
||
| if ( | ||
| tag_filter == distro_name_raw | ||
| or tag_filter == distro_version_raw | ||
| or (distro_combo and tag_filter == distro_combo) | ||
| ): | ||
| return True |
There was a problem hiding this comment.
question: Any reason why this is also checking format, arch and distro-related things for what's only supposed to be a tag filter? Why should the user use this instead of the other existing flags for these use cases?
There was a problem hiding this comment.
Great question! The reason I included format, arch, and distro fields in the tag filter is that Cloudsmith UI presents all of these as “tags” on the package details page. I wanted the --tag option to feel familiar and work the same way users see and interact with tags in the UI, even though, technically, some of those are metadata fields.
I agree it might be clearer and more consistent to have --tag only match actual tags, and require users to use --format, --arch, etc. for the other filters. I’m happy to update the implementation to do that if that feels like a better approach, just let me know your preference!
Summary
This PR adds tag filtering capability to the
cloudsmith downloadcommand and updates the README with comprehensive download command documentation.Changes Made
🚀 New Feature: --tag Option
--tagoption tocloudsmith downloadcommand for filtering packages by tagsresolve_package()function to support tag filtering across multiple metadata fields:📚 Documentation Updates
downloadcommand to README features list--tagfeatureUsage Examples
Testing
test_resolve_package_with_tag_filtervalidates tag filteringBreaking Changes
None - this is a backward-compatible feature addition.