copy: add InstancePlatforms field for platform-based filtering#656
Conversation
|
Packit jobs failed. @containers/packit-build please check. |
1 similar comment
|
Packit jobs failed. @containers/packit-build please check. |
mtrmac
left a comment
There was a problem hiding this comment.
Thanks!
An extremely brief look for now.
|
I've approved this and restarted a couple of failng tests. I'd be interested in seeing your reply to @mtrmac 's comment on the multi-compression images. Overall, a nice change, thanks! |
|
LGTM |
|
#656 (comment) still needs addressing. |
mtrmac
left a comment
There was a problem hiding this comment.
ACK to the implementation.
Please rebase, I think that should fix the Skopeo test failures.
8dd19fb to
630a079
Compare
mtrmac
left a comment
There was a problem hiding this comment.
Thanks!
LGTM; please squash to avoid the "address review feedback" commit messages.
Add the ability to select images by platform name instead of requiring
digest hashes when copying specific images from multi-architecture
manifest lists.
When copying specific images using CopySpecificImages mode, users
previously had to specify exact digest hashes in the Instances field.
This was cumbersome and error-prone because users must manually look up
digest values and can easily confuse which digest corresponds to which
platform. Most users think in terms of "linux/amd64" or "linux/arm64",
not "sha256:abc123...".
This commit introduces a new InstancePlatforms field that allows users
to specify platforms by human-readable OS and Architecture combinations.
The field works alongside the existing Instances field, enabling both
digest-based and platform-based selection to be used together.
Key features:
- New InstancePlatformFilter type with OS and Architecture fields
- InstancePlatforms []InstancePlatformFilter field in Options struct
- determineSpecificImages() function resolves platforms to digests and
combines with digest-based selection using efficient Set-based lookup
- Copies ALL instances matching the specified OS/Architecture, including
all compression variants and other variations
- Fully backward compatible - existing Instances field continues to work
- Clear error messages when requested platform doesn't exist
Example usage:
options := ©.Options{
ImageListSelection: copy.CopySpecificImages,
InstancePlatforms: []copy.InstancePlatformFilter{
{OS: "linux", Architecture: "amd64"},
{OS: "linux", Architecture: "arm64"},
},
}
Based on original work by @nalind in containers/image#1938.
Relates to containers#227
Signed-off-by: Alex Guidi <aguidi@redhat.com>
2c20778 to
af517b0
Compare
All commits squashed as requested. Please let me know if there is something pending before merging this PR. |
Add platform-based filtering for copying specific images
This PR adds the ability to select images by platform name (e.g.,
linux/amd64) instead of requiring digest hashes, implementing the functionality proposed in containers/image#1938.Motivation
Relates to #227
When copying specific images from a multi-architecture manifest list, the current
CopySpecificImagesmode requires users to specify exact digest hashes in theInstancesfield. This is cumbersome because:This PR adds a new
InstancePlatformsfield that allows users to specify platforms by human-readable OS and Architecture names.Changes
1. New
InstancePlatformFiltertype andInstancePlatformsfieldInstancePlatformFilterstruct withOSandArchitecturefieldsInstancePlatforms []InstancePlatformFilterfield toOptionsstruct{OS: "linux", Architecture: "amd64"}Instancesfield (both can be used simultaneously)2. Platform resolution in
determineSpecificImages()no instances found for platform OS/Architecture)3. Efficient Set-based filtering
slices.Contains()to Set-based lookupset.NewWithValues()for convenient initialization4. Comprehensive test coverage
TestDetermineSpecificImageswith table-driven testsUser Experience Improvement
Before (digest-based only):
After (platform-based):
Combined (both methods):
Multi-Compression Support
When a platform is specified, ALL instances matching that OS/Architecture are copied, including:
This ensures that users get complete platform coverage without needing to understand the internal compression details.
API Design
The
InstancePlatformFiltertype only exposesOSandArchitecturefields, making it impossible to set unsupported fields (like Variant) at compile time. This is safer than runtime validation and provides a clearer API.Testing
All existing tests pass. New tests verify:
Compatibility
Instancesfield continues to work unchangedCredits
This implementation is based on the original work by @nalind in containers/image#1938, adapted for the container-libs monorepo structure.