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

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

commit a114bebb93df43e4c8300eb2778907f2398a9e9b
Author: nferraro <ni.ferr...@gmail.com>
AuthorDate: Fri Jan 11 12:15:45 2019 +0100

    Fix #312: add more testcases and catalog guard
---
 pkg/platform/images/images.go      | 12 +++++++++++-
 pkg/platform/images/images_test.go | 10 ++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/pkg/platform/images/images.go b/pkg/platform/images/images.go
index ab98a21..da65856 100644
--- a/pkg/platform/images/images.go
+++ b/pkg/platform/images/images.go
@@ -19,6 +19,7 @@ package images
 
 import (
        "fmt"
+       "github.com/apache/camel-k/pkg/util/camel"
        "strings"
 
        "github.com/apache/camel-k/version"
@@ -71,8 +72,10 @@ func LookupPredefinedImage(dependencies []string) string {
        if !strings.HasPrefix(otherDep, camelPrefix) {
                return ""
        }
-
        comp := strings.TrimPrefix(otherDep, camelPrefix)
+       if !isInCamelCatalog(comp) {
+               return ""
+       }
        return PredefinedImageNameFor(comp)
 }
 
@@ -80,3 +83,10 @@ func LookupPredefinedImage(dependencies []string) string {
 func PredefinedImageNameFor(comp string) string {
        return fmt.Sprintf("%s/%s%s:%s", BaseRepository, ImagePrefix, comp, 
version.Version)
 }
+
+func isInCamelCatalog(comp string) bool {
+       if _, ok := camel.Runtime.Artifacts["camel-" + comp]; ok {
+               return true
+       }
+       return false
+}
diff --git a/pkg/platform/images/images_test.go 
b/pkg/platform/images/images_test.go
index 027bf39..5a64b87 100644
--- a/pkg/platform/images/images_test.go
+++ b/pkg/platform/images/images_test.go
@@ -41,6 +41,13 @@ func TestImageLookup(t *testing.T) {
                        image:        BaseRepository + "/" + ImagePrefix + 
"telegram:" + version.Version,
                },
                {
+                       dependencies: []string{"camel:telegram", 
"camel-k:knative"},
+                       image:        BaseRepository + "/" + ImagePrefix + 
"telegram:" + version.Version,
+               },
+               {
+                       dependencies: []string{"camel:telegram", "camel:core", 
"camel-k:knative", "camel:dropbox"},
+               },
+               {
                        dependencies: []string{"camel:core", "camel-k:knative"},
                        image:        BaseRepository + "/" + ImagePrefix + 
"core:" + version.Version,
                },
@@ -58,6 +65,9 @@ func TestImageLookup(t *testing.T) {
                {
                        dependencies: []string{"camel:dropbox", "camel:core", 
"camel-k:knative", "runtime:jvm", "runtime:groovy"},
                },
+               {
+                       dependencies: []string{"camel:cippalippa", 
"camel:core", "camel-k:knative"},
+               },
        }
 
        for i, tc := range cases {

Reply via email to