This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 15f6d0ed90b09bbfd814d6e05dbe3044e176f215
Author: Nicola Ferraro <[email protected]>
AuthorDate: Fri Feb 28 00:10:38 2020 +0100

    Fix #1305: fix case of transitive equality between images
---
 pkg/builder/spectrum/publisher.go | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/pkg/builder/spectrum/publisher.go 
b/pkg/builder/spectrum/publisher.go
index 4aaf59c..5b834f7 100644
--- a/pkg/builder/spectrum/publisher.go
+++ b/pkg/builder/spectrum/publisher.go
@@ -19,14 +19,28 @@ package spectrum
 
 import (
        "fmt"
+       "os"
        "path"
 
        "github.com/apache/camel-k/pkg/builder"
        "github.com/apache/camel-k/pkg/platform"
+       "github.com/apache/camel-k/pkg/util/log"
        spectrum "github.com/container-tools/spectrum/pkg/builder"
 )
 
 func publisher(ctx *builder.Context) error {
+       libraryPath := path.Join(ctx.Path, "context", "dependencies")
+       _, err := os.Stat(libraryPath)
+       if err != nil && os.IsNotExist(err) {
+               // this can only indicate that there are no more libraries to 
add to the base image,
+               // because transitive resolution is the same even if spec 
differs
+               log.Infof("No new image to build, reusing existing image %s", 
ctx.BaseImage)
+               ctx.Image = ctx.BaseImage
+               return nil
+       } else if err != nil {
+               return err
+       }
+
        pl, err := platform.GetCurrentPlatform(ctx.C, ctx, ctx.Namespace)
        if err != nil {
                return err
@@ -57,7 +71,7 @@ func publisher(ctx *builder.Context) error {
                PushInsecure: pl.Status.Build.Registry.Insecure,
        }
 
-       digest, err := spectrum.Build(options, path.Join(ctx.Path, "context", 
"dependencies")+":/deployments/dependencies")
+       digest, err := spectrum.Build(options, 
libraryPath+":/deployments/dependencies")
        if err != nil {
                return err
        }

Reply via email to