Skip to content

Commit 0068c29

Browse files
authored
Merge pull request #270 from cloudogu/bug/password-override
Fix application passwords, mailhog and vault ingress
2 parents 98e35be + 411759d commit 0068c29

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

applications/cluster-resources/secrets/vault/values.ftl.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ global:
1616
- name: proxy-registry
1717
</#if>
1818
<#if config.features.secrets.vault.helm.image?has_content
19-
|| url?has_content
19+
|| host?has_content
2020
|| config.application.podResources == true>
2121
server:
2222
</#if>

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

+18
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ class ApplicationConfigurator {
131131
newConfig.scmm.ingress = new URL(injectSubdomain('scmm',
132132
newConfig.application.baseUrl as String, newConfig.application.urlSeparatorHyphen as Boolean)).host
133133
}
134+
// When specific user/pw are not set, set them to global values
135+
if (newConfig.scmm.password === Config.DEFAULT_ADMIN_PW) {
136+
newConfig.scmm.password = newConfig.application.password
137+
}
138+
if (newConfig.scmm.username === Config.DEFAULT_ADMIN_USER) {
139+
newConfig.scmm.username = newConfig.application.username
140+
}
141+
142+
134143
}
135144

136145
private void addJenkinsConfig(Config newConfig) {
@@ -153,6 +162,13 @@ class ApplicationConfigurator {
153162
newConfig.jenkins.ingress = new URL(injectSubdomain('jenkins',
154163
newConfig.application.baseUrl, newConfig.application.urlSeparatorHyphen)).host
155164
}
165+
// When specific user/pw are not set, set them to global values
166+
if (newConfig.jenkins.username === Config.DEFAULT_ADMIN_USER) {
167+
newConfig.jenkins.username = newConfig.application.username
168+
}
169+
if (newConfig.jenkins.password === Config.DEFAULT_ADMIN_PW) {
170+
newConfig.jenkins.password = newConfig.application.password
171+
}
156172
}
157173

158174
private void evaluateBaseUrl(Config newConfig) {
@@ -328,4 +344,6 @@ class ApplicationConfigurator {
328344
throw new RuntimeException(errorMessage, e)
329345
}
330346
}
347+
348+
331349
}

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import picocli.CommandLine.Mixin
1515
import picocli.CommandLine.Option
1616

1717
import static com.cloudogu.gitops.config.ConfigConstants.*
18-
import static picocli.CommandLine.ScopeType
18+
import static picocli.CommandLine.ScopeType
19+
1920
/**
2021
* The global configuration object.
2122
*
@@ -488,9 +489,10 @@ class Config {
488489
}
489490

490491
static class MailSchema {
491-
@Option(names = ['--mailhog', '--mail'], description = MAILHOG_ENABLE_DESCRIPTION, scope = ScopeType.INHERIT)
492+
492493
Boolean active = false
493494

495+
@Option(names = ['--mailhog', '--mail'], description = MAILHOG_ENABLE_DESCRIPTION, scope = ScopeType.INHERIT)
494496
@JsonPropertyDescription(MAILHOG_ENABLE_DESCRIPTION)
495497
Boolean mailhog = false
496498

src/main/groovy/com/cloudogu/gitops/scmm/ScmmRepo.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class ScmmRepo {
3636
ScmmRepo(Config config, String scmmRepoTarget, FileSystemUtils fileSystemUtils) {
3737
def tmpDir = File.createTempDir()
3838
tmpDir.deleteOnExit()
39-
this.username = config.scmm.internal ? config.application.username : config.scmm.username
40-
this.password = config.scmm.internal ? config.application.password : config.scmm.password
39+
this.username = config.scmm.username
40+
this.password = config.scmm.password
4141
this.scmmUrl = "${config.scmm.protocol}://${config.scmm.host}"
4242
this.scmmRepoTarget = scmmRepoTarget.startsWith(NAMESPACE_3RD_PARTY_DEPENDENCIES) ? scmmRepoTarget :
4343
"${config.application.namePrefix}${scmmRepoTarget}"

src/test/groovy/com/cloudogu/gitops/features/VaultTest.groovy

+11-2
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,23 @@ class VaultTest {
6464
@Test
6565
void 'uses ingress if enabled'() {
6666
config.features.secrets.vault.url = 'http://vault.local'
67-
// Also set image to make sure ingress and image work at the same time under the server block
68-
config.features.secrets.vault.helm.image = 'localhost:5000/hashicorp/vault:1.12.0'
6967
createVault().install()
7068

7169
def ingressYaml = parseActualYaml()['server']['ingress']
7270
assertThat(ingressYaml['enabled']).isEqualTo(true)
7371
assertThat((ingressYaml['hosts'] as List)[0]['host']).isEqualTo('vault.local')
7472
}
73+
74+
@Test
75+
void 'uses ingress if enabled and image set'() {
76+
config.features.secrets.vault.url = 'http://vault.local'
77+
// Also set image to make sure ingress and image work at the same time under the server block
78+
//config.features.secrets.vault.helm.image = 'localhost:5000/hashicorp/vault:1.12.0'
79+
createVault().install()
80+
81+
def ingressYaml = parseActualYaml()['server']['ingress']
82+
assertThat(ingressYaml['enabled']).isEqualTo(true)
83+
}
7584

7685
@Test
7786
void 'does not use ingress by default'() {

0 commit comments

Comments
 (0)