diff --git a/chart/charts/crds/templates/_helpers.tpl b/chart/charts/crds/templates/_helpers.tpl new file mode 100644 index 000000000..6f667038b --- /dev/null +++ b/chart/charts/crds/templates/_helpers.tpl @@ -0,0 +1,19 @@ +{{/* vim: set filetype=mustache: */}} + +{{/* + This returns a "1" if the CRD is absent in the cluster + Usage: + {{- if (include "crdIsAbsent" (list )) -}} + # CRD Yaml + {{- end -}} +*/}} +{{- define "crdIsAbsent" -}} + {{- $crdName := index . 0 -}} + {{- $crd := lookup "apiextensions.k8s.io/v1" "CustomResourceDefinition" "" $crdName -}} + {{- $output := "1" -}} + {{- if $crd -}} + {{- $output = "" -}} + {{- end -}} + + {{- $output -}} +{{- end -}} \ No newline at end of file diff --git a/chart/charts/crds/templates/csi-volume-snapshot-class.yaml b/chart/charts/crds/templates/csi-volume-snapshot-class.yaml index 7082a976f..c4a126935 100644 --- a/chart/charts/crds/templates/csi-volume-snapshot-class.yaml +++ b/chart/charts/crds/templates/csi-volume-snapshot-class.yaml @@ -1,4 +1,6 @@ {{- if and .Values.volumeSnapshots.enabled .Values.volumeSnapshots.snapshotClassesEnabled -}} +{{- $crdName := "volumesnapshotclasses.snapshot.storage.k8s.io" -}} +{{- if (include "crdIsAbsent" (list $crdName)) -}} apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -147,3 +149,4 @@ status: conditions: [] storedVersions: [] {{- end -}} +{{- end -}} diff --git a/chart/charts/crds/templates/csi-volume-snapshot-content.yaml b/chart/charts/crds/templates/csi-volume-snapshot-content.yaml index eac326f8b..55a42277c 100644 --- a/chart/charts/crds/templates/csi-volume-snapshot-content.yaml +++ b/chart/charts/crds/templates/csi-volume-snapshot-content.yaml @@ -1,4 +1,6 @@ {{- if and .Values.volumeSnapshots.enabled .Values.volumeSnapshots.snapshotContentsEnabled -}} +{{- $crdName := "volumesnapshotcontents.snapshot.storage.k8s.io" -}} +{{- if (include "crdIsAbsent" (list $crdName)) -}} apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -485,3 +487,4 @@ status: conditions: [] storedVersions: [] {{- end -}} +{{- end -}} diff --git a/chart/charts/crds/templates/csi-volume-snapshot.yaml b/chart/charts/crds/templates/csi-volume-snapshot.yaml index 89eac02fd..8d6f220f1 100644 --- a/chart/charts/crds/templates/csi-volume-snapshot.yaml +++ b/chart/charts/crds/templates/csi-volume-snapshot.yaml @@ -1,4 +1,6 @@ {{- if and .Values.volumeSnapshots.enabled .Values.volumeSnapshots.snapshotsEnabled -}} +{{- $crdName := "volumesnapshots.snapshot.storage.k8s.io" -}} +{{- if (include "crdIsAbsent" (list $crdName)) -}} apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -387,3 +389,4 @@ status: conditions: [] storedVersions: [] {{- end -}} +{{- end -}} diff --git a/chart/charts/crds/templates/jaeger.yaml b/chart/charts/crds/templates/jaeger.yaml index 4de8ab433..d34c2361e 100644 --- a/chart/charts/crds/templates/jaeger.yaml +++ b/chart/charts/crds/templates/jaeger.yaml @@ -1,4 +1,6 @@ {{- if .Values.jaeger.enabled -}} +{{- $crdName := "jaegers.jaegertracing.io" -}} +{{- if (include "crdIsAbsent" (list $crdName)) -}} apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -44,3 +46,4 @@ spec: subresources: status: {} {{- end -}} +{{- end -}}