You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by jp...@apache.org on 2022/05/17 07:32:57 UTC

[camel-k] branch main updated: Fix #3271: Prepend Organization/Namespace in HTTP path when uploading to the image registry from the command line

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 85bda438f Fix #3271: Prepend Organization/Namespace in HTTP path when uploading to the image registry from the command line
85bda438f is described below

commit 85bda438f08952b9135887aa06232f579957366d
Author: John Poth <po...@gmail.com>
AuthorDate: Mon May 16 15:08:32 2022 +0200

    Fix #3271: Prepend Organization/Namespace in HTTP path when uploading to the image registry from the command line
---
 pkg/cmd/run.go        |  8 ++++----
 pkg/trait/registry.go | 10 ++++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 3c560f8c9..718cf5884 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -1109,11 +1109,11 @@ func getArtifactHTTPPath(dependency maven.Dependency, platform *v1.IntegrationPl
 	// Some vendors don't allow '/' or '.' in repository name so let's replace them with '_'
 	artifactHTTPPath = strings.ReplaceAll(artifactHTTPPath, "/", "_")
 	artifactHTTPPath = strings.ReplaceAll(artifactHTTPPath, ".", "_")
-	if platform.Spec.Cluster == v1.IntegrationPlatformClusterOpenShift {
-		// image must be uploaded in the namespace
-		artifactHTTPPath = fmt.Sprintf("%s/%s", ns, artifactHTTPPath)
+	organization := platform.Spec.Build.Registry.Organization
+	if organization == "" {
+		organization = ns
 	}
-	return artifactHTTPPath
+	return fmt.Sprintf("%s/%s", organization, artifactHTTPPath)
 }
 
 func createDefaultGav(path string, dirName string, integrationName string) (maven.Dependency, error) {
diff --git a/pkg/trait/registry.go b/pkg/trait/registry.go
index 9e6070ac5..b1f47741e 100644
--- a/pkg/trait/registry.go
+++ b/pkg/trait/registry.go
@@ -103,14 +103,16 @@ func (t *registryTrait) Apply(e *Environment) error {
 		}
 		build.Maven.Servers = append(build.Maven.Servers, server)
 	}
-	addRegistryAndExtensionToMaven(registryAddress, build, e.Platform.Status.Cluster, e.Platform.Namespace)
+	addRegistryAndExtensionToMaven(registryAddress, build, e.Platform)
 	return nil
 }
 
-func addRegistryAndExtensionToMaven(registryAddress string, build *v1.BuilderTask, clusterType v1.IntegrationPlatformCluster, ns string) {
-	if clusterType == v1.IntegrationPlatformClusterOpenShift {
-		registryAddress = fmt.Sprintf("%s/%s", registryAddress, ns)
+func addRegistryAndExtensionToMaven(registryAddress string, build *v1.BuilderTask, platform *v1.IntegrationPlatform) {
+	organization := platform.Spec.Build.Registry.Organization
+	if organization == "" {
+		organization = platform.Namespace
 	}
+	registryAddress = fmt.Sprintf("%s/%s", registryAddress, organization)
 	ext := v1.MavenArtifact{
 		GroupID:    "com.github.johnpoth",
 		ArtifactID: "wagon-docker-registry",