mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Only check variant if set on image.
This fixes an edge case where some images may not have a variant set just because it didn't used to get set. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
238887ef06
commit
fe2aca0e39
1 changed files with 12 additions and 2 deletions
|
@ -178,7 +178,7 @@ func (is *imageSource) ResolveImageConfig(ctx context.Context, ref string, opt l
|
|||
case source.ResolveModePreferLocal:
|
||||
img, err := is.resolveLocal(ref)
|
||||
if err == nil {
|
||||
if img.Architecture != opt.Platform.Architecture || img.Variant != opt.Platform.Variant || img.OS != opt.Platform.OS {
|
||||
if !platformMatches(img, opt.Platform) {
|
||||
logrus.WithField("ref", ref).Debugf("Requested build platform %s does not match local image platform %s, checking remote",
|
||||
path.Join(opt.Platform.OS, opt.Platform.Architecture, opt.Platform.Variant),
|
||||
path.Join(img.OS, img.Architecture, img.Variant),
|
||||
|
@ -273,7 +273,7 @@ func (p *puller) resolveLocal() {
|
|||
ref := p.src.Reference.String()
|
||||
img, err := p.is.resolveLocal(ref)
|
||||
if err == nil {
|
||||
if img.Architecture != p.platform.Architecture || img.Variant != p.platform.Variant || img.OS != p.platform.OS {
|
||||
if !platformMatches(img, &p.platform) {
|
||||
logrus.WithField("ref", ref).Debugf("Requested build platform %s does not match local image platform %s, not resolving",
|
||||
path.Join(p.platform.OS, p.platform.Architecture, p.platform.Variant),
|
||||
path.Join(img.OS, img.Architecture, img.Variant),
|
||||
|
@ -947,3 +947,13 @@ func ensureManifestRequested(ctx context.Context, res remotes.Resolver, ref stri
|
|||
res.Resolve(ctx, ref)
|
||||
}
|
||||
}
|
||||
|
||||
func platformMatches(img *image.Image, p *ocispec.Platform) bool {
|
||||
if img.Architecture != p.Architecture {
|
||||
return false
|
||||
}
|
||||
if img.Variant != "" && img.Variant != p.Variant {
|
||||
return false
|
||||
}
|
||||
return img.OS == p.OS
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue