Browse code

builder: fix platform passing in image adapter

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2019/03/16 11:07:41
Showing 1 changed files
... ...
@@ -381,6 +381,7 @@ func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) {
381 381
 		return nil, err
382 382
 	}
383 383
 
384
+	platform := platforms.Only(p.platform)
384 385
 	var (
385 386
 		schema1Converter *schema1.Converter
386 387
 		handlers         []images.Handler
... ...
@@ -413,7 +414,9 @@ func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) {
413 413
 		// Set any children labels for that content
414 414
 		childrenHandler = images.SetChildrenLabels(p.is.ContentStore, childrenHandler)
415 415
 		// Filter the children by the platform
416
-		childrenHandler = images.FilterPlatforms(childrenHandler, platforms.Default())
416
+		childrenHandler = images.FilterPlatforms(childrenHandler, platform)
417
+		// Limit manifests pulled to the best match in an index
418
+		childrenHandler = images.LimitManifests(childrenHandler, platform, 1)
417 419
 
418 420
 		handlers = append(handlers,
419 421
 			remotes.FetchHandler(p.is.ContentStore, fetcher),
... ...
@@ -434,12 +437,12 @@ func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) {
434 434
 		}
435 435
 	}
436 436
 
437
-	mfst, err := images.Manifest(ctx, p.is.ContentStore, p.desc, platforms.Default())
437
+	mfst, err := images.Manifest(ctx, p.is.ContentStore, p.desc, platform)
438 438
 	if err != nil {
439 439
 		return nil, err
440 440
 	}
441 441
 
442
-	config, err := images.Config(ctx, p.is.ContentStore, p.desc, platforms.Default())
442
+	config, err := images.Config(ctx, p.is.ContentStore, p.desc, platform)
443 443
 	if err != nil {
444 444
 		return nil, err
445 445
 	}