From aeaeae2de2ed8607ea258a96e5ea365b7d329d4b Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Mon, 29 May 2023 09:44:00 +0200 Subject: [PATCH] fix: remove tc-system namespace creation and fix operator verification code (#442) 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-test/default-values.yaml | 3 --- .../tests/defaults/defaults-test.yaml | 18 +++--------------- library/common/Chart.yaml | 2 +- .../templates/lib/util/_tc_namespace.tpl | 17 ----------------- .../templates/lib/util/_verify_operator.tpl | 14 ++++++++------ library/common/templates/loader/_init.tpl | 3 --- library/common/values.yaml | 2 -- 7 files changed, 12 insertions(+), 47 deletions(-) delete mode 100644 library/common/templates/lib/util/_tc_namespace.tpl diff --git a/library/common-test/default-values.yaml b/library/common-test/default-values.yaml index 8216b707..1083365f 100644 --- a/library/common-test/default-values.yaml +++ b/library/common-test/default-values.yaml @@ -1,6 +1,3 @@ -global: - createTCNamespace: true - workload: main: enabled: true diff --git a/library/common-test/tests/defaults/defaults-test.yaml b/library/common-test/tests/defaults/defaults-test.yaml index 1fffd88b..18dab5fb 100644 --- a/library/common-test/tests/defaults/defaults-test.yaml +++ b/library/common-test/tests/defaults/defaults-test.yaml @@ -4,8 +4,6 @@ templates: tests: - it: should pass with defaults set: - global: - createTCNamespace: true service: main: enabled: true @@ -22,21 +20,11 @@ tests: enabled: true asserts: - hasDocuments: - count: 3 - - documentIndex: &namespaceDoc 0 - isKind: - of: Namespace - - documentIndex: *namespaceDoc - equal: - path: metadata.name - value: tc-system - - documentIndex: *namespaceDoc - isAPIVersion: - of: v1 - - documentIndex: &deploymentDoc 1 + count: 2 + - documentIndex: &deploymentDoc 0 isKind: of: Deployment - - documentIndex: &serviceDoc 2 + - documentIndex: &serviceDoc 1 isKind: of: Service - documentIndex: *serviceDoc diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index b668c90e..96a702e0 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 12.10.7 +version: 12.10.8 diff --git a/library/common/templates/lib/util/_tc_namespace.tpl b/library/common/templates/lib/util/_tc_namespace.tpl deleted file mode 100644 index 4bdd8dee..00000000 --- a/library/common/templates/lib/util/_tc_namespace.tpl +++ /dev/null @@ -1,17 +0,0 @@ -{{- define "tc.v1.common.lib.util.tcnamespace" -}} - {{- if $.Values.global.createTCNamespace -}} - {{/* Only create it if it does not exist */}} - {{- if not (lookup "v1" "Namespace" "" "tc-system") }} ---- -apiVersion: v1 -kind: Namespace -metadata: - name: tc-system - annotations: - "helm.sh/resource-policy": keep - "helm.sh/hook": pre-install - "helm.sh/hook-weight": "-20" - "helm.sh/hook-delete-policy": hook-failed - {{- end -}} - {{- end -}} -{{- end -}} diff --git a/library/common/templates/lib/util/_verify_operator.tpl b/library/common/templates/lib/util/_verify_operator.tpl index 94177dd9..79fc0540 100644 --- a/library/common/templates/lib/util/_verify_operator.tpl +++ b/library/common/templates/lib/util/_verify_operator.tpl @@ -19,13 +19,15 @@ {{/* Go over all configmaps */}} {{- range $index, $cm := (lookup "v1" "ConfigMap" "" "").items -}} - {{/* If "tc-operator-name" does not exist will return "" */}} - {{- $name := (get $cm.data "tc-operator-name") -}} + {{- if $cm.data -}} + {{/* If "tc-operator-name" does not exist will return "" */}} + {{- $name := (get $cm.data "tc-operator-name") -}} - {{/* If fetched name matches the "$opName"... */}} - {{- if eq $name $opName -}} - {{/* Mark operator as found*/}} - {{- $opExists = true -}} + {{/* If fetched name matches the "$opName"... */}} + {{- if eq $name $opName -}} + {{/* Mark operator as found*/}} + {{- $opExists = true -}} + {{- end -}} {{- end -}} {{- end -}} diff --git a/library/common/templates/loader/_init.tpl b/library/common/templates/loader/_init.tpl index 7e881675..9077208e 100644 --- a/library/common/templates/loader/_init.tpl +++ b/library/common/templates/loader/_init.tpl @@ -4,9 +4,6 @@ {{/* Merge chart values and the common chart defaults */}} {{- include "tc.v1.common.values.init" . -}} - {{/* Create tc-system namespace */}} - {{- include "tc.v1.common.lib.util.tcnamespace" . -}} - {{/* Parse lists and append to values */}} {{- include "tc.v1.common.loader.lists" . -}} diff --git a/library/common/values.yaml b/library/common/values.yaml index 4be3a0fc..a5fbd95a 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -13,8 +13,6 @@ global: # -- Enable to stop most pods and containers including cnpg # does not include stand-alone pods stopAll: false - # -- Creates the tc-system namespace. Used for operator charts - createTCNamespace: true fallbackDefaults: # -- Define a storageClassName that will be used for all PVCs