Skip to content
Open
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
4 changes: 1 addition & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ pipeline {
reuseNode true
}}
steps {
sh 'mvn -B clean test'
junit testResults: '**/target/surefire-reports/TEST-*.xml'
archiveArtifacts artifacts: "**/target/site/jacoco/**"
echo 'test'
}
}

Expand Down
8 changes: 5 additions & 3 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"baseBranchPatterns": ["develop"]
}
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"baseBranchPatterns": [
"develop"
]
}
32 changes: 16 additions & 16 deletions src/main/groovy/com/cloudogu/gitops/Application.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ class Application {
log.debug("Application finished")
}

private void storeGopInformationInSecret(Config config) {
String namespace = "gop-job" // Fallback, if run from IDE
if (!config.application.gopNamespace.isEmpty()) {
// if set, take namespace from configuration
namespace = "${config.application.gopNamespace}"
} else if (this.k8sClient.k8sJavaApiClient.getCurrentNamespace() != null) {
// if gop-namespace not set, take namespace from running GOP
namespace = this.k8sClient.k8sJavaApiClient.getCurrentNamespace()
}
log.debug("Storing GOP configuration in secret 'gop-configuration' in namespace '${namespace}'")
k8sClient.createNamespace(namespace)
k8sClient.createSecret('generic', 'gop-configuration', namespace,
new Tuple2('gop-initial-password', config.DEFAULT_ADMIN_PW),
new Tuple2('gop-config', config.toYaml(true)))
}

private void storeGopInformationInSecret(Config config) {
String namespace = "gop-job"
// Fallback, if run from IDE
if (!config.application.gopNamespace.isEmpty()) {
// if set, take namespace from configuration
namespace = "${config.application.gopNamespace}"
} else if (this.k8sClient.getCurrentNamespace() != null) {
// if gop-namespace not set, take namespace from running GOP
namespace = this.k8sClient.getCurrentNamespace()
}
log.debug("Storing GOP configuration in secret 'gop-configuration' in namespace '${namespace}'")
k8sClient.createNamespace(namespace)
k8sClient.createSecret('generic', 'gop-configuration', namespace,
new Tuple2('gop-initial-password', config.DEFAULT_ADMIN_PW),
new Tuple2('gop-config', config.toYaml(true)))
}

