From 61293a9c5d87b207c763913612366b76f033585e Mon Sep 17 00:00:00 2001 From: Thomas Michael Date: Mon, 15 Dec 2025 10:12:09 +0100 Subject: [PATCH] namespace creation for jenkins, only if internal --- .../cloudogu/gitops/features/Jenkins.groovy | 4 +++ .../cloudogu/gitops/ApplicationTest.groovy | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/main/groovy/com/cloudogu/gitops/features/Jenkins.groovy b/src/main/groovy/com/cloudogu/gitops/features/Jenkins.groovy index 136224fe1..4b2b8f97a 100644 --- a/src/main/groovy/com/cloudogu/gitops/features/Jenkins.groovy +++ b/src/main/groovy/com/cloudogu/gitops/features/Jenkins.groovy @@ -296,4 +296,8 @@ class Jenkins extends Feature { ] ] } + @Override + String getActiveNamespaceFromFeature() { + return isEnabled() && config?.jenkins?.internal ? getNamespace() : null + } } \ No newline at end of file diff --git a/src/test/groovy/com/cloudogu/gitops/ApplicationTest.groovy b/src/test/groovy/com/cloudogu/gitops/ApplicationTest.groovy index 70b7ffd69..46d44f469 100644 --- a/src/test/groovy/com/cloudogu/gitops/ApplicationTest.groovy +++ b/src/test/groovy/com/cloudogu/gitops/ApplicationTest.groovy @@ -1,6 +1,7 @@ package com.cloudogu.gitops import com.cloudogu.gitops.config.Config +import com.cloudogu.gitops.features.git.config.ScmTenantSchema import io.micronaut.context.ApplicationContext import org.junit.jupiter.api.Test @@ -103,4 +104,35 @@ class ApplicationTest { application.setNamespaceListToConfig(config) // No exception == happy } + @Test + void 'get active namespaces correctly in Openshift if jenkins and scm are external'() { + config.registry.active = true + config.jenkins.active = true + config.jenkins.internal = false + config.scm.scmManager = new ScmTenantSchema.ScmManagerTenantConfig() + config.scm.scmManager.internal = false + config.features.monitoring.active = true + config.features.argocd.active = true + config.content.examples = true + config.features.ingressNginx.active = true + config.application.namePrefix = 'test1-' + config.application.openshift = true + config.content.namespaces = [ + '${config.application.namePrefix}example-apps-staging', + '${config.application.namePrefix}example-apps-production' + ] + List namespaceList = new ArrayList<>(Arrays.asList( + "test1-argocd", + "test1-example-apps-staging", + "test1-example-apps-production", + "test1-ingress-nginx", + "test1-monitoring", + "test1-registry", + )) + def application = ApplicationContext.run() + .registerSingleton(config) + .getBean(Application) + application.setNamespaceListToConfig(config) + assertThat(config.application.namespaces.getActiveNamespaces()).containsExactlyInAnyOrderElementsOf(namespaceList) + } } \ No newline at end of file