From f60c959fb7bc92ad4973123e17e9348e7e511ebf Mon Sep 17 00:00:00 2001 From: Ceddaerrix <47855224+Ceddaerrix@users.noreply.github.com> Date: Thu, 12 Oct 2023 12:43:31 +0300 Subject: [PATCH] Allow templating in jenkins.url template (#929) --- charts/jenkins/Chart.yaml | 2 +- charts/jenkins/templates/_helpers.tpl | 4 +-- .../jenkins-controller-ingress-DRY-test.yaml | 26 +++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 charts/jenkins/unittests/jenkins-controller-ingress-DRY-test.yaml diff --git a/charts/jenkins/Chart.yaml b/charts/jenkins/Chart.yaml index 937910e69..2f74e045e 100644 --- a/charts/jenkins/Chart.yaml +++ b/charts/jenkins/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: jenkins home: https://jenkins.io/ -version: 4.7.1 +version: 4.7.2 appVersion: 2.414.2 description: Jenkins - Build great things at any scale! The leading open source automation server, Jenkins provides over 1800 plugins to support building, deploying and automating any project. sources: diff --git a/charts/jenkins/templates/_helpers.tpl b/charts/jenkins/templates/_helpers.tpl index ba663de09..18523a83d 100644 --- a/charts/jenkins/templates/_helpers.tpl +++ b/charts/jenkins/templates/_helpers.tpl @@ -88,9 +88,9 @@ Returns the Jenkins URL {{- else }} {{- if .Values.controller.ingress.hostName }} {{- if .Values.controller.ingress.tls }} - {{- default "https" .Values.controller.jenkinsUrlProtocol }}://{{ .Values.controller.ingress.hostName }}{{ default "" .Values.controller.jenkinsUriPrefix }} + {{- default "https" .Values.controller.jenkinsUrlProtocol }}://{{ tpl .Values.controller.ingress.hostName $ }}{{ default "" .Values.controller.jenkinsUriPrefix }} {{- else }} - {{- default "http" .Values.controller.jenkinsUrlProtocol }}://{{ .Values.controller.ingress.hostName }}{{ default "" .Values.controller.jenkinsUriPrefix }} + {{- default "http" .Values.controller.jenkinsUrlProtocol }}://{{ tpl .Values.controller.ingress.hostName $ }}{{ default "" .Values.controller.jenkinsUriPrefix }} {{- end }} {{- else }} {{- default "http" .Values.controller.jenkinsUrlProtocol }}://{{ template "jenkins.fullname" . }}:{{.Values.controller.servicePort}}{{ default "" .Values.controller.jenkinsUriPrefix }} diff --git a/charts/jenkins/unittests/jenkins-controller-ingress-DRY-test.yaml b/charts/jenkins/unittests/jenkins-controller-ingress-DRY-test.yaml new file mode 100644 index 000000000..a57e667a4 --- /dev/null +++ b/charts/jenkins/unittests/jenkins-controller-ingress-DRY-test.yaml @@ -0,0 +1,26 @@ +suite: Controller Ingress - DRY Support +release: + name: my-release + namespace: my-namespace +templates: + - jenkins-controller-ingress.yaml + - jcasc-config.yaml +tests: + - it: controller-ingress + template: jenkins-controller-ingress.yaml + set: + global.jenkinsHostname: "jenkins.example.com" + controller.ingress: + enabled: true + hostName: "{{ .Values.global.jenkinsHostname }}" + resourceRootUrl: "{{ .Values.global.jenkinsHostname }}" + tls: + - hosts: + - "{{ .Values.global.jenkinsHostname }}" + asserts: + - equal: + path: spec.rules[0].host + value: "jenkins.example.com" + - equal: + path: spec.tls[0].hosts[0] + value: "jenkins.example.com"