@@ -12,11 +12,9 @@ import com.cloudogu.gitops.utils.CommandExecutor
1212import com.cloudogu.gitops.utils.FileSystemUtils
1313import com.cloudogu.gitops.utils.K8sClient
1414import com.cloudogu.gitops.utils.MapUtils
15- import com.cloudogu.gitops.utils.TemplatingEngine
1615import freemarker.template.Configuration
1716import freemarker.template.DefaultObjectWrapperBuilder
1817import groovy.util.logging.Slf4j
19- import groovy.yaml.YamlSlurper
2018import io.micronaut.core.annotation.Order
2119import jakarta.inject.Singleton
2220
@@ -28,7 +26,7 @@ class Jenkins extends Feature {
2826 static final String HELM_VALUES_PATH = " jenkins/values.ftl.yaml"
2927
3028 String namespace = ' default'
31-
29+
3230 private Config config
3331 private CommandExecutor commandExecutor
3432 private FileSystemUtils fileSystemUtils
@@ -82,21 +80,17 @@ class Jenkins extends Feature {
8280 new Tuple2 (' jenkins-admin-password' , config. jenkins. password))
8381
8482 def helmConfig = config. jenkins. helm
85- def templatedMap = new YamlSlurper (). parseText(
86- new TemplatingEngine (). template(new File (HELM_VALUES_PATH ),
87- [dockerGid : findDockerGid(),
88- config : config,
89- // Allow for using static classes inside the templates
90- statics : new DefaultObjectWrapperBuilder (Configuration . VERSION_2_3_32 ). build()
91- .getStaticModels(),
92- ])) as Map
93-
94- def valuesFromConfig = helmConfig. values
95-
96- def mergedMap = MapUtils . deepMerge(valuesFromConfig, templatedMap)
97-
98- def tmpHelmValues = fileSystemUtils. createTempFile()
99- fileSystemUtils. writeYaml(mergedMap, tmpHelmValues. toFile())
83+ def templatedMap = templateToMap(HELM_VALUES_PATH ,
84+ [
85+ dockerGid : findDockerGid(),
86+ config : config,
87+ // Allow for using static classes inside the templates
88+ statics : new DefaultObjectWrapperBuilder (Configuration . VERSION_2_3_32 ). build()
89+ .getStaticModels(),
90+ ])
91+
92+ def mergedMap = MapUtils . deepMerge(helmConfig. values, templatedMap)
93+ def tempValuesPath = fileSystemUtils. writeTempFile(mergedMap)
10094
10195 deployer. deployFeature(
10296 helmConfig. repoURL,
@@ -105,10 +99,10 @@ class Jenkins extends Feature {
10599 helmConfig. version,
106100 namespace,
107101 ' jenkins' ,
108- tmpHelmValues
102+ tempValuesPath
109103 )
110104 }
111-
105+
112106 commandExecutor. execute(" ${ fileSystemUtils.rootDir} /scripts/jenkins/init-jenkins.sh" , [
113107 TRACE : config. application. trace,
114108 INTERNAL_JENKINS : config. jenkins. internal,
@@ -204,8 +198,8 @@ class Jenkins extends Feature {
204198 def etcGroup = k8sClient. run(" tmp-docker-gid-grepper-${ new Random().nextInt(10000)} " ,
205199 ' irrelevant' /* Redundant, but mandatory param */ , namespace, createGidGrepperOverrides(),
206200 ' --restart=Never' , ' -ti' , ' --rm' , ' --quiet' )
207- // --quiet is necessary to avoid 'pod deleted' output
208-
201+ // --quiet is necessary to avoid 'pod deleted' output
202+
209203 def lines = etcGroup. split(' \n ' )
210204 for (String it : lines) {
211205 def parts = it. split(" :" )
@@ -233,7 +227,7 @@ class Jenkins extends Feature {
233227 ' name' : ' tmp-docker-gid-grepper' ,
234228 // We use the same image for several tasks for performance and maintenance reasons
235229 ' image' : " ${ config.jenkins.internalBashImage} " ,
236- ' args' : [ ' cat' , ' /etc/group' ],
230+ ' args' : [' cat' , ' /etc/group' ],
237231 ' volumeMounts' : [
238232 [
239233 ' name' : ' group' ,
0 commit comments