From 02c0f5f38626d2295845aeb448a812fc04f2fa4a Mon Sep 17 00:00:00 2001 From: Aspen Date: Wed, 9 Jul 2025 05:49:07 -0700 Subject: [PATCH] fix(common): correct skipEmptyWalArchiveCheck template syntax in cluster (#37317) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the _cluster.tpl file to ensure the skipEmptyWalArchiveCheck annotation is properly rendered. Added a new test case in cluster_metadata_test.yaml to verify the correct behavior of the annotation. **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [x] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code - [ ] 📜 Documentation Changes **🧪 How Has This Been Tested?** Added unit tests to verify the annotation **📃 Notes:** **✔️ Checklist:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made changes to the documentation - [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 - [x] I made sure the title starts with `feat(chart-name):`, `fix(chart-name):`, `chore(chart-name):`, `docs(chart-name):` or `fix(docs):` **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ 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._ --- .../tests/cnpg/cluster_metadata_test.yaml | 14 ++++++++++++++ charts/library/common/Chart.yaml | 2 +- .../common/templates/class/cnpg/_cluster.tpl | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/charts/library/common-test/tests/cnpg/cluster_metadata_test.yaml b/charts/library/common-test/tests/cnpg/cluster_metadata_test.yaml index 9ef0027c7de..f69a6ac308c 100644 --- a/charts/library/common-test/tests/cnpg/cluster_metadata_test.yaml +++ b/charts/library/common-test/tests/cnpg/cluster_metadata_test.yaml @@ -153,3 +153,17 @@ tests: equal: path: metadata.namespace value: local-namespace + + - it: should pass with cnpg with skipEmptyWalArchiveCheck annotation + set: + cnpg: + my-pg: + enabled: true + user: test-user + database: test-db + password: test-password + asserts: + - documentIndex: *clusterDoc + equal: + path: metadata.annotations["cnpg.io/skipEmptyWalArchiveCheck"] + value: "enabled" diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index d551a5b5f4a..c8d46609025 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -48,5 +48,5 @@ sources: - https://hub.docker.com/_/ - https://hub.docker.com/r/mikefarah/yq type: library -version: 28.12.8 +version: 28.12.9 diff --git a/charts/library/common/templates/class/cnpg/_cluster.tpl b/charts/library/common/templates/class/cnpg/_cluster.tpl index ffc1b6ef6b0..2c3dfe27ad3 100644 --- a/charts/library/common/templates/class/cnpg/_cluster.tpl +++ b/charts/library/common/templates/class/cnpg/_cluster.tpl @@ -176,7 +176,9 @@ metadata: annotations: cnpg.io/hibernation: {{ $hibernation | quote }} checksum/secrets: {{ toJson $rootCtx.Values.secret | sha256sum }} - cnpg.io/skipEmptyWalArchiveCheck: $skipEmptyWalArchiveCheck + {{- if $skipEmptyWalArchiveCheck }} + cnpg.io/skipEmptyWalArchiveCheck: "enabled" + {{- end }} {{- $annotations := (mustMerge $clusterAnnotations (include "tc.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }} {{- . | nindent 4 }}