mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-23 11:00:25 +00:00
Merge pull request #3967 from deitch/build-after-pull-if-missing
when pulling image to cache, if it is missing target arch, indicate an error
This commit is contained in:
commit
3a0405298a
18
src/cmd/linuxkit/cache/write.go
vendored
18
src/cmd/linuxkit/cache/write.go
vendored
@ -83,7 +83,23 @@ func (p *Provider) ImagePull(ref *reference.Spec, trustedRef, architecture strin
|
|||||||
// first attempt as an index
|
// first attempt as an index
|
||||||
ii, err := desc.ImageIndex()
|
ii, err := desc.ImageIndex()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Debugf("ImageWrite retrieved %s is index, saving", pullImageName)
|
log.Debugf("ImageWrite retrieved %s is index, saving, first checking if it contains target arch %s", pullImageName, architecture)
|
||||||
|
im, err := ii.IndexManifest()
|
||||||
|
if err != nil {
|
||||||
|
return ImageSource{}, fmt.Errorf("unable to get IndexManifest: %v", err)
|
||||||
|
}
|
||||||
|
// only useful if it contains our architecture
|
||||||
|
var foundArch bool
|
||||||
|
for _, m := range im.Manifests {
|
||||||
|
if m.MediaType.IsImage() && m.Platform != nil && m.Platform.Architecture == architecture && m.Platform.OS == linux {
|
||||||
|
foundArch = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !foundArch {
|
||||||
|
return ImageSource{}, fmt.Errorf("index %s does not contain target architecture %s", pullImageName, architecture)
|
||||||
|
}
|
||||||
|
|
||||||
if err := p.cache.WriteIndex(ii); err != nil {
|
if err := p.cache.WriteIndex(ii); err != nil {
|
||||||
return ImageSource{}, fmt.Errorf("unable to write index: %v", err)
|
return ImageSource{}, fmt.Errorf("unable to write index: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user