From 71ce0b08138111cf7b552ba7f885d4374acbf301 Mon Sep 17 00:00:00 2001 From: annekebr <44376590+annekebr@users.noreply.github.com> Date: Fri, 26 Nov 2021 11:04:21 +0100 Subject: [PATCH 1/8] refactor: add jsonschema validation for values.yaml Adding a jsonschema allows user to fail early as the user configuration in the is validated at installation time already. For that reason, there has been added additional validation that couldn't be performed using jsonschema in the helm helper file. Moreover, as we now have our dear conny in artifacthub we can enhance our artifacthub page by adding a jsonschema as artifacthub parses the file and shows its content in a nice format. --- .github/PULL_REQUEST_TEMPLATE.md | 1 + helm/Chart.yaml | 2 +- helm/templates/_helpers.tpl | 68 ++ helm/templates/alertconfig.yaml | 4 +- helm/templates/config.yaml | 2 + helm/values.schema.json | 1810 ++++++++++++++++++++++++++++++ 6 files changed, 1885 insertions(+), 2 deletions(-) create mode 100644 helm/values.schema.json diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 2394c60b4..351265365 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,5 +14,6 @@ Fixes # - [ ] PR follows [Contributing Guide](../docs/CONTRIBUTING.md) - [ ] Added tests (if necessary) - [ ] Extended README/Documentation (if necessary) +- [ ] Adjusted `helm/values.schema.json` according to new changes if `helm/values.yaml` has been touched - [ ] Adjusted versions of image and Helm chart in `values.yaml` and `Chart.yaml` (if necessary) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 27de00e4c..5dbe9467d 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: connaisseur description: Helm chart for Connaisseur - a Kubernetes admission controller to integrate container image signature verification and trust pinning into a cluster. type: application -version: 1.2.1 +version: 1.2.2 appVersion: 2.4.1 keywords: - container image diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 06f2c19bf..aaea644d0 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -184,3 +184,71 @@ Extract Kubernetes Minor Version. readOnly: true {{- end -}} {{- end -}} +{{- define "checkForAlertTemplates" -}} + {{ $files := .Files }} + {{- if .Values.alerting }} + {{- if .Values.alerting.admit_request }} + {{- if .Values.alerting.admit_request.templates }} + {{- range .Values.alerting.admit_request.templates }} + {{- $filename := .template -}} + {{- $file := printf "alert_payload_templates/%s.json" $filename | $files.Get }} + {{- if $file }} + {{- else }} + {{- fail (printf "The value of the alert template must be chosen such that