From 2f3e793a6ba8d63859f57561efaf6c6e5e2119a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Colombaro?= Date: Thu, 26 Sep 2024 10:42:02 +0200 Subject: [PATCH] [bitnami/cassandra] Use common password manager to handle passwords (#29560) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [bitnami/cassandra] Use common password manager to handle passwords Signed-off-by: Léo Colombaro * Update CHANGELOG.md Signed-off-by: Bitnami Containers * Update CHANGELOG.md Signed-off-by: Bitnami Containers --------- Signed-off-by: Léo Colombaro Signed-off-by: Bitnami Containers Co-authored-by: Bitnami Containers --- bitnami/cassandra/CHANGELOG.md | 17 +++++++-- bitnami/cassandra/Chart.yaml | 2 +- bitnami/cassandra/templates/_helpers.tpl | 35 ++----------------- .../cassandra/templates/cassandra-secret.yaml | 6 ++-- 4 files changed, 21 insertions(+), 39 deletions(-) diff --git a/bitnami/cassandra/CHANGELOG.md b/bitnami/cassandra/CHANGELOG.md index 74f5d88a05..6a961b293e 100644 --- a/bitnami/cassandra/CHANGELOG.md +++ b/bitnami/cassandra/CHANGELOG.md @@ -1,8 +1,16 @@ # Changelog -## 12.0.1 (2024-09-10) +## 12.0.2 (2024-09-26) -* [bitnami/cassandra] Release 12.0.1 ([#29339](https://github.com/bitnami/charts/pull/29339)) +* [bitnami/cassandra] Use common password manager to handle passwords ([#29560](https://github.com/bitnami/charts/pull/29560)) + +## 12.0.1 (2024-09-10) + +* [bitnami/cassandra] Release 12.0.1 (#29339) ([0349ba2](https://github.com/bitnami/charts/commit/0349ba298f17cef36647d887f74cc9600be00be5)), closes [#29339](https://github.com/bitnami/charts/issues/29339) + +## 12.0.0 (2024-09-10) + +* [bitnami/cassandra] Release 12.0.0 (#29305) ([a1acd8f](https://github.com/bitnami/charts/commit/a1acd8f74562ec3d85d0ee11e6d22c9d426699df)), closes [#29305](https://github.com/bitnami/charts/issues/29305) ## 11.4.2 (2024-09-04) @@ -10,8 +18,11 @@ ## 11.4.1 (2024-09-03) -* [bitnami/cassandra] feat: :sparkles: Allow setting initdb scripts in values (#29172) ([0aaac20](https://github.com/bitnami/charts/commit/0aaac209548b8c38af586322dbda2e86e8830600)), closes [#29172](https://github.com/bitnami/charts/issues/29172) * [bitnami/cassandra] test: :white_check_mark: Improve ginkgo testing reliability (#29177) ([28cf5f7](https://github.com/bitnami/charts/commit/28cf5f7b8e48370b31d79ed596fd26697ac4a0dc)), closes [#29177](https://github.com/bitnami/charts/issues/29177) + +## 11.4.0 (2024-09-03) + +* [bitnami/cassandra] feat: :sparkles: Allow setting initdb scripts in values (#29172) ([0aaac20](https://github.com/bitnami/charts/commit/0aaac209548b8c38af586322dbda2e86e8830600)), closes [#29172](https://github.com/bitnami/charts/issues/29172) * Update README.md (#29126) ([0d5e4f8](https://github.com/bitnami/charts/commit/0d5e4f85cd10e48fcf53dc6a9d69b2f4a4c8ae34)), closes [#29126](https://github.com/bitnami/charts/issues/29126) ## 11.3.14 (2024-08-28) diff --git a/bitnami/cassandra/Chart.yaml b/bitnami/cassandra/Chart.yaml index f45025f167..e6029b7cc7 100644 --- a/bitnami/cassandra/Chart.yaml +++ b/bitnami/cassandra/Chart.yaml @@ -32,4 +32,4 @@ maintainers: name: cassandra sources: - https://github.com/bitnami/charts/tree/main/bitnami/cassandra -version: 12.0.1 +version: 12.0.2 diff --git a/bitnami/cassandra/templates/_helpers.tpl b/bitnami/cassandra/templates/_helpers.tpl index 5f068dc1b4..0d271d9b83 100644 --- a/bitnami/cassandra/templates/_helpers.tpl +++ b/bitnami/cassandra/templates/_helpers.tpl @@ -250,42 +250,13 @@ Return true if a TLS credentials secret object should be created {{- end -}} {{/* -Returns the available value for certain key in an existing secret (if it exists), -otherwise it generates a random value. +Get the password to use to access Cassandra */}} -{{- define "getValueFromSecret" }} - {{- $len := (default 16 .Length) | int -}} - {{- $obj := (lookup "v1" "Secret" .Namespace .Name).data -}} - {{- if $obj }} - {{- index $obj .Key | b64dec -}} - {{- else -}} - {{- randAlphaNum $len -}} - {{- end -}} -{{- end }} - {{- define "cassandra.password" -}} - {{- if .Values.dbUser.password }} - {{- .Values.dbUser.password }} - {{- else if (not .Values.dbUser.forcePassword) }} - {{- include "getValueFromSecret" (dict "Namespace" (include "common.names.namespace" .) "Name" (include "common.names.fullname" .) "Length" 10 "Key" "cassandra-password") -}} - {{- else }} + {{- if (and (empty .Values.dbUser.password) .Values.dbUser.forcePassword) }} {{ required "A Cassandra Password is required!" .Values.dbUser.password }} - {{- end }} -{{- end -}} - -{{- define "cassandra.keystore.password" -}} - {{- if .Values.tls.keystorePassword }} - {{- .Values.tls.keystorePassword }} {{- else }} - {{- include "getValueFromSecret" (dict "Namespace" (include "common.names.namespace" .) "Name" (printf "%s-%s" (include "common.names.fullname" .) "tls-pass" | trunc 63 | trimSuffix "-") "Length" 10 "Key" "keystore-password") -}} - {{- end }} -{{- end -}} - -{{- define "cassandra.truststore.password" -}} - {{- if .Values.tls.truststorePassword }} - {{- .Values.tls.truststorePassword }} - {{- else }} - {{- include "getValueFromSecret" (dict "Namespace" (include "common.names.namespace" .) "Name" (printf "%s-%s" (include "common.names.fullname" .) "tls-pass" | trunc 63 | trimSuffix "-") "Length" 10 "Key" "truststore-password") -}} + {{- include "common.secrets.passwords.manage" (dict "secret" (include "common.names.fullname" .) "key" "cassandra-password" "providedValues" (list "dbUser.password") "context" $) -}} {{- end }} {{- end -}} diff --git a/bitnami/cassandra/templates/cassandra-secret.yaml b/bitnami/cassandra/templates/cassandra-secret.yaml index a00baf9df7..1ad025b424 100644 --- a/bitnami/cassandra/templates/cassandra-secret.yaml +++ b/bitnami/cassandra/templates/cassandra-secret.yaml @@ -15,7 +15,7 @@ metadata: {{- end }} type: Opaque data: - cassandra-password: {{ include "cassandra.password" . | b64enc | quote }} + cassandra-password: {{ include "cassandra.password" . }} {{ end }} {{- if and (or .Values.tls.keystorePassword .Values.tls.truststorePassword .Values.tls.autoGenerated) (not .Values.tls.passwordsSecret) (not .Values.tls.tlsEncryptionSecretName) }} --- @@ -31,9 +31,9 @@ metadata: type: Opaque data: {{- if or .Values.tls.keystorePassword .Values.tls.autoGenerated }} - keystore-password: {{ include "cassandra.keystore.password" . | b64enc | quote }} + keystore-password: {{ include "common.secrets.passwords.manage" (dict "secret" (printf "%s-%s" (include "common.names.fullname" .) "tls-pass" | trunc 63 | trimSuffix "-") "key" "keystore-password" "providedValues" (list "tls.keystorePassword") "context" $) }} {{- end }} {{- if or .Values.tls.truststorePassword .Values.tls.autoGenerated }} - truststore-password: {{ include "cassandra.truststore.password" . | b64enc | quote }} + truststore-password: {{ include "common.secrets.passwords.manage" (dict "secret" (printf "%s-%s" (include "common.names.fullname" .) "tls-pass" | trunc 63 | trimSuffix "-") "key" "truststore-password" "providedValues" (list "tls.truststorePassword") "context" $) }} {{- end }} {{- end }}