You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
squash! copy: add option to strip sparse manifest lists
copy: implement code review feedback for sparse manifest stripping
Address feedback from mtrmac's review on PR podman-container-tools#655:
1. Simplify deletion logic by combining EditInstances calls
- Moved deletion tracking into prepareInstanceCopies function
- Combined update and delete operations into single EditInstances call
- Removed separate digest-based tracking and redundant loops
2. Use slices.Delete for manifest entry removal
- Replaced manual slice manipulation with slices.Delete in both
docker_schema2_list.go and oci_index.go for cleaner code
3. Integrate deletion tests into existing test methods
- Removed standalone TestListDeleteInstances function
- Added deletion test cases to TestSchema2ListEditInstances and
TestOCI1EditInstances for better test organization
4. Move deletion logic into prepareInstanceCopies (most critical fix)
- Modified prepareInstanceCopies to return ([]instanceCopy, []int, error)
- Track indices to delete when SparseManifestListAction == StripSparseManifestList
- Properly handles duplicate digests by using instance indices instead
of digest-based lookup, fixing edge case where same digest appears
multiple times in manifest list
5. Use slices.Backward for reverse iteration
- Simplified deletion loop using slices.Backward iterator
- Maintains high-to-low deletion order to avoid index shifting
6. Move SparseManifestListAction field for better organization
- Relocated field from line 150 to line 116 in copy.go
- Now positioned near related ImageListSelection and Instances fields
- Improves logical grouping of manifest list options
All tests pass. The implementation now correctly handles:
- Duplicate digests in manifest lists
- Single EditInstances call for efficiency
- Cleaner separation of concerns
- Better code organization
Fixes feedback on podman-container-tools#655
Signed-off-by: Alex Guidi <aguidi@redhat.com>
Copy file name to clipboardExpand all lines: image/copy/copy.go
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -111,6 +111,9 @@ type Options struct {
111
111
ForceManifestMIMETypestring
112
112
ImageListSelectionImageListSelection// set to either CopySystemImage (the default), CopyAllImages, or CopySpecificImages to control which instances we copy when the source reference is a list; ignored if the source reference is not a list
113
113
Instances []digest.Digest// if ImageListSelection is CopySpecificImages, copy only these instances and the list itself
114
+
// When only a subset of images of a list is copied, this action indicates if the manifest should be kept or stripped.
115
+
// See CopySpecificImages.
116
+
SparseManifestListActionSparseManifestListAction
114
117
// Give priority to pulling gzip images if multiple images are present when configured to OptionalBoolTrue,
115
118
// prefers the best compression if this is configured as OptionalBoolFalse. Choose automatically (and the choice may change over time)
116
119
// if this is set to OptionalBoolUndefined (which is the default behavior, and recommended for most callers).
@@ -145,10 +148,6 @@ type Options struct {
145
148
// to not indicate "nondistributable".
146
149
DownloadForeignLayersbool
147
150
148
-
// When only a subset of images of a list is copied, this action indicates if the manifest should be kept or stripped.
149
-
// See CopySpecificImages.
150
-
SparseManifestListActionSparseManifestListAction
151
-
152
151
// Contains slice of OptionCompressionVariant, where copy will ensure that for each platform
153
152
// in the manifest list, a variant with the requested compression will exist.
154
153
// Invalid when copying a non-multi-architecture image. That will probably
0 commit comments