Refactor platforms.Only with a "platformVector" helper
This improves the hard-coded list of ARM fallbacks in the `platform.Only` implementation (by doing a descending loop over variant numbers instead, which is all the hard-coded list was doing). Making this a separate function can then more easily be recursive later for handling an `arm64`->`arm` fallback (or similar), but I think it makes the code a lot more clear too (so we're calculating a vector of platforms separately from building a matcher object). This also makes a minor adjustment in `TestImagePullWithDistSourceLabel` which had an implicit assumption that `platforms.Only` would only ever result in a single suitable manifest, which isn't strictly true (and is likely failing as-is when run on any 32bit `arm` system that's `v6` or higher, which this fixes 😅). Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
This commit is contained in:
@@ -113,7 +113,7 @@ func TestImagePullWithDistSourceLabel(t *testing.T) {
|
||||
key := fmt.Sprintf("containerd.io/distribution.source.%s", source)
|
||||
|
||||
// only check the target platform
|
||||
childrenHandler := images.FilterPlatforms(images.ChildrenHandler(cs), pMatcher)
|
||||
childrenHandler := images.LimitManifests(images.ChildrenHandler(cs), pMatcher, 1)
|
||||
|
||||
checkLabelHandler := func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
|
||||
children, err := childrenHandler(ctx, desc)
|
||||
|
||||
Reference in New Issue
Block a user