Skip to content

Commit

Permalink
Add Helm v2 hooks for CRDs from _helpers template
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Cezar <[email protected]>
  • Loading branch information
igorcezar committed Oct 15, 2020
1 parent aa4cfc6 commit b92e0bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions charts/velero/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,11 @@ Create the volume snapshot location provider
{{ default .provider .volumeSnapshotLocation.provider }}
{{- end -}}
{{- end -}}

{{/*
Helm hooks for Helm v2 CRDs
*/}}
{{- define "velero.helmhooks.crds" -}}
{{ print "\"helm.sh/hook\": pre-install,pre-upgrade" | indent 4 }}
{{ print "\"helm.sh/hook-delete-policy\": \"before-hook-creation\"" | indent 4 }}
{{- end -}}
7 changes: 5 additions & 2 deletions charts/velero/templates/crds.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{{- if and .Values.installCRDs (eq .Release.Service "Tiller") }}
{{- range $path, $bytes := .Files.Glob "crds/*.yaml" }}
{{- if $.Values.enableHelmHooks }}
{{- if not $.Values.enableHelmHooks }}
{{ $.Files.Get $path }}
{{- else }}
{{- range $.Files.Lines $path }}
{{- if not ( contains "helm.sh/hook" . ) }}
{{- if contains "annotations:" . }}
{{ . }}
{{ template "velero.helmhooks.crds" . }}
{{- else }}
{{ . }}
{{- end }}
{{- end }}
Expand Down

0 comments on commit b92e0bc

Please sign in to comment.