diff --git a/library/common/templates/class/velero/_backupStorageLocation.tpl b/library/common/templates/class/velero/_backupStorageLocation.tpl new file mode 100644 index 00000000..7feffd44 --- /dev/null +++ b/library/common/templates/class/velero/_backupStorageLocation.tpl @@ -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 -}} diff --git a/library/common/templates/class/velero/_schedule.tpl b/library/common/templates/class/velero/_schedule.tpl new file mode 100644 index 00000000..af6e5a91 --- /dev/null +++ b/library/common/templates/class/velero/_schedule.tpl @@ -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 -}} diff --git a/library/common/templates/class/velero/_volumeSnapshotLocation.tpl b/library/common/templates/class/velero/_volumeSnapshotLocation.tpl new file mode 100644 index 00000000..529f5e30 --- /dev/null +++ b/library/common/templates/class/velero/_volumeSnapshotLocation.tpl @@ -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 -}}