List<Feature> getFeatures() {
return features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,4 @@ class GenerateJsonSchema {
static String anchor(String name) {
return sectionTitle(name).toLowerCase().replaceAll(/\s+/, '-')
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import com.cloudogu.gitops.config.Config
import com.cloudogu.gitops.config.schema.JsonSchemaValidator
import com.cloudogu.gitops.destroy.Destroyer
import com.cloudogu.gitops.kubernetes.api.K8sClient
import com.cloudogu.gitops.utils.CommandExecutor
import com.cloudogu.gitops.utils.FileSystemUtils

import io.micronaut.context.ApplicationContext

Expand Down Expand Up @@ -41,7 +39,7 @@ class GitopsPlaygroundCli {
K8sClient k8sClient
ApplicationConfigurator applicationConfigurator

GitopsPlaygroundCli(K8sClient k8sClient = new K8sClient(new CommandExecutor(), new FileSystemUtils(), null),
GitopsPlaygroundCli(K8sClient k8sClient = new K8sClient(),
ApplicationConfigurator applicationConfigurator = new ApplicationConfigurator()) {
this.k8sClient = k8sClient
this.applicationConfigurator = applicationConfigurator
Expand Down Expand Up @@ -285,4 +283,4 @@ class GitopsPlaygroundCli {
}
return profileConfig
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,4 @@ class ApplicationConfigurator {
throw new RuntimeException(errorMessage, e)
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/groovy/com/cloudogu/gitops/config/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -777,4 +777,4 @@ class Config {
new YAMLMapper()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ interface ConfigConstants {
String HELM_CONFIG_VERSION_DESCRIPTION = 'The version of the Helm chart to be installed'
String HELM_CONFIG_IMAGE_DESCRIPTION = 'The image of the Helm chart to be installed'
String HELM_CONFIG_VALUES_DESCRIPTION = 'Helm values of the chart, allows overriding defaults and setting values that are not exposed as explicit configuration'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class JsonSchemaValidator {
throw new RuntimeException("Config file invalid: " + validationMessages.join("\n"))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ import groovy.transform.CompileStatic
@CompileStatic
class ArgoCDDestructionHandler implements DestructionHandler {
private K8sClient k8sClient
private GitRepoFactory repoProvider
private HelmClient helmClient
private GitRepoFactory repoProvider
private Config config
private FileSystemUtils fileSystemUtils
private GitHandler gitHandler

ArgoCDDestructionHandler(Config config,
K8sClient k8sClient,
GitRepoFactory repoProvider,
HelmClient helmClient,
GitRepoFactory repoProvider,
FileSystemUtils fileSystemUtils,
GitHandler gitHandler) {
this.k8sClient = k8sClient
this.repoProvider = repoProvider
this.helmClient = helmClient
this.repoProvider = repoProvider
this.config = config
this.fileSystemUtils = fileSystemUtils
this.gitHandler = gitHandler
Expand Down Expand Up @@ -93,4 +93,4 @@ class ArgoCDDestructionHandler implements DestructionHandler {
helmClient.dependencyBuild(umbrellaChartPath)
helmClient.upgrade('argocd', umbrellaChartPath, [namespace: "${namePrefix}argocd"])
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class ContentLoader extends Feature {
if (repoConfig.credentials?.username != null && repoConfig.credentials?.password != null) {
credentialsProvider = new UsernamePasswordCredentialsProvider(repoConfig.credentials.username, repoConfig.credentials.password)
} else if (repoConfig.credentials?.secretName && repoConfig.credentials?.secretNamespace) {
Credentials credentials = this.k8sClient.k8sJavaApiClient.getCredentialsFromSecret(repoConfig.credentials)
Credentials credentials = this.k8sClient.getCredentialsFromSecret(repoConfig.credentials)
credentialsProvider = new UsernamePasswordCredentialsProvider(credentials.username, credentials.password)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class ExternalSecretsOperator extends Feature implements FeatureWithImage {
K8sClient k8sClient,
AirGappedUtils airGappedUtils,
GitHandler gitHandler) {

this.deployer = deployer
this.config = config
this.fileSystemUtils = fileSystemUtils
Expand Down
12 changes: 4 additions & 8 deletions src/main/groovy/com/cloudogu/gitops/features/Registry.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,10 @@ class Registry extends Feature {
CONTAINER_PORT, config.registry.internalPort.toString(),
namespace) */

Map<String, String> selector = new HashMap<>()
selector.put("app", "docker-registry")
k8sClient.k8sJavaApiClient.createNodePortService(namespace,
'docker-registry-internal-port',
selector,
CONTAINER_PORT.toInteger(),
config.registry.internalPort,
'docker-registry-internal-port')
k8sClient.createServiceNodePort('docker-registry-internal-port',
"${CONTAINER_PORT}:${CONTAINER_PORT}",
config.registry.internalPort.toString(),
namespace)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,4 @@ class ArgoCD extends Feature {
return this.repoSetup
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ class RepoLayout {
// "argocd/operator/rbac/tenant"
"${operatorRbacSubfolder()}/tenant"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ class ScmCentralSchema {
String gitOpsUsername = ''

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ class ScmTenantSchema {
String urlForJenkins = ''

@JsonIgnore
String getHost() { return NetworkingUtils.getHost(url) }
String getHost() {
return NetworkingUtils.getHost(url)
}

@JsonIgnore
String getProtocol() { return NetworkingUtils.getProtocol(url) }
String getProtocol() {
return NetworkingUtils.getProtocol(url)
}
String ingress = ''

@Option(names = ['--scmm-skip-restart'], description = SCMM_SKIP_RESTART_DESCRIPTION)
Expand All @@ -150,4 +154,4 @@ class ScmTenantSchema {
return new Credentials(username, password)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ interface ScmManagerConfig {
String getGitOpsUsername()

Credentials getCredentials()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ class ScmManager implements GitProvider {
scmmConfig.credentials,
Objects.requireNonNull(config, "config must not be null").application.insecure)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,24 @@ class ScmManagerUrlResolver {
// ---------- Public API used by ScmManager ----------

/** Client base …/scm (no trailing slash) */
URI clientBase() { noTrailSlash(ensureScm(clientBaseRaw())) }
URI clientBase() {
noTrailSlash(ensureScm(clientBaseRaw()))
}

/** Client API base …/scm/api/ */
URI clientApiBase() { withSlash(clientBase()).resolve("api/") }
URI clientApiBase() {
withSlash(clientBase()).resolve("api/")
}

/** Client repo base …/scm/repo (no trailing slash) */
URI clientRepoBase() { noTrailSlash(withSlash(clientBase()).resolve("${root()}/")) }
URI clientRepoBase() {
noTrailSlash(withSlash(clientBase()).resolve("${root()}/"))
}

/** In-cluster base …/scm (no trailing slash) */
URI inClusterBase() { noTrailSlash(ensureScm(inClusterBaseRaw())) }
URI inClusterBase() {
noTrailSlash(ensureScm(inClusterBaseRaw()))
}

/** In-cluster repo prefix …/scm/repo/[<namePrefix>] */
String inClusterRepoPrefix() {
Expand All @@ -62,7 +70,9 @@ class ScmManagerUrlResolver {
}

/** …/scm/api/v2/metrics/prometheus */
URI prometheusEndpoint() { withSlash(clientBase()).resolve("api/v2/metrics/prometheus") }
URI prometheusEndpoint() {
withSlash(clientBase()).resolve("api/v2/metrics/prometheus")
}

// ---------- Base resolution ----------

Expand Down Expand Up @@ -121,4 +131,4 @@ class ScmManagerUrlResolver {
def s = u.toString()
s.endsWith('/') ? URI.create(s.substring(0, s.length() - 1)) : u
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ class HelmClient {
helm(['dependency', 'build', path])
}

String upgrade(String release, String chartOrPath, Map args) {
String upgrade(String release, String chartOrPath, Map args = [:]) {
helm(['upgrade', '-i', release, chartOrPath, '--create-namespace'], args)
}

String template(String release, String chartOrPath, Map args = [:]) {
helm(['template', release, chartOrPath], args)
}

String uninstall(String release, String namespace) {
String[] command = ["helm", "uninstall", release, '--namespace', namespace]
commandExecutor.execute(command).stdOut
}

private String helm(List<String> verbAndParams, Map args = [:]) {
List<String> command = ['helm'] + verbAndParams

Expand All @@ -41,12 +46,7 @@ class HelmClient {
command += value
}

log.trace("Executing helm command: ${command.join(' ')}")
commandExecutor.execute(command as String[]).stdOut
}

String uninstall(String release, String namespace) {
String[] command = ["helm", "uninstall", release, '--namespace', namespace]

commandExecutor.execute(command).stdOut
}
}
Loading