Skip to content

Commit

Permalink
chore(bors): merge pull request #459
Browse files Browse the repository at this point in the history
459: Cherry helm PR 458 r=tiagolobocastro a=tiagolobocastro

<!

Co-authored-by: cmontemuino <[email protected]>
  • Loading branch information
mayastor-bors and cmontemuino committed Apr 2, 2024
2 parents 0da7271 + 3262b9f commit 747d349
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 25 deletions.
4 changes: 4 additions & 0 deletions chart/charts/crds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ A Helm chart that collects CustomResourceDefinitions (CRDs) from Mayastor.

| Key | Description | Default |
|:----|:------------|:--------|
| csi.&ZeroWidthSpace;volumeSnapshots.&ZeroWidthSpace;annotations | Annotations to be added to all CRDs | <pre>{<br><br>}</pre> |
| csi.&ZeroWidthSpace;volumeSnapshots.&ZeroWidthSpace;enabled | Install Volume Snapshot CRDs | `true` |
| csi.&ZeroWidthSpace;volumeSnapshots.&ZeroWidthSpace;keep | Keep CRDs on chart uninstall | `true` |
| jaeger.&ZeroWidthSpace;annotations | Annotations to be added to all CRDs | <pre>{<br><br>}</pre> |
| jaeger.&ZeroWidthSpace;enabled | Install Jaeger CRDs | `true` |
| jaeger.&ZeroWidthSpace;keep | Keep CRDs on chart uninstall | `true` |

27 changes: 14 additions & 13 deletions chart/charts/crds/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{{/* vim: set filetype=mustache: */}}

{{/*
This returns a "1" if the CRD is absent in the cluster
Adds extra annotations to CRDs. This targets two scenarios: preventing CRD recycling in case
the chart is removed; and adding custom annotations.
NOTE: This function assumes the element `metadata.annotations` already exists.
Usage:
{{- if (include "crdIsAbsent" (list <crd-name>)) -}}
# CRD Yaml
{{- end -}}
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
*/}}
{{- define "crdIsAbsent" -}}
{{- $crdName := index . 0 -}}
{{- $crd := lookup "apiextensions.k8s.io/v1" "CustomResourceDefinition" "" $crdName -}}
{{- $output := "1" -}}
{{- if $crd -}}
{{- $output = "" -}}
{{- end -}}

{{- $output -}}
{{- end -}}
{{- define "crds.extraAnnotations" -}}
{{- if .keep -}}
helm.sh/resource-policy: keep
{{ end }}
{{- with .annotations }}
{{- toYaml . }}
{{- end }}
{{- end -}}

4 changes: 1 addition & 3 deletions chart/charts/crds/templates/csi-volume-snapshot-class.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{- if .Values.csi.volumeSnapshots.enabled -}}
{{- $crdName := "volumesnapshotclasses.snapshot.storage.k8s.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
controller-gen.kubebuilder.io/version: v0.11.3
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
creationTimestamp: null
name: volumesnapshotclasses.snapshot.storage.k8s.io
spec:
Expand Down Expand Up @@ -149,4 +148,3 @@ status:
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
4 changes: 1 addition & 3 deletions chart/charts/crds/templates/csi-volume-snapshot-content.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{- if .Values.csi.volumeSnapshots.enabled -}}
{{- $crdName := "volumesnapshotcontents.snapshot.storage.k8s.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
controller-gen.kubebuilder.io/version: v0.11.3
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
creationTimestamp: null
name: volumesnapshotcontents.snapshot.storage.k8s.io
spec:
Expand Down Expand Up @@ -487,4 +486,3 @@ status:
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
4 changes: 1 addition & 3 deletions chart/charts/crds/templates/csi-volume-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{- if .Values.csi.volumeSnapshots.enabled -}}
{{- $crdName := "volumesnapshots.snapshot.storage.k8s.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
controller-gen.kubebuilder.io/version: v0.11.3
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
creationTimestamp: null
name: volumesnapshots.snapshot.storage.k8s.io
spec:
Expand Down Expand Up @@ -389,4 +388,3 @@ status:
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
7 changes: 4 additions & 3 deletions chart/charts/crds/templates/jaeger.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{{- if .Values.jaeger.enabled -}}
{{- $crdName := "jaegers.jaegertracing.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: jaegers.jaegertracing.io
{{- if or (.Values.jaeger.keep) (.Values.jaeger.annotations) }}
annotations:
{{- include "crds.extraAnnotations" .Values.jaeger | nindent 4 }}
{{- end }}
labels:
app: jaeger-operator
spec:
Expand Down Expand Up @@ -46,4 +48,3 @@ spec:
subresources:
status: {}
{{- end -}}
{{- end -}}
13 changes: 13 additions & 0 deletions chart/charts/crds/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
jaeger:
# -- Install Jaeger CRDs
enabled: true
# -- Keep CRDs on chart uninstall
keep: true
# -- Annotations to be added to all CRDs
annotations: {}
# Example for Argo CD to prevent CRDs from being recycled
# argocd.argoproj.io/sync-options: Prune=false

csi:
volumeSnapshots:
# -- Install Volume Snapshot CRDs
enabled: true
# -- Keep CRDs on chart uninstall
keep: true
# -- Annotations to be added to all CRDs
annotations: {}
# Example for Argo CD to prevent CRDs from being recycled
# argocd.argoproj.io/sync-options: Prune=false

0 comments on commit 747d349

Please sign in to comment.