From a39e1ed2127ba65287c00acdcaf1806f12752400 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sat, 7 Oct 2023 21:46:48 +0300 Subject: [PATCH] fix(redis-creds): do not use redisUsername if its empty (#527) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 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:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ 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/Chart.yaml | 2 +- .../common/templates/lib/dependencies/_redisInjector.tpl | 8 ++++++-- .../common/templates/lib/imagePullSecret/_createData.tpl | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 1d9e680e..8fca2241 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 14.0.6 +version: 14.0.7 diff --git a/library/common/templates/lib/dependencies/_redisInjector.tpl b/library/common/templates/lib/dependencies/_redisInjector.tpl index 68601649..e4a6dbec 100644 --- a/library/common/templates/lib/dependencies/_redisInjector.tpl +++ b/library/common/templates/lib/dependencies/_redisInjector.tpl @@ -15,11 +15,15 @@ This template generates a random password and ensures it persists across updates {{- $dbPass = (index $dbprevious.data "redis-password") | b64dec -}} {{- end -}} + {{- $redisUser := .Values.redis.redisUsername -}} + {{- if not $redisUser -}}{{/* If you try to print a nil value it will print as */}} + {{- $redisUser = "" -}} + {{- end -}} {{/* Prepare data */}} {{- $dbHost := printf "%v-%v" .Release.Name "redis" -}} {{- $portHost := printf "%v:6379" $dbHost -}} - {{- $url := printf "redis://%v:%v@%v/%v" .Values.redis.redisUsername $dbPass $portHost $dbIndex -}} - {{- $hostPass := printf "%v:%v@%v" .Values.redis.redisUsername $dbPass $dbHost -}} + {{- $url := printf "redis://%v:%v@%v/%v" $redisUser $dbPass $portHost $dbIndex -}} + {{- $hostPass := printf "%v:%v@%v" $redisUser $dbPass $dbHost -}} {{/* Append some values to redis.creds, so apps using the dep, can use them */}} {{- $_ := set .Values.redis.creds "redisPassword" ($dbPass | quote) -}} diff --git a/library/common/templates/lib/imagePullSecret/_createData.tpl b/library/common/templates/lib/imagePullSecret/_createData.tpl index cf58a891..5ebef018 100644 --- a/library/common/templates/lib/imagePullSecret/_createData.tpl +++ b/library/common/templates/lib/imagePullSecret/_createData.tpl @@ -21,7 +21,8 @@ objectData: "email" (tpl .email $rootCtx) "auth" $auth) -}} {{- end -}} - {{- $_ := set $registrySecret "auths" (dict (tpl $objectData.data.registry $rootCtx) $registry) -}} + {{- $registryKey := tpl $objectData.data.registry $rootCtx -}} + {{- $_ := set $registrySecret "auths" (dict $registryKey $registry) -}} {{/* This should result in something like this: