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>
| ... | ... |
@@ -178,7 +178,7 @@ func (is *imageSource) ResolveImageConfig(ctx context.Context, ref string, opt l |
| 178 | 178 |
case source.ResolveModePreferLocal: |
| 179 | 179 |
img, err := is.resolveLocal(ref) |
| 180 | 180 |
if err == nil {
|
| 181 |
- if img.Architecture != opt.Platform.Architecture || img.Variant != opt.Platform.Variant || img.OS != opt.Platform.OS {
|
|
| 181 |
+ if !platformMatches(img, opt.Platform) {
|
|
| 182 | 182 |
logrus.WithField("ref", ref).Debugf("Requested build platform %s does not match local image platform %s, checking remote",
|
| 183 | 183 |
path.Join(opt.Platform.OS, opt.Platform.Architecture, opt.Platform.Variant), |
| 184 | 184 |
path.Join(img.OS, img.Architecture, img.Variant), |
| ... | ... |
@@ -273,7 +273,7 @@ func (p *puller) resolveLocal() {
|
| 273 | 273 |
ref := p.src.Reference.String() |
| 274 | 274 |
img, err := p.is.resolveLocal(ref) |
| 275 | 275 |
if err == nil {
|
| 276 |
- if img.Architecture != p.platform.Architecture || img.Variant != p.platform.Variant || img.OS != p.platform.OS {
|
|
| 276 |
+ if !platformMatches(img, &p.platform) {
|
|
| 277 | 277 |
logrus.WithField("ref", ref).Debugf("Requested build platform %s does not match local image platform %s, not resolving",
|
| 278 | 278 |
path.Join(p.platform.OS, p.platform.Architecture, p.platform.Variant), |
| 279 | 279 |
path.Join(img.OS, img.Architecture, img.Variant), |
| ... | ... |
@@ -947,3 +947,13 @@ func ensureManifestRequested(ctx context.Context, res remotes.Resolver, ref stri |
| 947 | 947 |
res.Resolve(ctx, ref) |
| 948 | 948 |
} |
| 949 | 949 |
} |
| 950 |
+ |
|
| 951 |
+func platformMatches(img *image.Image, p *ocispec.Platform) bool {
|
|
| 952 |
+ if img.Architecture != p.Architecture {
|
|
| 953 |
+ return false |
|
| 954 |
+ } |
|
| 955 |
+ if img.Variant != "" && img.Variant != p.Variant {
|
|
| 956 |
+ return false |
|
| 957 |
+ } |
|
| 958 |
+ return img.OS == p.OS |
|
| 959 |
+} |