mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 19:44:23 -03:00
spec
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
words:
|
||||
- tailscale
|
||||
- tailscale
|
||||
- Velero
|
||||
|
||||
63
library/common-test/tests/veleroSchedule/metadata_test.yaml
Normal file
63
library/common-test/tests/veleroSchedule/metadata_test.yaml
Normal file
@@ -0,0 +1,63 @@
|
||||
suite: velero schedule metadata test
|
||||
templates:
|
||||
- common.yaml
|
||||
chart:
|
||||
appVersion: &appVer v9.9.9
|
||||
release:
|
||||
name: test-release-name
|
||||
namespace: test-release-namespace
|
||||
tests:
|
||||
- it: should pass with storageClass created with labels and annotations
|
||||
set:
|
||||
label1: label1
|
||||
label2: global_label2
|
||||
annotation1: annotation1
|
||||
annotation2: global_annotation2
|
||||
global:
|
||||
labels:
|
||||
g_label1: global_label1
|
||||
g_label2: "{{ .Values.label2 }}"
|
||||
annotations:
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: "{{ .Values.annotation2 }}"
|
||||
schedules:
|
||||
my-sched:
|
||||
enabled: true
|
||||
labels:
|
||||
label1: "{{ .Values.label1 }}"
|
||||
label2: label2
|
||||
annotations:
|
||||
annotation1: "{{ .Values.annotation1 }}"
|
||||
annotation2: annotation2
|
||||
schedule: "0 0 * * *"
|
||||
asserts:
|
||||
- documentIndex: &scheduleDoc 0
|
||||
isKind:
|
||||
of: Schedule
|
||||
- documentIndex: *scheduleDoc
|
||||
isAPIVersion:
|
||||
of: velero.io/v1
|
||||
- documentIndex: *scheduleDoc
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
annotation1: annotation1
|
||||
annotation2: annotation2
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: global_annotation2
|
||||
- documentIndex: *scheduleDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app: common-test-1.0.0
|
||||
release: test-release-name
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/instance: test-release-name
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/version: *appVer
|
||||
g_label1: global_label1
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
37
library/common-test/tests/veleroSchedule/names_test.yaml
Normal file
37
library/common-test/tests/veleroSchedule/names_test.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
suite: velero schedule name test
|
||||
templates:
|
||||
- common.yaml
|
||||
release:
|
||||
name: test-release-name
|
||||
namespace: test-release-namespace
|
||||
tests:
|
||||
- it: should generate correct name
|
||||
set:
|
||||
schedules:
|
||||
my-sched1:
|
||||
enabled: true
|
||||
schedule: "0 0 * * *"
|
||||
my-sched2:
|
||||
enabled: true
|
||||
schedule: "0 0 * * *"
|
||||
asserts:
|
||||
- documentIndex: &scheduleDoc 0
|
||||
isKind:
|
||||
of: Schedule
|
||||
- documentIndex: *scheduleDoc
|
||||
isAPIVersion:
|
||||
of: velero.io/v1
|
||||
- documentIndex: *scheduleDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: test-release-name-common-test-my-sched1
|
||||
- documentIndex: &otherScheduleDoc 1
|
||||
isKind:
|
||||
of: Schedule
|
||||
- documentIndex: *otherScheduleDoc
|
||||
isAPIVersion:
|
||||
of: velero.io/v1
|
||||
- documentIndex: *otherScheduleDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: test-release-name-common-test-my-sched2
|
||||
94
library/common-test/tests/veleroSchedule/spec_test.yaml
Normal file
94
library/common-test/tests/veleroSchedule/spec_test.yaml
Normal file
@@ -0,0 +1,94 @@
|
||||
suite: velero schedule spec test
|
||||
templates:
|
||||
- common.yaml
|
||||
release:
|
||||
name: test-release-name
|
||||
namespace: test-release-namespace
|
||||
tests:
|
||||
- it: should generate correct spec with provided provider and credential
|
||||
set:
|
||||
schedules:
|
||||
my-sched:
|
||||
enabled: true
|
||||
schedule: "0 2 * * *"
|
||||
asserts:
|
||||
- documentIndex: &scheduleDoc 0
|
||||
isKind:
|
||||
of: Schedule
|
||||
- documentIndex: *scheduleDoc
|
||||
isAPIVersion:
|
||||
of: velero.io/v1
|
||||
- documentIndex: *scheduleDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
schedule: "0 2 * * *"
|
||||
|
||||
- it: should generate correct spec with useOwnerReferencesInBackup
|
||||
set:
|
||||
schedules:
|
||||
my-sched:
|
||||
enabled: true
|
||||
schedule: "0 2 * * *"
|
||||
useOwnerReferencesInBackup: true
|
||||
asserts:
|
||||
- documentIndex: &scheduleDoc 0
|
||||
isKind:
|
||||
of: Schedule
|
||||
- documentIndex: *scheduleDoc
|
||||
isAPIVersion:
|
||||
of: velero.io/v1
|
||||
- documentIndex: *scheduleDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
schedule: "0 2 * * *"
|
||||
useOwnerReferencesInBackup: true
|
||||
|
||||
- it: should generate correct spec with template
|
||||
set:
|
||||
schedules:
|
||||
my-sched:
|
||||
enabled: true
|
||||
schedule: "0 2 * * *"
|
||||
template:
|
||||
ttl: 720h
|
||||
includeClusterResources: true
|
||||
snapshotVolumes: true
|
||||
asserts:
|
||||
- documentIndex: &scheduleDoc 0
|
||||
isKind:
|
||||
of: Schedule
|
||||
- documentIndex: *scheduleDoc
|
||||
isAPIVersion:
|
||||
of: velero.io/v1
|
||||
- documentIndex: *scheduleDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
schedule: "0 2 * * *"
|
||||
template:
|
||||
ttl: 720h
|
||||
includeClusterResources: true
|
||||
snapshotVolumes: true
|
||||
|
||||
# Failures
|
||||
- it: should fail without schedule
|
||||
set:
|
||||
schedules:
|
||||
my-sched:
|
||||
enabled: true
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Velero Schedule - Expected non-empty [schedule]
|
||||
|
||||
- it: should fail with useOwnerReferencesInBackup not a bool
|
||||
set:
|
||||
schedules:
|
||||
my-sched:
|
||||
enabled: true
|
||||
schedule: "0 2 * * *"
|
||||
useOwnerReferencesInBackup: "true"
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Velero Schedule - Expected [useOwnerReferencesInBackup] to be a boolean
|
||||
@@ -16,10 +16,10 @@ objectData:
|
||||
{{- $objectData := .objectData }}
|
||||
---
|
||||
apiVersion: velero.io/v1
|
||||
kind: schedule
|
||||
kind: Schedule
|
||||
metadata:
|
||||
name: {{ $objectData.name }}
|
||||
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "schedule") }}
|
||||
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:
|
||||
@@ -31,12 +31,12 @@ metadata:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if $objectData.useOwnerReferencesInBackup }}
|
||||
useOwnerReferencesInBackup: {{ $objectData.useOwnerReferencesInBackup }}
|
||||
{{- end }}
|
||||
schedule: {{ $objectData.schedule | quote }}
|
||||
{{- with $objectData.template }}
|
||||
{{- if (kindIs "bool" $objectData.useOwnerReferencesInBackup) }}
|
||||
useOwnerReferencesInBackup: {{ $objectData.useOwnerReferencesInBackup }}
|
||||
{{- end -}}
|
||||
{{- with $objectData.template }}
|
||||
template:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -10,5 +10,13 @@ objectData:
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- if not $objectData.schedule -}}
|
||||
{{- fail "Velero Schedule - Expected non-empty [schedule]" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if (hasKey $objectData "useOwnerReferencesInBackup") -}}
|
||||
{{- if not (kindIs "bool" $objectData.useOwnerReferencesInBackup) -}}
|
||||
{{ fail "Velero Schedule - Expected [useOwnerReferencesInBackup] to be a boolean" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -6,18 +6,17 @@
|
||||
{{- define "tc.v1.common.spawner.velero.schedule" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{- range $schedule := .Values.schedule -}}
|
||||
{{- range $name, $schedule := .Values.schedules -}}
|
||||
|
||||
{{- $enabled := false -}}
|
||||
{{- if hasKey $schedule "enabled" -}}
|
||||
{{- if not (kindIs "invalid" $schedule.enabled) -}}
|
||||
{{- $enabled = $schedule.enabled -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "schedule - Expected the defined key [enabled] in [schedule.%s] to not be empty" $schedule.name) -}}
|
||||
{{- fail (printf "Schedule - Expected the defined key [enabled] in [schedules.%s] to not be empty" $name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- if kindIs "string" $enabled -}}
|
||||
{{- $enabled = tpl $enabled $ -}}
|
||||
|
||||
@@ -34,25 +33,25 @@
|
||||
{{/* Create a copy of the schedule */}}
|
||||
{{- $objectData := (mustDeepCopy $schedule) -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $schedule.name) -}}
|
||||
{{- $objectName := (printf "%s-%s" $fullname $name) -}}
|
||||
{{- if hasKey $objectData "expandObjectName" -}}
|
||||
{{- if not $objectData.expandObjectName -}}
|
||||
{{- $objectName = $schedule.name -}}
|
||||
{{- $objectName = $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Perform validations */}} {{/* schedules have a max name length of 253 */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName "length" 253) -}}
|
||||
{{- include "tc.v1.common.lib.velero.schedule.validation" (dict "objectData" $objectData) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "schedule") -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Schedule") -}}
|
||||
|
||||
{{/* Set the name of the schedule */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $schedule.name -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Set namespace to velero location or itself, just in case its used from within velero */}}
|
||||
{{- $operator := index $.Values.operator "velero" -}}
|
||||
{{- $namespace := $operator.namespace | default ( include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $ "objectData" $objectData "caller" "backupstoragelocation") ) -}}
|
||||
{{- $namespace := $operator.namespace | default (include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $ "objectData" $objectData "caller" "Schedule")) -}}
|
||||
{{- $_ := set $objectData "namespace" $namespace -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
|
||||
@@ -788,6 +788,7 @@ volumeSnapshotLocation: []
|
||||
# # project:
|
||||
|
||||
# Backup schedules to create.
|
||||
schedules: {}
|
||||
# Eg:
|
||||
# schedules:
|
||||
# mybackup:
|
||||
|
||||
Reference in New Issue
Block a user