From 850f2022b6b2eb39c8f4204464474ef2f4523848 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Sun, 29 Oct 2023 12:08:38 +0100 Subject: [PATCH] feat(common): add support for clusterCertificate to ingress and readd ingresslist (#542) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** - Changes the name of certificates with a secrettemplate, to make it easier to use kubernetes-reflector and ingress on those, ensures they do not include the fullname namespace of the chart creating the certificate - readds a parser for ingressList, not sure if functional, but at least it exists on a basic level now - Adds the ability to define clusterCertificates on ingress.tls and automatically fix/apply the secrettemplate naming scheme accordingly. **โš™๏ธ Type of change** - [x] โš™๏ธ Feature/App addition - [x] ๐Ÿช› Bugfix - [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] ๐Ÿ”ƒ Refactor of current code **๐Ÿงช How Has This Been Tested?** **๐Ÿ“ƒ Notes:** **โœ”๏ธ Checklist:** - [x] โš–๏ธ My code follows the style guidelines of this project - [x] ๐Ÿ‘€ I have performed a self-review of my own code - [x] #๏ธโƒฃ I have commented my code, particularly in hard-to-understand areas - [x] ๐Ÿ“„ I have made corresponding changes to the documentation - [x] โš ๏ธ My changes generate no new warnings - [x] ๐Ÿงช I have added tests to this description that prove my fix is effective or that my feature works - [x] โฌ†๏ธ I increased versions for any altered app according to semantic versioning **โž• App addition** If this PR is an app addition please make sure you have done the following. - [ ] ๐Ÿชž I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] ๐Ÿ–ผ๏ธ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --- library/common-test/Chart.yaml | 2 +- library/common/Chart.yaml | 2 +- library/common/templates/class/_ingress.tpl | 2 ++ library/common/templates/loader/_lists.tpl | 2 ++ .../common/templates/spawner/_certificate.tpl | 4 ++++ .../templates/values/lists/_ingressList.tpl | 17 +++++++++++++++++ 6 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 library/common/templates/values/lists/_ingressList.tpl diff --git a/library/common-test/Chart.yaml b/library/common-test/Chart.yaml index 9369a52b..cf19bfe9 100644 --- a/library/common-test/Chart.yaml +++ b/library/common-test/Chart.yaml @@ -3,7 +3,7 @@ appVersion: "" dependencies: - name: common repository: file://../common - version: ~14.1.0 + version: ~14.2.0 deprecated: false description: Helper chart to test different use cases of the common library home: https://github.com/truecharts/apps/tree/master/charts/library/common-test diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index a5ea79a3..7ba78b22 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 14.1.1 +version: 14.2.0 diff --git a/library/common/templates/class/_ingress.tpl b/library/common/templates/class/_ingress.tpl index 6f3c6c59..e5f16b91 100644 --- a/library/common/templates/class/_ingress.tpl +++ b/library/common/templates/class/_ingress.tpl @@ -124,6 +124,8 @@ spec: {{- $_ := set $cert "id" $tlsValues.scaleCert }} {{- $_ := set $cert "nameOverride" $tlsName }} secretName: {{ printf "%s-tls-%v" (include "tc.v1.common.lib.chart.names.fullname" $) $index }} + {{- else if .clusterCertificate }} + secretName: clusterissuer-templated-{{ tpl .clusterCertificate $ }} {{- else if .secretName }} secretName: {{ tpl .secretName $ | quote }} {{- end -}} diff --git a/library/common/templates/loader/_lists.tpl b/library/common/templates/loader/_lists.tpl index f1ea7ee6..fc0de770 100644 --- a/library/common/templates/loader/_lists.tpl +++ b/library/common/templates/loader/_lists.tpl @@ -6,4 +6,6 @@ {{- include "tc.v1.common.values.serviceList" . -}} + {{- include "tc.v1.common.values.ingressList" . -}} + {{- end -}} diff --git a/library/common/templates/spawner/_certificate.tpl b/library/common/templates/spawner/_certificate.tpl index 5b53390d..da3db07e 100644 --- a/library/common/templates/spawner/_certificate.tpl +++ b/library/common/templates/spawner/_certificate.tpl @@ -17,6 +17,10 @@ {{- $certName = printf "%v-%v" $certName $certValues.nameOverride -}} {{- end -}} + {{- if $certValues.certificateSecretTemplate -}} + {{- $certName = printf "%v-%v" "clusterissuer-templated" $name -}} + {{- end -}} + {{- include "tc.v1.common.class.certificate" (dict "root" $ "name" $certName "certificateIssuer" $cert.certificateIssuer "hosts" $cert.hosts "secretTemplate" $cert.secretTemplate ) -}} {{- end -}} {{- end -}} diff --git a/library/common/templates/values/lists/_ingressList.tpl b/library/common/templates/values/lists/_ingressList.tpl new file mode 100644 index 00000000..54ba2161 --- /dev/null +++ b/library/common/templates/values/lists/_ingressList.tpl @@ -0,0 +1,17 @@ +{{- define "tc.v1.common.values.ingressList" -}} + {{- $rootCtx := . -}} + + {{- range $idx, $ingressValues := $rootCtx.Values.ingressList -}} + {{- $name := (printf "ingress-list-%s" (toString $idx)) -}} + + {{- with $ingressValues.name -}} + {{- $name = . -}} + {{- end -}} + + {{- if not (hasKey $rootCtx.Values "ingress") -}} + {{- $_ := set $rootCtx.Values "ingress" dict -}} + {{- end -}} + + {{- $_ := set $rootCtx.Values.ingress $name $ingressValues -}} + {{- end -}} +{{- end -}}