Skip to content

Fix application passwords, mailhog and vault ingress #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ global:
- name: proxy-registry
</#if>
<#if config.features.secrets.vault.helm.image?has_content
|| url?has_content
|| host?has_content
|| config.application.podResources == true>
server:
</#if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ class ApplicationConfigurator {
newConfig.scmm.ingress = new URL(injectSubdomain('scmm',
newConfig.application.baseUrl as String, newConfig.application.urlSeparatorHyphen as Boolean)).host
}
// When specific user/pw are not set, set them to global values
if (newConfig.scmm.password === Config.DEFAULT_ADMIN_PW) {
newConfig.scmm.password = newConfig.application.password
}
if (newConfig.scmm.username === Config.DEFAULT_ADMIN_USER) {
newConfig.scmm.username = newConfig.application.username
}


}

private void addJenkinsConfig(Config newConfig) {
Expand All @@ -153,6 +162,13 @@ class ApplicationConfigurator {
newConfig.jenkins.ingress = new URL(injectSubdomain('jenkins',
newConfig.application.baseUrl, newConfig.application.urlSeparatorHyphen)).host
}
// When specific user/pw are not set, set them to global values
if (newConfig.jenkins.username === Config.DEFAULT_ADMIN_USER) {
newConfig.jenkins.username = newConfig.application.username
}
if (newConfig.jenkins.password === Config.DEFAULT_ADMIN_PW) {
newConfig.jenkins.password = newConfig.application.password
}
}

private void evaluateBaseUrl(Config newConfig) {
Expand Down Expand Up @@ -328,4 +344,6 @@ class ApplicationConfigurator {
throw new RuntimeException(errorMessage, e)
}
}


}
6 changes: 4 additions & 2 deletions src/main/groovy/com/cloudogu/gitops/config/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import picocli.CommandLine.Mixin
import picocli.CommandLine.Option

import static com.cloudogu.gitops.config.ConfigConstants.*
import static picocli.CommandLine.ScopeType
import static picocli.CommandLine.ScopeType

/**
* The global configuration object.
*
Expand Down Expand Up @@ -488,9 +489,10 @@ class Config {
}

static class MailSchema {
@Option(names = ['--mailhog', '--mail'], description = MAILHOG_ENABLE_DESCRIPTION, scope = ScopeType.INHERIT)

Boolean active = false

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

Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/com/cloudogu/gitops/scmm/ScmmRepo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class ScmmRepo {
ScmmRepo(Config config, String scmmRepoTarget, FileSystemUtils fileSystemUtils) {
def tmpDir = File.createTempDir()
tmpDir.deleteOnExit()
this.username = config.scmm.internal ? config.application.username : config.scmm.username
this.password = config.scmm.internal ? config.application.password : config.scmm.password
this.username = config.scmm.username
this.password = config.scmm.password
this.scmmUrl = "${config.scmm.protocol}://${config.scmm.host}"
this.scmmRepoTarget = scmmRepoTarget.startsWith(NAMESPACE_3RD_PARTY_DEPENDENCIES) ? scmmRepoTarget :
"${config.application.namePrefix}${scmmRepoTarget}"
Expand Down
13 changes: 11 additions & 2 deletions src/test/groovy/com/cloudogu/gitops/features/VaultTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,23 @@ class VaultTest {
@Test
void 'uses ingress if enabled'() {
config.features.secrets.vault.url = 'http://vault.local'
// Also set image to make sure ingress and image work at the same time under the server block
config.features.secrets.vault.helm.image = 'localhost:5000/hashicorp/vault:1.12.0'
createVault().install()

def ingressYaml = parseActualYaml()['server']['ingress']
assertThat(ingressYaml['enabled']).isEqualTo(true)
assertThat((ingressYaml['hosts'] as List)[0]['host']).isEqualTo('vault.local')
}

@Test
void 'uses ingress if enabled and image set'() {
config.features.secrets.vault.url = 'http://vault.local'
// Also set image to make sure ingress and image work at the same time under the server block
//config.features.secrets.vault.helm.image = 'localhost:5000/hashicorp/vault:1.12.0'
createVault().install()

def ingressYaml = parseActualYaml()['server']['ingress']
assertThat(ingressYaml['enabled']).isEqualTo(true)
}

@Test
void 'does not use ingress by default'() {
Expand Down