mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-03-30 22:48:28 +00:00
push release tags even when digest tag already is there (#4201)
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
@@ -555,18 +555,11 @@ func (p Pkg) Build(bos ...BuildOpt) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// we only will push if one of these is true:
|
// determine if we should skip pushing the default tag (no build and no local cache)
|
||||||
// - we had at least one platform to build
|
skipDefaultPush := false
|
||||||
// - we found an image in local cache
|
|
||||||
// if neither is true, there is nothing to push
|
|
||||||
|
|
||||||
if len(platformsToBuild) == 0 {
|
if len(platformsToBuild) == 0 {
|
||||||
// if we did not yet find the image in local cache,
|
// if we did not yet find the image in local cache, recheck
|
||||||
// check, in case we have it and would need to push.
|
|
||||||
// If we did not build it because we were not requested to do so,
|
|
||||||
// then we might not know we have it in local cache.
|
|
||||||
if !imageInLocalCache {
|
if !imageInLocalCache {
|
||||||
// we need this to know whether or not we might push
|
|
||||||
for _, platform := range bo.platforms {
|
for _, platform := range bo.platforms {
|
||||||
exists, err := c.ImageInCache(&ref, "", platform.Architecture)
|
exists, err := c.ImageInCache(&ref, "", platform.Architecture)
|
||||||
if err == nil && exists {
|
if err == nil && exists {
|
||||||
@@ -577,17 +570,22 @@ func (p Pkg) Build(bos ...BuildOpt) error {
|
|||||||
}
|
}
|
||||||
if !imageInLocalCache {
|
if !imageInLocalCache {
|
||||||
_, _ = fmt.Fprintf(writer, "No new platforms to push, skipping.\n")
|
_, _ = fmt.Fprintf(writer, "No new platforms to push, skipping.\n")
|
||||||
return nil
|
if bo.release == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
skipDefaultPush = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.dirty {
|
if p.dirty {
|
||||||
return fmt.Errorf("build complete, refusing to push dirty package")
|
return fmt.Errorf("build complete, refusing to push dirty package")
|
||||||
}
|
}
|
||||||
|
// push the manifest for the default tag if needed
|
||||||
// push the manifest
|
if !skipDefaultPush {
|
||||||
if err := c.Push(p.FullTag(), "", bo.manifest, true); err != nil {
|
if err := c.Push(p.FullTag(), "", bo.manifest, true); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_, _ = fmt.Fprintf(writer, "Skipping push of default tag %q\n", p.FullTag())
|
||||||
}
|
}
|
||||||
|
|
||||||
if bo.release == "" {
|
if bo.release == "" {
|
||||||
@@ -608,7 +606,8 @@ func (p Pkg) Build(bos ...BuildOpt) error {
|
|||||||
if err := c.DescriptorWrite(fullRelTag, *desc); err != nil {
|
if err := c.DescriptorWrite(fullRelTag, *desc); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := c.Push(fullRelTag, "", bo.manifest, true); err != nil {
|
// push the release tag without overriding existing (skip if already present)
|
||||||
|
if err := c.Push(fullRelTag, "", bo.manifest, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user