diff --git a/vars/generateContainerTemplate.groovy b/vars/generateContainerTemplate.groovy deleted file mode 100644 index c9e2ef0..0000000 --- a/vars/generateContainerTemplate.groovy +++ /dev/null @@ -1,61 +0,0 @@ -def generateContainerTemplate(appConfig) { - // Generate the container template based on the appConfig - def containerTemplates = appConfig.container.collect { container -> - def envVars = container.envVars.collect { envVar -> - """ - - name: ${envVar.name} - value: "${envVar.value}" - """ - }.join('\n') - - def volumeMounts = container.volumeMounts.collect { volumeMount -> - """ - - name: ${volumeMount.name} - mountPath: ${volumeMount.mountPath} - readOnly: ${volumeMount.readOnly} - """ - }.join('\n') - - def volumes = container.volumes.collect { volume -> - """ - - name: ${volume.name} - persistentVolumeClaim: - claimName: ${volume.claimName} - """ - }.join('\n') - - """ - - name: ${container.name} - image: ${container.image} - command: - - "${container.command}" - tty: ${container.tty} - ${envVars ? "env:\n${envVars}" : ''} - resources: - limits: - cpu: ${container.resources.cpu.limit} - memory: ${container.resources.memory.limit} - requests: - cpu: ${container.resources.cpu.request} - memory: ${container.resources.memory.request} - securityContext: - runAsNonRoot: true - runAsUser: ${container.securityContext.runAsUser} - ${volumeMounts ? "volumeMounts:\n${volumeMounts}" : ''} - ${volumes ? "volumes:\n${volumes}" : ''} - """ - } - - def containerTemplate = """ -apiVersion: v1 -kind: Pod -metadata: - labels: - name: ${appConfig.container.labels.name} -spec: - containers: -${containerTemplates.join('\n')} -""" - - return containerTemplate -} \ No newline at end of file diff --git a/vars/readAppConfig.groovy b/vars/readAppConfig.groovy deleted file mode 100644 index 24ac843..0000000 --- a/vars/readAppConfig.groovy +++ /dev/null @@ -1,83 +0,0 @@ -def call(selectedContainerNames = null) { - - def wild_path = getContext(hudson.FilePath) + "./wild-workdir" - def appConfig = readYaml(file: "${wild_path}/config/containers-config.yaml") - - if (selectedContainerNames) { - appConfig.container = appConfig.container.findAll { container -> - selectedContainerNames.contains(container.name) - } - } - - return appConfig -} - -// Usage example - specifying selected container names - -//def selectedContainerNames = ["container1", "container2"] -//def appConfig = readAppConfig(selectedContainerNames) - -// Usage example - resulting appConfig - -/* def appConfig = [ - container: [ - [ - name: "container1", - image: "image1", - command: "command1", - tty: true, - envVars: [ - [name: "ENV_VAR1", value: "value1"], - [name: "ENV_VAR2", value: "value2"] - ], - resources: [ - cpu: [ - limit: "500m", - request: "200m" - ], - memory: [ - limit: "512Mi", - request: "256Mi" - ] - ], - securityContext: [ - runAsUser: 1000 - ], - volumeMounts: [ - [name: "volume1", mountPath: "/path1", readOnly: true] - ], - volumes: [ - [name: "volume1", claimName: "claim1"] - ] - ], - [ - name: "container2", - image: "image2", - command: "command2", - tty: false, - envVars: [ - [name: "ENV_VAR3", value: "value3"], - [name: "ENV_VAR4", value: "value4"] - ], - resources: [ - cpu: [ - limit: "1", - request: "500m" - ], - memory: [ - limit: "1Gi", - request: "512Mi" - ] - ], - securityContext: [ - runAsUser: 2000 - ], - volumeMounts: [ - [name: "volume2", mountPath: "/path2", readOnly: false] - ], - volumes: [ - [name: "volume2", claimName: "claim2"] - ] - ] - ] -] */ diff --git a/vars/wildPipeline.groovy b/vars/wildPipeline.groovy index 21cb1a0..063e880 100644 --- a/vars/wildPipeline.groovy +++ b/vars/wildPipeline.groovy @@ -63,15 +63,14 @@ def call() { container("bash") { sh script: "test/action/test.sh", returnstatus: true } - - runContainerNames = ["bash", "maven"] - appConfig = readYaml(file: "./wild-workdir/config/containers-config.yaml") - runContainerConfig = containerConfig.getContainerConfig(appConfig, runContainerNames) - k8s_containers_run = containerConfig.generateContainerTemplate(runContainerConfig) - - stash name: "init", usedefaultexcludes: false } } + runContainerNames = ["bash", "maven"] + appConfig = readYaml(file: "./wild-workdir/config/containers-config.yaml") + runContainerConfig = containerConfig.getContainerConfig(appConfig, runContainerNames) + k8s_containers_run = containerConfig.generateContainerTemplate(runContainerConfig) + + stash name: "init", usedefaultexcludes: false } }