Skip to content

Commit 28af814

Browse files
committed
fixing ArgocdApplication
1 parent db58e00 commit 28af814

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

src/main/groovy/com/cloudogu/gitops/config/Config.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,11 @@ class Config {
484484
return new LinkedHashSet<>(dedicatedNamespaces + tenantNamespaces)
485485
}
486486
}
487+
488+
@JsonIgnore
489+
String getTenantName(){
490+
return namePrefix.replaceAll(/-$/, "")
491+
}
487492
}
488493

489494
static class ImagesSchema {

src/main/groovy/com/cloudogu/gitops/features/argocd/ArgoCD.groovy

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ class ArgoCD extends Feature {
246246
'example-apps',
247247
ScmmRepo.createSCMBaseUrl(config)+'argocd/example-apps',
248248
namespace,
249-
'argocd/')
249+
namespace,
250+
'argocd/',
251+
config.application.getTenantName())
250252
.generate(tenantBootstrapInitializationAction.repo, 'applications')
251253
}
252254
}
@@ -446,19 +448,18 @@ class ArgoCD extends Feature {
446448
k8sClient.label('secret', repoTemplateSecretName, namespace,
447449
new Tuple2(' argocd.argoproj.io/secret-type', 'repo-creds'))
448450

449-
450451
if (config.multiTenant.useDedicatedInstance) {
451452
log.debug('Creating central repo credential secret that is used by argocd to access repos in SCM-Manager')
452453
// Create secret imperatively here instead of values.yaml, because we don't want it to show in git repo
453454
def centralRepoTemplateSecretName = 'argocd-repo-creds-central-scmm'
454455

455-
k8sClient.createSecret('generic', centralRepoTemplateSecretName, "argocd",
456+
k8sClient.createSecret('generic', centralRepoTemplateSecretName, config.multiTenant.centralArgocdNamespace,
456457
new Tuple2('url', config.multiTenant.centralScmUrl),
457458
new Tuple2('username', config.multiTenant.username),
458459
new Tuple2('password', config.multiTenant.password)
459460
)
460461

461-
k8sClient.label('secret', centralRepoTemplateSecretName, "argocd",
462+
k8sClient.label('secret', centralRepoTemplateSecretName, config.multiTenant.centralArgocdNamespace,
462463
new Tuple2(' argocd.argoproj.io/secret-type', 'repo-creds'))
463464
}
464465
}

src/test/groovy/com/cloudogu/gitops/config/schema/ConfigTest.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,10 @@ registry:
5252
assertThat(actualValues.application.namePrefix).isEqualTo(expectedValues.application.namePrefix)
5353
assertThat(actualValues.registry.internalPort).isEqualTo(expectedValues.registry.internalPort)
5454
}
55-
}
55+
56+
@Test
57+
void 'getting Tenantname from Config'(){
58+
testConfig.application.namePrefix='testprefix-'
59+
assertThat(testConfig.application.getTenantName()).isEqualTo("testprefix")
60+
}
61+
}

templates/kubernetes/argocd/application.ftl.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
destination:
1111
server: https://kubernetes.default.svc
1212
namespace: ${destinationNamespace}
13-
project: default
13+
project: ${project}
1414
source:
1515
path: ${path}
1616
repoURL: ${repoUrl}

0 commit comments

Comments
 (0)