Skip to content

Commit 0d8da18

Browse files
committed
fixed folder structure; fixed kubeval for missing schemas
Signed-off-by: Marek Markiewka <marek.markiewka@cloudogu.com>
1 parent 644e1ac commit 0d8da18

6 files changed

Lines changed: 15 additions & 35 deletions

File tree

src/com/cloudogu/gitopsbuildlib/deployment/Deployment.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ abstract class Deployment {
2626
abstract preValidation(String stage)
2727
abstract postValidation(String stage)
2828

29+
2930
def validate(String stage) {
3031
gitopsConfig.validators.each { validatorConfig ->
3132
script.echo "Executing validator ${validatorConfig.key}"
32-
validatorConfig.value.validator.validate(validatorConfig.value.enabled, "${stage}/${gitopsConfig.application}", validatorConfig.value.config, gitopsConfig.deployments)
33+
validatorConfig.value.validator.validate(validatorConfig.value.enabled, "${stage}/${gitopsConfig.application}", validatorConfig.value.config, gitopsConfig)
3334
}
3435
}
3536

src/com/cloudogu/gitopsbuildlib/deployment/helm/repotype/HelmRepo.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class HelmRepo extends RepoType{
3030
withHelm {
3131
script.sh "helm repo add chartRepo ${helmConfig.repoUrl}${credentialArgs}"
3232
script.sh "helm repo update"
33+
// helm pull also executes helm dependency so we don't need to do it in this step
3334
script.sh "helm pull chartRepo/${helmConfig.chartName} --version=${helmConfig.version} --untar --untardir=chart"
3435
String helmScript = "helm values chart/${helmConfig.chartName} ${valuesFilesWithParameter(valuesFiles)}"
3536
merge = script.sh returnStdout: true, script: helmScript

src/com/cloudogu/gitopsbuildlib/validation/HelmKubeval.groovy

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.cloudogu.gitopsbuildlib.validation
22

3-
import com.cloudogu.gitopsbuildlib.docker.DockerWrapper
4-
53
class HelmKubeval extends Validator {
64

75
HelmKubeval(def script) {
@@ -11,33 +9,16 @@ class HelmKubeval extends Validator {
119
@Override
1210
void validate(String targetDirectory, Map config, Map deployments) {
1311
if (deployments.containsKey('helm')) {
14-
if (deployments.helm.repoType == 'GIT') {
15-
// script.dir("${targetDirectory}/chart") {
16-
// def git = (deployments.helm.containsKey('credentialsId'))
17-
// ? script.cesBuildLib.Git.new(script, deployments.helm.credentialsId)
18-
// : script.cesBuildLib.Git.new(script)
19-
// git url: deployments.helm.repoUrl, branch: 'main', changelog: false, poll: false
20-
//
21-
// if(deployments.helm.containsKey('version') && deployments.helm.version) {
22-
// git.checkout(deployments.helm.version)
23-
// }
24-
// }
25-
26-
def chartPath = ''
27-
if (deployments.helm.containsKey('chartPath')) {
28-
chartPath = deployments.helm.chartPath
29-
}
3012

31-
withDockerImage(config.image) {
32-
script.sh "helm kubeval chart/${chartPath} -v ${config.k8sSchemaVersion}"
33-
}
13+
def chartDir = ''
14+
if (deployments.helm.containsKey('chartPath')) {
15+
chartDir = deployments.helm.chartPath
16+
} else if ( deployments.helm.containsKey('chartName')) {
17+
chartDir = deployments.helm.chartName
18+
}
3419

35-
} else if (deployments.helm.repoType == 'HELM') {
36-
withDockerImage(config.image) {
37-
script.sh "helm repo add chartRepo ${deployments.helm.repoUrl}"
38-
script.sh "helm repo update"
39-
script.sh "helm kubeval chartRepo/${deployments.helm.chartName} --version=${deployments.helm.version} -v ${config.k8sSchemaVersion}"
40-
}
20+
withDockerImage(config.image) {
21+
script.sh "helm kubeval chart/${chartDir} -v ${config.k8sSchemaVersion}"
4122
}
4223
}
4324
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
package com.cloudogu.gitopsbuildlib.validation
22

3-
import com.cloudogu.gitopsbuildlib.docker.DockerWrapper
4-
53
/**
64
* Validates all yaml-resources within the target-directory against the specs of the given k8s version
75
*/
86
class Kubeval extends Validator {
97

10-
118
Kubeval(def script) {
129
super(script)
1310
}
1411

1512
@Override
1613
void validate(String targetDirectory, Map config, Map deployments) {
1714
withDockerImage(config.image) {
18-
script.sh "kubeval -d ${targetDirectory} -v ${config.k8sSchemaVersion} --strict"
15+
script.sh "kubeval -d ${targetDirectory} -v ${config.k8sSchemaVersion} --strict --ignore-missing-schemas"
1916
}
2017
}
2118
}

src/com/cloudogu/gitopsbuildlib/validation/Validator.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ abstract class Validator {
1212
dockerWrapper = new DockerWrapper(script)
1313
}
1414

15-
void validate(boolean enabled, String targetDirectory, Map config, Map deployments) {
15+
void validate(boolean enabled, String targetDirectory, Map config, Map gitopsConfig) {
1616
if (enabled) {
17-
validate(targetDirectory, config, deployments)
17+
validate(targetDirectory, config, gitopsConfig)
1818
} else {
1919
script.echo "Skipping validator ${this.getClass().getSimpleName()} because it is configured as enabled=false"
2020
}

src/com/cloudogu/gitopsbuildlib/validation/Yamllint.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Yamllint extends Validator {
1616
}
1717

1818
@Override
19-
void validate(String targetDirectory, Map config, Map deployments) {
19+
void validate(String targetDirectory, Map config, Map gitopsConfig) {
2020
withDockerImage(config.image) {
2121
script.sh "yamllint " +
2222
"${config.profile ? "-d ${config.profile} " : ''}" +

0 commit comments

Comments
 (0)