You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2021/03/03 12:56:35 UTC

[camel-k] 03/08: Fix #1799: get and create the catalog in the platform namespace only

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

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

commit 1ce737029c72ac8764ffebef001212c254966794
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Fri Feb 19 12:36:13 2021 +0100

    Fix #1799: get and create the catalog in the platform namespace only
---
 pkg/trait/camel.go       |  4 ++--
 pkg/trait/trait_types.go | 16 +++++++++-------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go
index fc8fba2..8a82430 100644
--- a/pkg/trait/camel.go
+++ b/pkg/trait/camel.go
@@ -76,7 +76,7 @@ func (t *camelTrait) Apply(e *Environment) error {
 }
 
 func (t *camelTrait) loadOrCreateCatalog(e *Environment, runtimeVersion string) error {
-	ns := e.DetermineNamespace()
+	ns := e.DetermineCatalogNamespace()
 	if ns == "" {
 		return errors.New("unable to determine namespace")
 	}
@@ -96,7 +96,7 @@ func (t *camelTrait) loadOrCreateCatalog(e *Environment, runtimeVersion string)
 		// the required versions (camel and runtime) are not expressed as
 		// semver constraints
 		if exactVersionRegexp.MatchString(runtimeVersion) {
-			catalog, err = camel.GenerateCatalog(e.C, e.Client, e.Platform.Namespace, e.Platform.Status.Build.Maven, runtime, []maven.Dependency{})
+			catalog, err = camel.GenerateCatalog(e.C, e.Client, ns, e.Platform.Status.Build.Maven, runtime, []maven.Dependency{})
 			if err != nil {
 				return err
 			}
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index 5b360d0..a44930b 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -341,18 +341,20 @@ func (e *Environment) GetIntegrationPodSpec() *corev1.PodSpec {
 	return nil
 }
 
-// DetermineNamespace --
-func (e *Environment) DetermineNamespace() string {
-	if e.Integration != nil && e.Integration.Namespace != "" {
-		return e.Integration.Namespace
+// DetermineCatalogNamespace --
+func (e *Environment) DetermineCatalogNamespace() string {
+	if e.Integration != nil && e.Integration.Status.PlatformNamespace != "" {
+		return e.Integration.Status.PlatformNamespace
+	}
+	if e.Platform != nil && e.Platform.Namespace != "" {
+		return e.Platform.Namespace
 	}
 	if e.IntegrationKit != nil && e.IntegrationKit.Namespace != "" {
 		return e.IntegrationKit.Namespace
 	}
-	if e.Platform != nil && e.Platform.Namespace != "" {
-		return e.Platform.Namespace
+	if e.Integration != nil && e.Integration.Namespace != "" {
+		return e.Integration.Namespace
 	}
-
 	return ""
 }