Skip to content

Commit 8a138b6

Browse files
nihussmannThomasMichael1811
authored andcommitted
removing unused folders from argocd repo
1 parent 07092fd commit 8a138b6

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,15 @@ class ArgoCD extends Feature {
479479
FileSystemUtils.deleteDir argocdRepoInitializationAction.repo.getAbsoluteLocalRepoTmpDir() + '/operator'
480480
}
481481

482+
if (config.multiTenant.useDedicatedInstance) {
483+
log.debug("Deleting unnecessary non dedicated instances folders from argocd repo: ${argocdRepoInitializationAction.repo.getAbsoluteLocalRepoTmpDir()}")
484+
FileSystemUtils.deleteDir argocdRepoInitializationAction.repo.getAbsoluteLocalRepoTmpDir() + '/applications'
485+
FileSystemUtils.deleteDir argocdRepoInitializationAction.repo.getAbsoluteLocalRepoTmpDir() + '/projects'
486+
} else {
487+
log.debug("Deleting unnecessary multiTenant folder from argocd repo: ${argocdRepoInitializationAction.repo.getAbsoluteLocalRepoTmpDir()}")
488+
FileSystemUtils.deleteDir argocdRepoInitializationAction.repo.getAbsoluteLocalRepoTmpDir() + '/multiTenant'
489+
}
490+
482491
if (!config.scmm.internal) {
483492
String externalScmmUrl = ScmUrlResolver.externalHost(config)
484493
log.debug("Configuring all yaml files in argocd repo to use the external scmm url: ${externalScmmUrl}")

src/test/groovy/com/cloudogu/gitops/features/argocd/ArgoCDTest.groovy

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ class ArgoCDTest {
12051205
"testPrefix-example-apps-production"
12061206
]
12071207
// have to prepare activeNamespaces for unit-test, Application.groovy is setting this in integration way
1208-
config.application.namespaces.dedicatedNamespaces =new LinkedHashSet<String>([
1208+
config.application.namespaces.dedicatedNamespaces = new LinkedHashSet<String>([
12091209
"monitoring",
12101210
"secrets",
12111211
"ingress-nginx",
@@ -1586,6 +1586,30 @@ class ArgoCDTest {
15861586
k8sCommands.assertExecuted('kubectl patch secret argocd-default-cluster-config -n argocd --patch-file=/tmp/gitops-playground-patch-')
15871587
}
15881588

1589+
1590+
@Test
1591+
void 'multiTenant folder gets deleted correctly if not in dedicated mode'() {
1592+
config.multiTenant.useDedicatedInstance = false
1593+
1594+
def argocd = createArgoCD()
1595+
argocd.install()
1596+
1597+
assertThat(Path.of(argocdRepo.getAbsoluteLocalRepoTmpDir(), 'multiTenant/')).doesNotExist()
1598+
assertThat(Path.of(argocdRepo.getAbsoluteLocalRepoTmpDir(), 'applications/')).exists()
1599+
assertThat(Path.of(argocdRepo.getAbsoluteLocalRepoTmpDir(), 'projects/')).exists()
1600+
}
1601+
1602+
@Test
1603+
void 'deleting unused folder in dedicated mode'() {
1604+
config.multiTenant.useDedicatedInstance = true
1605+
1606+
def argocd = createArgoCD()
1607+
argocd.install()
1608+
assertThat(Path.of(argocdRepo.getAbsoluteLocalRepoTmpDir(), 'multiTenant/')).exists()
1609+
assertThat(Path.of(argocdRepo.getAbsoluteLocalRepoTmpDir(), 'applications/')).doesNotExist()
1610+
assertThat(Path.of(argocdRepo.getAbsoluteLocalRepoTmpDir(), 'projects/')).doesNotExist()
1611+
}
1612+
15891613
@Test
15901614
void 'RBACs generated correctly'() {
15911615
config.application.namespaces.tenantNamespaces = new LinkedHashSet(['testprefix-tenant-test1', 'testprefix-tenant-test2', 'testprefix-tenant-test3'])
@@ -1728,6 +1752,7 @@ class ArgoCDTest {
17281752
'http://scmm.scm-manager.svc.cluster.local/scm/3rd-party-dependencies/cert-manager.git'
17291753
)
17301754
}
1755+
17311756
@Test
17321757
void 'If using mirror with GitLab, ensure source repos in cluster-resources got right URL'() {
17331758
config.application.mirrorRepos = true
@@ -1786,6 +1811,7 @@ class ArgoCDTest {
17861811
'http://scmm.test1-scm-manager.svc.cluster.local/scm/repo/3rd-party-dependencies/cert-manager'
17871812
)
17881813
}
1814+
17891815
@Test
17901816
void 'If using mirror with name-prefix, ensure source repos in cluster-resources got right URL'() {
17911817
config.application.mirrorRepos = true

0 commit comments

Comments
 (0)