add initial work on velero classes

This commit is contained in:
Kjeld Schouten
2023-11-14 19:58:17 +01:00
parent 5b5f7ba775
commit 495ec6fb46
3 changed files with 159 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
{{/* backupstoragelocation Class */}}
{{/* Call this template:
{{ include "tc.v1.common.class.velero.backupstoragelocation" (dict "rootCtx" $ "objectData" $objectData) }}
rootCtx: The root context of the chart.
objectData:
name: The name of the backupstoragelocation.
labels: The labels of the backupstoragelocation.
annotations: The annotations of the backupstoragelocation.
namespace: The namespace of the backupstoragelocation. (Optional)
*/}}
{{- define "tc.v1.common.class.velero.backupstoragelocation" -}}
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData }}
---
apiVersion: velero.io/v1
kind: BackupStorageLocation
metadata:
name: {{ $objectData.name }}
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "backupstoragelocation") }}
{{- $labels := (mustMerge ($objectData.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
labels:
{{- . | nindent 4 }}
{{- end -}}
{{- $annotations := (mustMerge ($objectData.annotations | default dict) (include "tc.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}}
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
annotations:
{{- . | nindent 4 }}
{{- end }}
spec:
{{- if not (empty $objectData.credential) }}
credential:
{{- with $objectData.credential.name }}
name: {{ . }}
{{- end }}
{{- with $objectData.credential.key }}
key: {{ . }}
{{- end }}
{{- end }}
provider: {{ $objectData.provider }}
accessMode: {{ $objectData.accessMode | default "ReadWrite" }}
{{- with $objectData.default }}
default: {{ . }}
{{- end }}
{{- with $objectData.validationFrequency }}
validationFrequency: {{ . }}
{{- end }}
objectStorage:
bucket: {{ $objectData.bucket | quote }}
{{- with $objectData.prefix }}
prefix: {{ . | quote }}
{{- end }}
{{- with $objectData.caCert }}
caCert: {{ . }}
{{- end }}
{{- with $objectData.config }}
config:
{{- range $key, $value := . }}
{{- $key | nindent 4 }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end -}}

View File

@@ -0,0 +1,42 @@
{{/* schedule Class */}}
{{/* Call this template:
{{ include "tc.v1.common.class.velero.schedule" (dict "rootCtx" $ "objectData" $objectData) }}
rootCtx: The root context of the chart.
objectData:
name: The name of the schedule.
labels: The labels of the schedule.
annotations: The annotations of the schedule.
namespace: The namespace of the schedule. (Optional)
*/}}
{{- define "tc.v1.common.class.velero.schedule" -}}
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData }}
---
apiVersion: velero.io/v1
kind: schedule
metadata:
name: {{ $objectData.name }}
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "schedule") }}
{{- $labels := (mustMerge ($objectData.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
labels:
{{- . | nindent 4 }}
{{- end -}}
{{- $annotations := (mustMerge ($objectData.annotations | default dict) (include "tc.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}}
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
annotations:
{{- . | nindent 4 }}
{{- end }}
spec:
{{- if $objectData.useOwnerReferencesInBackup }}
useOwnerReferencesInBackup: {{ $objectData.useOwnerReferencesInBackup }}
{{- end }}
schedule: {{ $objectData.schedule | quote }}
{{- with $objectData.template }}
template:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}

View File

@@ -0,0 +1,50 @@
{{/* volumesnapshotlocation Class */}}
{{/* Call this template:
{{ include "tc.v1.common.class.velero.volumesnapshotlocation" (dict "rootCtx" $ "objectData" $objectData) }}
rootCtx: The root context of the chart.
objectData:
name: The name of the volumesnapshotlocation.
labels: The labels of the volumesnapshotlocation.
annotations: The annotations of the volumesnapshotlocation.
namespace: The namespace of the volumesnapshotlocation. (Optional)
*/}}
{{- define "tc.v1.common.class.velero.volumesnapshotlocation" -}}
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData }}
---
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
name: {{ $objectData.name }}
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "volumesnapshotlocation") }}
{{- $labels := (mustMerge ($objectData.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
labels:
{{- . | nindent 4 }}
{{- end -}}
{{- $annotations := (mustMerge ($objectData.annotations | default dict) (include "tc.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}}
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
annotations:
{{- . | nindent 4 }}
{{- end }}
spec:
{{- if not (empty $objectData.credential) }}
credential:
{{- with $objectData.credential.name }}
name: {{ . }}
{{- end }}
{{- with $objectData.credential.key }}
key: {{ . }}
{{- end }}
{{- end }}
provider: {{ $objectData.provider }}
{{- with $objectData.config }}
config:
{{- range $key, $value := . }}
{{- $key | nindent 4 }}: {{ $value | quote }}
{{- end }}
{{- end -}}
{{- end -}}