Skip to content

Instantly share code, notes, and snippets.

@stefanooldeman
Last active August 2, 2018 09:06
Show Gist options
  • Save stefanooldeman/d9b5f7f55309017f3e27ac06b1146672 to your computer and use it in GitHub Desktop.
Save stefanooldeman/d9b5f7f55309017f3e27ac06b1146672 to your computer and use it in GitHub Desktop.
my helm chart template functions
{{/*
imagePullPolicy:
this function will parse the imageTag with semver
imagePullPolicy is determined based of a versions prerelease
example usage:
```
image: {{ .Values.ImageTag }}
{{ include "imagePullPolicy" .Values.ImageTag | indent 8 }}
env: ...
```
*/}}
{{- define "imagePullPolicy" -}}
{{ $parsed := replace "_" "+" . | semver -}}
# semver prerelease: '{{ print $parsed.Prerelease }}'
# semver build metadata: '{{ print $parsed.Metadata }}'
{{- if eq $parsed.Prerelease "SNAPSHOT" }}
imagePullPolicy: Always
{{- else }}
imagePullPolicy: IfNotPresent
{{- end }}
# imagePullPolicy is set by "imagePullPolicy" in _helpers.tpl
{{- end -}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment