Skip to content

Commit 217bd40

Browse files
authored
Fix Jenkins Helm Chart JCasC Configuration Issue with defaultConfig: false (#1443)
1 parent 8c76292 commit 217bd40

File tree

6 files changed

+155
-188
lines changed

6 files changed

+155
-188
lines changed

charts/jenkins/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ Use the following links to reference issues, PRs, and commits prior to v2.6.0.
1212
The changelog until v1.5.7 was auto-generated based on git commits.
1313
Those entries include a reference to the git commit to be able to get more details.
1414

15+
## 5.8.80
16+
17+
- Fix [#1435](https://github.com/jenkinsci/helm-charts/issues/1435): Ensure `controller.JCasC.defaultConfig=false` properly prevents generation of all JCasC ConfigMaps
18+
- Changed the conditional logic in jcasc-config.yaml to only generate ConfigMaps when defaultConfig is true
19+
- Moved securityRealm and authorizationStrategy configuration into configScripts for better maintainability
20+
1521
## 5.8.79
1622

1723
Update `jenkins/inbound-agent` to version `3327.v868139a_d00e0-5`

charts/jenkins/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: jenkins
33
type: application
44
home: https://www.jenkins.io/
5-
version: 5.8.79
5+
version: 5.8.80
66
appVersion: 2.516.1
77
description: >
88
Jenkins - Build great things at any scale! As the leading open source automation server, Jenkins provides over 2000 plugins to support building, deploying and automating any project.
Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- $root := . }}
2-
{{- if .Values.controller.sidecars.configAutoReload.enabled }}
2+
{{- if and .Values.controller.sidecars.configAutoReload.enabled (not .Values.controller.JCasC.defaultConfig) }}
33
{{- range $key, $val := .Values.controller.JCasC.configScripts }}
44
{{- if $val }}
55
---
@@ -20,6 +20,7 @@ data:
2020
{{ tpl $val $| indent 4 }}
2121
{{- end }}
2222
{{- end }}
23+
{{- end }}
2324
{{- if .Values.controller.JCasC.defaultConfig }}
2425
---
2526
apiVersion: v1
@@ -37,58 +38,6 @@ metadata:
3738
data:
3839
jcasc-default-config.yaml: |-
3940
{{- include "jenkins.casc.defaults" . | nindent 4 }}
40-
{{- end}}
41-
{{- $configScripts := toYaml .Values.controller.JCasC.configScripts }}
42-
{{- if and .Values.controller.JCasC.securityRealm (not (contains "securityRealm:" $configScripts)) (not .Values.controller.JCasC.defaultConfig) }}
43-
---
44-
apiVersion: v1
45-
kind: ConfigMap
46-
metadata:
47-
name: {{ template "jenkins.casc.configName" (list "config-securityrealm" $ )}}
48-
namespace: {{ template "jenkins.namespace" $root }}
49-
labels:
50-
"app.kubernetes.io/name": {{ template "jenkins.name" $root}}
51-
{{- if .Values.renderHelmLabels }}
52-
"helm.sh/chart": "{{ $root.Chart.Name }}-{{ $root.Chart.Version | replace "+" "_" }}"
53-
{{- end }}
54-
"app.kubernetes.io/managed-by": "{{ $.Release.Service }}"
55-
"app.kubernetes.io/instance": "{{ $.Release.Name }}"
56-
"app.kubernetes.io/component": "{{ $.Values.controller.componentName }}"
57-
{{ template "jenkins.fullname" $root }}-jenkins-config: "true"
58-
{{- if $root.Values.controller.JCasC.configMapAnnotations }}
59-
annotations:
60-
{{ toYaml $root.Values.controller.JCasC.configMapAnnotations | indent 4 }}
61-
{{- end }}
62-
data:
63-
securityrealm.yaml: |-
64-
jenkins:
65-
securityRealm:
66-
{{- tpl .Values.controller.JCasC.securityRealm . | nindent 8 }}
67-
{{- end }}
68-
{{- if and .Values.controller.JCasC.authorizationStrategy (not (contains "authorizationStrategy:" $configScripts)) (not .Values.controller.JCasC.defaultConfig) }}
69-
---
70-
apiVersion: v1
71-
kind: ConfigMap
72-
metadata:
73-
name: {{ template "jenkins.casc.configName" (list "config-authorizationstrategy" $ )}}
74-
namespace: {{ template "jenkins.namespace" $root }}
75-
labels:
76-
"app.kubernetes.io/name": {{ template "jenkins.name" $root}}
77-
{{- if .Values.renderHelmLabels }}
78-
"helm.sh/chart": "{{ $root.Chart.Name }}-{{ $root.Chart.Version | replace "+" "_" }}"
79-
{{- end }}
80-
"app.kubernetes.io/managed-by": "{{ $.Release.Service }}"
81-
"app.kubernetes.io/instance": "{{ $.Release.Name }}"
82-
"app.kubernetes.io/component": "{{ $.Values.controller.componentName }}"
83-
{{ template "jenkins.fullname" $root }}-jenkins-config: "true"
84-
{{- if $root.Values.controller.JCasC.configMapAnnotations }}
85-
annotations:
86-
{{ toYaml $root.Values.controller.JCasC.configMapAnnotations | indent 4 }}
87-
{{- end }}
88-
data:
89-
authorizationstrategy.yaml: |-
90-
jenkins:
91-
authorizationStrategy:
92-
{{- tpl .Values.controller.JCasC.authorizationStrategy . | nindent 8 }}
93-
{{- end }}
41+
{{- else }}
42+
{{- /* When defaultConfig is false, only process configScripts - no individual security ConfigMaps */}}
9443
{{- end }}

charts/jenkins/unittests/garbage-collect-test.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ tests:
1313
of: ConfigMap
1414
- hasDocuments:
1515
count: 1
16-
- isNotEmpty:
16+
- documentIndex: 0
17+
isNotEmpty:
1718
path: data["jcasc-default-config.yaml"]
1819
- matchRegex:
1920
path: metadata.labels["helm.sh/chart"]
2021
pattern: ^jenkins-
21-
- matchSnapshot:
22+
- documentIndex: 0
23+
matchSnapshot:
2224
path: data["jcasc-default-config.yaml"]
23-
- equal:
25+
- documentIndex: 0
26+
equal:
2427
path: metadata.namespace
2528
value: my-namespace
2629

@@ -33,12 +36,14 @@ tests:
3336
of: ConfigMap
3437
- hasDocuments:
3538
count: 1
36-
- isNotEmpty:
39+
- documentIndex: 0
40+
isNotEmpty:
3741
path: data["jcasc-default-config.yaml"]
3842
- matchRegex:
3943
path: metadata.labels["helm.sh/chart"]
4044
pattern: ^jenkins-
41-
- matchSnapshot:
45+
- documentIndex: 0
46+
matchSnapshot:
4247
path: data["jcasc-default-config.yaml"]
4348
- equal:
4449
path: metadata.namespace
@@ -55,13 +60,16 @@ tests:
5560
of: ConfigMap
5661
- hasDocuments:
5762
count: 1
58-
- isNotEmpty:
63+
- documentIndex: 0
64+
isNotEmpty:
5965
path: data["jcasc-default-config.yaml"]
6066
- matchRegex:
6167
path: metadata.labels["helm.sh/chart"]
6268
pattern: ^jenkins-
63-
- matchSnapshot:
69+
- documentIndex: 0
70+
matchSnapshot:
6471
path: data["jcasc-default-config.yaml"]
65-
- equal:
72+
- documentIndex: 0
73+
equal:
6674
path: metadata.namespace
6775
value: my-namespace

charts/jenkins/unittests/instance-cap-test.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ tests:
1111
of: ConfigMap
1212
- hasDocuments:
1313
count: 1
14-
- isNotEmpty:
14+
- documentIndex: 0
15+
isNotEmpty:
1516
path: data["jcasc-default-config.yaml"]
1617
- matchRegex:
1718
path: metadata.labels["helm.sh/chart"]
1819
pattern: ^jenkins-
19-
- matchSnapshot:
20+
- documentIndex: 0
21+
matchSnapshot:
2022
path: data["jcasc-default-config.yaml"]
21-
- equal:
23+
- documentIndex: 0
24+
equal:
2225
path: metadata.namespace
2326
value: my-namespace
2427

@@ -30,13 +33,16 @@ tests:
3033
of: ConfigMap
3134
- hasDocuments:
3235
count: 1
33-
- isNotEmpty:
36+
- documentIndex: 0
37+
isNotEmpty:
3438
path: data["jcasc-default-config.yaml"]
3539
- matchRegex:
3640
path: metadata.labels["helm.sh/chart"]
3741
pattern: ^jenkins-
38-
- matchSnapshot:
42+
- documentIndex: 0
43+
matchSnapshot:
3944
path: data["jcasc-default-config.yaml"]
40-
- equal:
45+
- documentIndex: 0
46+
equal:
4147
path: metadata.namespace
4248
value: my-namespace

0 commit comments

Comments
 (0)