From d064d44ff7120bbd9a77698331b9b08954180ff0 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Tue, 30 May 2023 22:24:59 +0200 Subject: [PATCH] feat(common): tweak operator verification behavior (#443) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** We need to actually save the found operator data for use with the charts We also need an option to start deploying this in a soft-failing way **โš™๏ธ 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._ --------- Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- library/common-test/values.yaml | 3 +++ library/common/Chart.yaml | 2 +- library/common/templates/lib/util/_verify_operator.tpl | 8 +++++++- library/common/values.yaml | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/library/common-test/values.yaml b/library/common-test/values.yaml index 3d760be3..33be6a5c 100644 --- a/library/common-test/values.yaml +++ b/library/common-test/values.yaml @@ -19,6 +19,9 @@ service: ports: main: enabled: false +operator: + verify: + failOnError: true manifestManager: enabled: false diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 96a702e0..06ddb13d 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.8 +version: 12.10.9 diff --git a/library/common/templates/lib/util/_verify_operator.tpl b/library/common/templates/lib/util/_verify_operator.tpl index 79fc0540..c395ce68 100644 --- a/library/common/templates/lib/util/_verify_operator.tpl +++ b/library/common/templates/lib/util/_verify_operator.tpl @@ -5,7 +5,7 @@ {{- $opExists := include "tc.v1.common.lib.util.operator.verify" (dict "rootCtx" $ "opName" $opName) -}} {{/* If the operator was not found */}} - {{- if eq $opExists "false" -}} + {{- if and (eq $opExists "false") ($.Values.operator.verify.failOnError) -}} {{- fail (printf "Operator [%s] have to be installed first" $opName) -}} {{- end -}} {{- end -}} @@ -22,11 +22,17 @@ {{- if $cm.data -}} {{/* If "tc-operator-name" does not exist will return "" */}} {{- $name := (get $cm.data "tc-operator-name") -}} + {{- $version := (get $cm.data "tc-operator-version") -}} {{/* If fetched name matches the "$opName"... */}} {{- if eq $name $opName -}} + {{- if $opExists -}} + {{- fail (printf "Found duplicate configmaps for operator [%s]" $opName) -}} + {{- end -}} {{/* Mark operator as found*/}} {{- $opExists = true -}} + {{- $operatorData := dict "name" $name "namespace" $cm.metadata.namespace "version" $version -}} + {{- $_ := set $.Values.operator $opName $operatorData -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/library/common/values.yaml b/library/common/values.yaml index a5fbd95a..f2ddb17e 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -564,6 +564,7 @@ operator: # -- Verified wether required operators for this chart are actually installed and registered verify: enabled: true + failOnError: false # -- a list of extra operators to check for additionalOperators: []