mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-04 22:41:22 -03:00
volsnapshots
This commit is contained in:
@@ -21,7 +21,7 @@ tests:
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: "{{ .Values.annotation2 }}"
|
||||
volumeSnapshots:
|
||||
- name: example1
|
||||
example1:
|
||||
enabled: true
|
||||
source:
|
||||
volumeSnapshotContentName: some-name
|
||||
|
||||
@@ -8,11 +8,11 @@ tests:
|
||||
- it: should generate correct name
|
||||
set:
|
||||
volumeSnapshots:
|
||||
- name: example1
|
||||
example1:
|
||||
enabled: true
|
||||
source:
|
||||
volumeSnapshotContentName: some-name
|
||||
- name: example2
|
||||
example2:
|
||||
enabled: true
|
||||
source:
|
||||
volumeSnapshotContentName: some-name
|
||||
|
||||
@@ -8,11 +8,11 @@ tests:
|
||||
- it: should generate correct spec
|
||||
set:
|
||||
volumeSnapshots:
|
||||
- name: example1
|
||||
example1:
|
||||
enabled: true
|
||||
source:
|
||||
volumeSnapshotContentName: some-name
|
||||
- name: example2
|
||||
example2:
|
||||
enabled: true
|
||||
source:
|
||||
persistentVolumeClaimName: some-pvc-name
|
||||
@@ -45,7 +45,7 @@ tests:
|
||||
- it: should generate correct spec with volumeSnapshotClass
|
||||
set:
|
||||
volumeSnapshots:
|
||||
- name: example1
|
||||
example1:
|
||||
enabled: true
|
||||
volumeSnapshotClassName: some-class
|
||||
source:
|
||||
@@ -63,20 +63,10 @@ tests:
|
||||
volumeSnapshotContentName: some-name
|
||||
|
||||
# Failures
|
||||
- it: should fail without name
|
||||
set:
|
||||
volumeSnapshots:
|
||||
- enabled: true
|
||||
source:
|
||||
volumeSnapshotContentName: some-name
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Volume Snapshot - Expected non empty [name]
|
||||
|
||||
- it: should fail without source object
|
||||
set:
|
||||
volumeSnapshots:
|
||||
- name: example1
|
||||
example1:
|
||||
enabled: true
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
@@ -85,7 +75,7 @@ tests:
|
||||
- it: should fail without a valid source
|
||||
set:
|
||||
volumeSnapshots:
|
||||
- name: example1
|
||||
example1:
|
||||
enabled: true
|
||||
source:
|
||||
invalid: invalid
|
||||
@@ -96,7 +86,7 @@ tests:
|
||||
- it: should fail with more than one valid source
|
||||
set:
|
||||
volumeSnapshots:
|
||||
- name: example1
|
||||
example1:
|
||||
enabled: true
|
||||
source:
|
||||
volumeSnapshotContentName: some-name
|
||||
@@ -105,7 +95,6 @@ tests:
|
||||
- failedTemplate:
|
||||
errorMessage: Volume Snapshot - Expected exactly one of the valid source types [volumeSnapshotContentName, persistentVolumeClaimName]. Found [2]
|
||||
|
||||
|
||||
- it: should fail with empty enabled
|
||||
set:
|
||||
volumeSnapshots:
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
{{- define "tc.v1.common.spawner.volumesnapshot" -}}
|
||||
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}}
|
||||
|
||||
{{- range $idx, $volumesnapshot := .Values.volumeSnapshots -}}
|
||||
{{- range $name, $volumesnapshot := .Values.volumeSnapshots -}}
|
||||
|
||||
{{- $enabled := false -}}
|
||||
{{- if hasKey $volumesnapshot "enabled" -}}
|
||||
{{- if not (kindIs "invalid" $volumesnapshot.enabled) -}}
|
||||
{{- $enabled = $volumesnapshot.enabled -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Volume Snapshot - Expected the defined key [enabled] in [volumeSnapshots.%v] to not be empty" $idx) -}}
|
||||
{{- fail (printf "Volume Snapshot - Expected the defined key [enabled] in [volumeSnapshots.%v] to not be empty" $name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -33,14 +33,10 @@
|
||||
{{/* Create a copy of the volumesnapshot */}}
|
||||
{{- $objectData := (mustDeepCopy $volumesnapshot) -}}
|
||||
|
||||
{{- if not $objectData.name -}}
|
||||
{{- fail "Volume Snapshot - Expected non empty [name]" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $objectName := (printf "%s-%s" $fullname $volumesnapshot.name) -}}
|
||||
{{- $objectName := (printf "%s-%s" $fullname $name) -}}
|
||||
{{- if hasKey $objectData "expandObjectName" -}}
|
||||
{{- if not $objectData.expandObjectName -}}
|
||||
{{- $objectName = $volumesnapshot.name -}}
|
||||
{{- $objectName = $name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -51,7 +47,7 @@
|
||||
|
||||
{{/* Set the name of the volumesnapshot */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $volumesnapshot.name -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.volumesnapshot" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{{- define "tc.v1.common.values.volumeSnapshotList" -}}
|
||||
{{- $rootCtx := . -}}
|
||||
|
||||
{{- range $idx, $volSnapValues := $rootCtx.Values.volumeSnapshotsList -}}
|
||||
|
||||
{{- $name := (printf "vs-list-%s" (toString $idx)) -}}
|
||||
|
||||
{{- with $volSnapValues.name -}}
|
||||
{{- $name = . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (hasKey $rootCtx.Values "volumeSnapshots") -}}
|
||||
{{- $_ := set $rootCtx.Values "volumeSnapshots" dict -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $rootCtx.Values.volumeSnapshots $name $volSnapValues -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -322,10 +322,11 @@ persistenceList: []
|
||||
|
||||
deviceList: []
|
||||
|
||||
volumeSnapshotClass: []
|
||||
volumeSnapshots: []
|
||||
volumeSnapshotClass: {}
|
||||
volumeSnapshots: {}
|
||||
volumeSnapshotsList: {}
|
||||
# volumeSnapshots:
|
||||
# - name: "mycustomsnapshot"
|
||||
# mysnapshot:
|
||||
# volumeSnapshotClassName: "mycustomsnapshot" (optional)
|
||||
# source:
|
||||
# # pick one
|
||||
|
||||
Reference in New Issue
Block a user