mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
Merge pull request #3787 from deitch/skip-build-if-no-platforms
This commit is contained in:
commit
b56a0df58d
22
src/cmd/linuxkit/cache/push.go
vendored
22
src/cmd/linuxkit/cache/push.go
vendored
@ -29,16 +29,38 @@ func (p *Provider) Push(name string) error {
|
||||
return err
|
||||
}
|
||||
options = append(options, remote.WithAuthFromKeychain(authn.DefaultKeychain))
|
||||
|
||||
img, err1 := root.Image()
|
||||
ii, err2 := root.ImageIndex()
|
||||
// before we even try to push, let us see if it exists remotely
|
||||
remoteOptions := []remote.Option{remote.WithAuthFromKeychain(authn.DefaultKeychain)}
|
||||
|
||||
switch {
|
||||
case err1 == nil:
|
||||
dig, err := img.Digest()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not get digest for image %s: %v", name, err)
|
||||
}
|
||||
desc, err := remote.Get(ref, remoteOptions...)
|
||||
if err == nil && desc != nil && dig == desc.Digest {
|
||||
fmt.Printf("%s image already available on remote registry, skipping push", name)
|
||||
return nil
|
||||
}
|
||||
log.Debugf("pushing image %s", name)
|
||||
if err := remote.Write(ref, img, options...); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Pushed image %s\n", name)
|
||||
case err2 == nil:
|
||||
dig, err := ii.Digest()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not get digest for index %s: %v", name, err)
|
||||
}
|
||||
desc, err := remote.Get(ref, remoteOptions...)
|
||||
if err == nil && desc != nil && dig == desc.Digest {
|
||||
fmt.Printf("%s index already available on remote registry, skipping push", name)
|
||||
return nil
|
||||
}
|
||||
log.Debugf("pushing index %s", name)
|
||||
// this is an index, so we not only want to write the index, but tags for each arch-specific image in it
|
||||
if err := remote.WriteIndex(ref, ii, options...); err != nil {
|
||||
|
@ -158,6 +158,14 @@ func pkgBuildPush(args []string, withPush bool) {
|
||||
pkgPlats = append(pkgPlats, imagespec.Platform{OS: "linux", Architecture: a})
|
||||
}
|
||||
}
|
||||
|
||||
// if there are no platforms to build for, do nothing.
|
||||
// note that this is *not* an error; we simply skip it
|
||||
if len(pkgPlats) == 0 {
|
||||
fmt.Printf("Skipping %s with no architectures to build\n", p.Tag())
|
||||
return
|
||||
}
|
||||
|
||||
pkgOpts = append(pkgOpts, pkglib.WithBuildPlatforms(pkgPlats...))
|
||||
|
||||
var msg, action string
|
||||
|
Loading…
Reference in New Issue
Block a user