You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/01/13 14:47:17 UTC

[camel-k] 03/09: Fix #312: add a none context to avoid creating any if needed

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 ac316852c15259719c3aa5d297bfa62aa77c8d5b
Author: nferraro <ni...@gmail.com>
AuthorDate: Thu Jan 10 16:16:20 2019 +0100

    Fix #312: add a none context to avoid creating any if needed
---
 pkg/controller/integrationplatform/create.go | 15 +++++++++++----
 pkg/platform/resources.go                    |  3 +++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/pkg/controller/integrationplatform/create.go b/pkg/controller/integrationplatform/create.go
index fa203c2..fd2ddec 100644
--- a/pkg/controller/integrationplatform/create.go
+++ b/pkg/controller/integrationplatform/create.go
@@ -51,6 +51,11 @@ func (action *createAction) Handle(ctx context.Context, platform *v1alpha1.Integ
 		res := make([]string, 0, l)
 
 		for _, c := range platform.Spec.Resources.Contexts {
+			if c == p.NoContext {
+				// Signals nothing to install
+				continue
+			}
+
 			//
 			// Assuming that if the resource ends with a yaml extension, the full
 			// resource name is provided
@@ -62,10 +67,12 @@ func (action *createAction) Handle(ctx context.Context, platform *v1alpha1.Integ
 			res = append(res, c)
 		}
 
-		logrus.Info("Installing custom platform resources")
-		err := install.Resources(ctx, action.client, platform.Namespace, res...)
-		if err != nil {
-			return err
+		if len(res) > 0 {
+			logrus.Info("Installing custom platform resources")
+			err := install.Resources(ctx, action.client, platform.Namespace, res...)
+			if err != nil {
+				return err
+			}
 		}
 	} else {
 		logrus.Info("Installing default platform resources")
diff --git a/pkg/platform/resources.go b/pkg/platform/resources.go
index 292776f..a0b208b 100644
--- a/pkg/platform/resources.go
+++ b/pkg/platform/resources.go
@@ -32,6 +32,9 @@ var KnativeContexts = []string{
 	"platform-integration-context-knative.yaml",
 }
 
+// NoContext is a placeholder for a not-present context
+const NoContext = "none"
+
 // GetContexts --
 func GetContexts() []string {
 	return append(DefaultContexts, KnativeContexts...)