Skip to content

Instantly share code, notes, and snippets.

@xr09
Last active November 15, 2024 12:16
Show Gist options
  • Save xr09/e760aeee47df08c2b1a81b33f378161c to your computer and use it in GitHub Desktop.
Save xr09/e760aeee47df08c2b1a81b33f378161c to your computer and use it in GitHub Desktop.
check helm minimum version
{{- define "check-minimum-helm-version" -}}
{{- $majorRequired := 3 -}}
{{- $minorRequired := 7 -}}
{{- $match := .Capabilities.HelmVersion.Version | toString | regexFind "^v[0-9]+\\.[0-9]+\\." -}}
{{- $major := $match | trimPrefix "v" | trimSuffix "." | regexFind "[0-9]+\\." | trimAll "." | int -}}
{{- $minor := $match | trimPrefix "v" | trimSuffix "." | regexFind "\\.[0-9]+" | trimAll "." | int -}}
{{- if (lt $major $majorRequired) }}
{{- fail "Helm version is too old, please upgrade to at least Helm 3.7" }}
{{- else if and ( eq $major $majorRequired ) (lt $minor $minorRequired) }}
{{- fail "Helm version is too old, please upgrade to at least Helm 3.7" }}
{{- end }}
{{- end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment