Skip to content

Commit 61293a9

Browse files
author
Thomas Michael
committed
namespace creation for jenkins, only if internal
1 parent 1d01378 commit 61293a9

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/main/groovy/com/cloudogu/gitops/features/Jenkins.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,8 @@ class Jenkins extends Feature {
296296
]
297297
]
298298
}
299+
@Override
300+
String getActiveNamespaceFromFeature() {
301+
return isEnabled() && config?.jenkins?.internal ? getNamespace() : null
302+
}
299303
}

src/test/groovy/com/cloudogu/gitops/ApplicationTest.groovy

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cloudogu.gitops
22

33
import com.cloudogu.gitops.config.Config
4+
import com.cloudogu.gitops.features.git.config.ScmTenantSchema
45
import io.micronaut.context.ApplicationContext
56
import org.junit.jupiter.api.Test
67

@@ -103,4 +104,35 @@ class ApplicationTest {
103104
application.setNamespaceListToConfig(config)
104105
// No exception == happy
105106
}
107+
@Test
108+
void 'get active namespaces correctly in Openshift if jenkins and scm are external'() {
109+
config.registry.active = true
110+
config.jenkins.active = true
111+
config.jenkins.internal = false
112+
config.scm.scmManager = new ScmTenantSchema.ScmManagerTenantConfig()
113+
config.scm.scmManager.internal = false
114+
config.features.monitoring.active = true
115+
config.features.argocd.active = true
116+
config.content.examples = true
117+
config.features.ingressNginx.active = true
118+
config.application.namePrefix = 'test1-'
119+
config.application.openshift = true
120+
config.content.namespaces = [
121+
'${config.application.namePrefix}example-apps-staging',
122+
'${config.application.namePrefix}example-apps-production'
123+
]
124+
List<String> namespaceList = new ArrayList<>(Arrays.asList(
125+
"test1-argocd",
126+
"test1-example-apps-staging",
127+
"test1-example-apps-production",
128+
"test1-ingress-nginx",
129+
"test1-monitoring",
130+
"test1-registry",
131+
))
132+
def application = ApplicationContext.run()
133+
.registerSingleton(config)
134+
.getBean(Application)
135+
application.setNamespaceListToConfig(config)
136+
assertThat(config.application.namespaces.getActiveNamespaces()).containsExactlyInAnyOrderElementsOf(namespaceList)
137+
}
106138
}

0 commit comments

Comments
 (0)