feat(common): tweak operator verification behavior (#443)

**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?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ 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>
This commit is contained in:
Kjeld Schouten
2023-05-30 22:24:59 +02:00
committed by GitHub
parent aeaeae2de2
commit d064d44ff7
4 changed files with 12 additions and 2 deletions

View File

@@ -19,6 +19,9 @@ service:
ports:
main:
enabled: false
operator:
verify:
failOnError: true
manifestManager:
enabled: false

View File

@@ -15,4 +15,4 @@ maintainers:
name: common
sources: null
type: library
version: 12.10.8
version: 12.10.9

View File

@@ -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 -}}

View File

@@ -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: []