1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-28 18:38:40 +00:00

Auto-detect Kyverno version in policies chart (#4460)

* Auto-detect Kyverno version in policies chart

Signed-off-by: David Young <davidy@funkypenguin.co.nz>

* Don't bump chart (another process will do this)

Signed-off-by: David Young <davidy@funkypenguin.co.nz>

* Also don't bump version in README

Signed-off-by: David Young <davidy@funkypenguin.co.nz>

Signed-off-by: David Young <davidy@funkypenguin.co.nz>
Co-authored-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
This commit is contained in:
David Young 2022-09-03 03:41:02 +12:00 committed by GitHub
parent 7c9792d03f
commit eb96862cd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 0 deletions

View file

@ -23,6 +23,8 @@ annotations:
artifacthub.io/prerelease: "false"
# valid kinds are: added, changed, deprecated, removed, fixed and security
artifacthub.io/changes: |
- kind: added
description: Add possibility to manually set kyvernoVersion and avoid autodetection
- kind: added
description: Support for artifacthub.io/changes annotation
- kind: fixed

View file

@ -77,6 +77,7 @@ The command removes all the Kubernetes components associated with the chart and
| nameOverride | string | `nil` | Name override. |
| customLabels | object | `{}` | Additional labels. |
| background | bool | `true` | Policies background mode |
| kyvernoVersion | string | `"autodetect"` | Kyverno version The default of "autodetect" will try to determine the currently installed version from the deployment |
## Source Code

View file

@ -59,6 +59,7 @@ helm.sh/chart: {{ template "kyverno-policies.chart" . }}
{{/* Get deployed Kyverno version from Kubernetes */}}
{{- define "kyverno-policies.kyvernoVersion" -}}
{{- $version := "" -}}
{{- if eq .Values.kyvernoVersion "autodetect" }}
{{- with (lookup "apps/v1" "Deployment" .Release.Namespace "kyverno") -}}
{{- with (first .spec.template.spec.containers) -}}
{{- $imageTag := (last (splitList ":" .image)) -}}
@ -66,6 +67,9 @@ helm.sh/chart: {{ template "kyverno-policies.chart" . }}
{{- end -}}
{{- end -}}
{{ $version }}
{{- else -}}
{{ .Values.kyvernoVersion }}
{{- end -}}
{{- end -}}
{{/* Fail if deployed Kyverno does not match */}}

View file

@ -92,3 +92,7 @@ customLabels: {}
# -- Policies background mode
background: true
# -- Kyverno version
# The default of "autodetect" will try to determine the currently installed version from the deployment
kyvernoVersion: autodetect