From fc115e3e8fc287e68d46df49456d3a5fb0efc48e Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sun, 3 Dec 2023 16:18:22 +0200 Subject: [PATCH] chore(utils): use template for "enabled" with tpl support (#618) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --- library/common/Chart.yaml | 2 +- .../common/templates/lib/util/_enabled.tpl | 28 +++++++++++++++++++ .../common/templates/spawner/_configmap.tpl | 26 ++++------------- .../templates/spawner/_imagePullSecret.tpl | 7 ++++- library/common/templates/spawner/_portal.tpl | 8 +++++- .../templates/spawner/_priorityClass.tpl | 26 ++++------------- library/common/templates/spawner/_pvc.tpl | 7 ++++- library/common/templates/spawner/_rbac.tpl | 6 +++- .../templates/spawner/_scaleCertificate.tpl | 6 +++- library/common/templates/spawner/_secret.tpl | 26 ++++------------- library/common/templates/spawner/_service.tpl | 6 +++- .../templates/spawner/_serviceAccount.tpl | 6 +++- .../templates/spawner/_storageClass.tpl | 26 ++++------------- .../templates/spawner/_volumeSnapshot.tpl | 25 ++++------------- .../spawner/_volumeSnapshotClass.tpl | 25 ++++------------- library/common/templates/spawner/_webhook.tpl | 25 ++++------------- .../common/templates/spawner/_workload.tpl | 7 ++++- .../spawner/velero/_backupstoragelocation.tpl | 25 ++++------------- .../templates/spawner/velero/_schedule.tpl | 26 ++++------------- .../velero/_volumeSnapshotLocation.tpl | 25 ++++------------- library/common/values.yaml | 2 ++ 21 files changed, 126 insertions(+), 214 deletions(-) create mode 100644 library/common/templates/lib/util/_enabled.tpl diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 6142f2ef..34745ca3 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 15.3.1 +version: 15.3.2 diff --git a/library/common/templates/lib/util/_enabled.tpl b/library/common/templates/lib/util/_enabled.tpl new file mode 100644 index 00000000..ce739cdc --- /dev/null +++ b/library/common/templates/lib/util/_enabled.tpl @@ -0,0 +1,28 @@ +{{- define "tc.v1.common.lib.util.enabled" -}} + {{- $objectData := .objectData -}} + {{- $rootCtx := .rootCtx -}} + {{- $key := .key -}} + {{- $name := (.name | toString) -}} + {{- $caller := .caller -}} + + {{- $enabled := false -}} + {{- if hasKey $objectData "enabled" -}} + {{- if not (kindIs "invalid" $objectData.enabled) -}} + {{- $enabled = $objectData.enabled -}} + {{- else -}} + {{- fail (printf "%s - Expected the defined key [enabled] in [%s.%s] to not be empty" $caller $key $name) -}} + {{- end -}} + {{- end -}} + + {{- if kindIs "string" $enabled -}} + {{- $enabled = tpl $enabled $rootCtx -}} + {{- if eq $enabled "true" -}} + {{- $enabled = true -}} + {{- else if eq $enabled "false" -}} + {{- $enabled = false -}} + {{- end -}} + {{- end -}} + + {{/* NOTE: Always treat the returned result as string */}} + {{- $enabled -}} +{{- end -}} diff --git a/library/common/templates/spawner/_configmap.tpl b/library/common/templates/spawner/_configmap.tpl index f798daf4..718a7368 100644 --- a/library/common/templates/spawner/_configmap.tpl +++ b/library/common/templates/spawner/_configmap.tpl @@ -8,28 +8,12 @@ {{- range $name, $configmap := .Values.configmap -}} - {{- $enabled := false -}} - {{- if hasKey $configmap "enabled" -}} - {{- if not (kindIs "invalid" $configmap.enabled) -}} - {{- $enabled = $configmap.enabled -}} - {{- else -}} - {{- fail (printf "ConfigMap - Expected the defined key [enabled] in [configmap.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $configmap + "name" $name "caller" "ConfigMap" + "key" "configmap")) -}} - - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the configmap */}} {{- $objectData := (mustDeepCopy $configmap) -}} diff --git a/library/common/templates/spawner/_imagePullSecret.tpl b/library/common/templates/spawner/_imagePullSecret.tpl index 30c4cc2d..4540fee3 100644 --- a/library/common/templates/spawner/_imagePullSecret.tpl +++ b/library/common/templates/spawner/_imagePullSecret.tpl @@ -8,7 +8,12 @@ {{- range $name, $imgPullSecret := .Values.imagePullSecret -}} - {{- if $imgPullSecret.enabled -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $imgPullSecret + "name" $name "caller" "Image Pull Secret" + "key" "imagePullSecret")) -}} + + {{- if eq $enabled "true" -}} {{/* Create a copy of the configmap */}} {{- $objectData := (mustDeepCopy $imgPullSecret) -}} diff --git a/library/common/templates/spawner/_portal.tpl b/library/common/templates/spawner/_portal.tpl index e7e58e31..34631101 100644 --- a/library/common/templates/spawner/_portal.tpl +++ b/library/common/templates/spawner/_portal.tpl @@ -5,7 +5,13 @@ {{- define "tc.v1.common.spawner.portal" -}} {{- range $name, $portal := .Values.portal -}} - {{- if $portal.enabled -}} + + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $portal + "name" $name "caller" "Portal" + "key" "portal")) -}} + + {{- if eq $enabled "true" -}} {{/* Create a copy of the portal */}} {{- $objectData := (mustDeepCopy $portal) -}} diff --git a/library/common/templates/spawner/_priorityClass.tpl b/library/common/templates/spawner/_priorityClass.tpl index 450e6346..a7391d5d 100644 --- a/library/common/templates/spawner/_priorityClass.tpl +++ b/library/common/templates/spawner/_priorityClass.tpl @@ -8,28 +8,12 @@ {{- range $name, $priorityclass := .Values.priorityClass -}} - {{- $enabled := false -}} - {{- if hasKey $priorityclass "enabled" -}} - {{- if not (kindIs "invalid" $priorityclass.enabled) -}} - {{- $enabled = $priorityclass.enabled -}} - {{- else -}} - {{- fail (printf "Priority Class - Expected the defined key [enabled] in [priorityclass.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $priorityclass + "name" $name "caller" "Priority Class" + "key" "priorityClass")) -}} - - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the priorityclass */}} {{- $objectData := (mustDeepCopy $priorityclass) -}} diff --git a/library/common/templates/spawner/_pvc.tpl b/library/common/templates/spawner/_pvc.tpl index b8631c02..6855539b 100644 --- a/library/common/templates/spawner/_pvc.tpl +++ b/library/common/templates/spawner/_pvc.tpl @@ -7,7 +7,12 @@ {{- range $name, $persistence := .Values.persistence -}} - {{- if $persistence.enabled -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $persistence + "name" $name "caller" "Persistence" + "key" "persistence")) -}} + + {{- if eq $enabled "true" -}} {{/* Create a copy of the persistence */}} {{- $objectData := (mustDeepCopy $persistence) -}} diff --git a/library/common/templates/spawner/_rbac.tpl b/library/common/templates/spawner/_rbac.tpl index 255f11c8..c5a48399 100644 --- a/library/common/templates/spawner/_rbac.tpl +++ b/library/common/templates/spawner/_rbac.tpl @@ -10,8 +10,12 @@ {{- include "tc.v1.common.lib.rbac.primaryValidation" $ -}} {{- range $name, $rbac := .Values.rbac -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $rbac + "name" $name "caller" "RBAC" + "key" "rbac")) -}} - {{- if $rbac.enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the configmap */}} {{- $objectData := (mustDeepCopy $rbac) -}} diff --git a/library/common/templates/spawner/_scaleCertificate.tpl b/library/common/templates/spawner/_scaleCertificate.tpl index 62859591..0598beab 100644 --- a/library/common/templates/spawner/_scaleCertificate.tpl +++ b/library/common/templates/spawner/_scaleCertificate.tpl @@ -7,8 +7,12 @@ {{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}} {{- range $name, $certificate := .Values.scaleCertificate -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $certificate + "name" $name "caller" "Scale Certificate" + "key" "scaleCertificate")) -}} - {{- if $certificate.enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the certificate */}} {{- $objectData := (mustDeepCopy $certificate) -}} diff --git a/library/common/templates/spawner/_secret.tpl b/library/common/templates/spawner/_secret.tpl index dea858ae..f6e68c23 100644 --- a/library/common/templates/spawner/_secret.tpl +++ b/library/common/templates/spawner/_secret.tpl @@ -7,28 +7,12 @@ {{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $ -}} {{- range $name, $secret := .Values.secret -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $secret + "name" $name "caller" "Secret" + "key" "secret")) -}} - {{- $enabled := false -}} - {{- if hasKey $secret "enabled" -}} - {{- if not (kindIs "invalid" $secret.enabled) -}} - {{- $enabled = $secret.enabled -}} - {{- else -}} - {{- fail (printf "Secret - Expected the defined key [enabled] in [secret.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} - - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the secret */}} {{- $objectData := (mustDeepCopy $secret) -}} diff --git a/library/common/templates/spawner/_service.tpl b/library/common/templates/spawner/_service.tpl index 5e19892c..a0faab7c 100644 --- a/library/common/templates/spawner/_service.tpl +++ b/library/common/templates/spawner/_service.tpl @@ -10,8 +10,12 @@ {{- include "tc.v1.common.lib.service.primaryValidation" $ -}} {{- range $name, $service := .Values.service -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $service + "name" $name "caller" "Service" + "key" "service")) -}} - {{- if $service.enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the configmap */}} {{- $objectData := (mustDeepCopy $service) -}} diff --git a/library/common/templates/spawner/_serviceAccount.tpl b/library/common/templates/spawner/_serviceAccount.tpl index c15aff45..a34460d8 100644 --- a/library/common/templates/spawner/_serviceAccount.tpl +++ b/library/common/templates/spawner/_serviceAccount.tpl @@ -10,8 +10,12 @@ {{- include "tc.v1.common.lib.serviceAccount.primaryValidation" $ -}} {{- range $name, $serviceAccount := .Values.serviceAccount -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $serviceAccount + "name" $name "caller" "Service Account" + "key" "serviceAccount")) -}} - {{- if $serviceAccount.enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the configmap */}} {{- $objectData := (mustDeepCopy $serviceAccount) -}} diff --git a/library/common/templates/spawner/_storageClass.tpl b/library/common/templates/spawner/_storageClass.tpl index 36ee6328..088045ba 100644 --- a/library/common/templates/spawner/_storageClass.tpl +++ b/library/common/templates/spawner/_storageClass.tpl @@ -8,28 +8,12 @@ {{- range $name, $storageclass := .Values.storageClass -}} - {{- $enabled := false -}} - {{- if hasKey $storageclass "enabled" -}} - {{- if not (kindIs "invalid" $storageclass.enabled) -}} - {{- $enabled = $storageclass.enabled -}} - {{- else -}} - {{- fail (printf "StorageClass - Expected the defined key [enabled] in [storageclass.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $storageclass + "name" $name "caller" "Storage Class" + "key" "storageClass")) -}} - - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the storageclass */}} {{- $objectData := (mustDeepCopy $storageclass) -}} diff --git a/library/common/templates/spawner/_volumeSnapshot.tpl b/library/common/templates/spawner/_volumeSnapshot.tpl index 4d477391..f8fb545a 100644 --- a/library/common/templates/spawner/_volumeSnapshot.tpl +++ b/library/common/templates/spawner/_volumeSnapshot.tpl @@ -8,27 +8,12 @@ {{- 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" $name) -}} - {{- end -}} - {{- end -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $volumesnapshot + "name" $name "caller" "Volume Snapshot" + "key" "volumeSnapshots")) -}} - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the volumesnapshot */}} {{- $objectData := (mustDeepCopy $volumesnapshot) -}} diff --git a/library/common/templates/spawner/_volumeSnapshotClass.tpl b/library/common/templates/spawner/_volumeSnapshotClass.tpl index 0262e294..6b15825c 100644 --- a/library/common/templates/spawner/_volumeSnapshotClass.tpl +++ b/library/common/templates/spawner/_volumeSnapshotClass.tpl @@ -8,27 +8,12 @@ {{- range $name, $volumesnapshotclass := .Values.volumeSnapshotClass -}} - {{- $enabled := false -}} - {{- if hasKey $volumesnapshotclass "enabled" -}} - {{- if not (kindIs "invalid" $volumesnapshotclass.enabled) -}} - {{- $enabled = $volumesnapshotclass.enabled -}} - {{- else -}} - {{- fail (printf "Volume Snapshot Class - Expected the defined key [enabled] in [volumeSnapshotClass.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $volumesnapshotclass + "name" $name "caller" "Volume Snapshot Class" + "key" "volumeSnapshotClass")) -}} - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the volumesnapshotclass */}} {{- $objectData := (mustDeepCopy $volumesnapshotclass) -}} diff --git a/library/common/templates/spawner/_webhook.tpl b/library/common/templates/spawner/_webhook.tpl index 79326ebf..90c0db10 100644 --- a/library/common/templates/spawner/_webhook.tpl +++ b/library/common/templates/spawner/_webhook.tpl @@ -8,27 +8,12 @@ {{- range $name, $mutatingWebhookConfiguration := .Values.webhook -}} - {{- $enabled := false -}} - {{- if hasKey $mutatingWebhookConfiguration "enabled" -}} - {{- if not (kindIs "invalid" $mutatingWebhookConfiguration.enabled) -}} - {{- $enabled = $mutatingWebhookConfiguration.enabled -}} - {{- else -}} - {{- fail (printf "Webhook - Expected the defined key [enabled] in [webhook.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $mutatingWebhookConfiguration + "name" $name "caller" "Webhook" + "key" "webhook")) -}} - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the mutatingWebhookConfiguration */}} {{- $objectData := (mustDeepCopy $mutatingWebhookConfiguration) -}} diff --git a/library/common/templates/spawner/_workload.tpl b/library/common/templates/spawner/_workload.tpl index 832067a4..d89cc79a 100644 --- a/library/common/templates/spawner/_workload.tpl +++ b/library/common/templates/spawner/_workload.tpl @@ -11,7 +11,12 @@ {{- range $name, $workload := .Values.workload -}} - {{- if $workload.enabled -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $workload + "name" $name "caller" "Workload" + "key" "workload")) -}} + + {{- if eq $enabled "true" -}} {{/* Create a copy of the workload */}} {{- $objectData := (mustDeepCopy $workload) -}} diff --git a/library/common/templates/spawner/velero/_backupstoragelocation.tpl b/library/common/templates/spawner/velero/_backupstoragelocation.tpl index a096bc1f..86f45faa 100644 --- a/library/common/templates/spawner/velero/_backupstoragelocation.tpl +++ b/library/common/templates/spawner/velero/_backupstoragelocation.tpl @@ -8,27 +8,12 @@ {{- range $name, $backupStorageLoc := .Values.backupStorageLocation -}} - {{- $enabled := false -}} - {{- if hasKey $backupStorageLoc "enabled" -}} - {{- if not (kindIs "invalid" $backupStorageLoc.enabled) -}} - {{- $enabled = $backupStorageLoc.enabled -}} - {{- else -}} - {{- fail (printf "Backup Storage Location - Expected the defined key [enabled] in [backupStorageLocation.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $backupStorageLoc + "name" $name "caller" "Velero Backup Storage Location" + "key" "backupStorageLocation")) -}} - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the backupstoragelocation */}} {{- $objectData := (mustDeepCopy $backupStorageLoc) -}} diff --git a/library/common/templates/spawner/velero/_schedule.tpl b/library/common/templates/spawner/velero/_schedule.tpl index 85259fc7..4a01372b 100644 --- a/library/common/templates/spawner/velero/_schedule.tpl +++ b/library/common/templates/spawner/velero/_schedule.tpl @@ -8,28 +8,12 @@ {{- 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 [schedules.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} - - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $schedule + "name" $name "caller" "Velero Schedule" + "key" "schedules")) -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the schedule */}} {{- $objectData := (mustDeepCopy $schedule) -}} diff --git a/library/common/templates/spawner/velero/_volumeSnapshotLocation.tpl b/library/common/templates/spawner/velero/_volumeSnapshotLocation.tpl index 03d566e5..8ade18b2 100644 --- a/library/common/templates/spawner/velero/_volumeSnapshotLocation.tpl +++ b/library/common/templates/spawner/velero/_volumeSnapshotLocation.tpl @@ -8,27 +8,12 @@ {{- range $name, $volSnapLoc := .Values.volumeSnapshotLocation -}} - {{- $enabled := false -}} - {{- if hasKey $volSnapLoc "enabled" -}} - {{- if not (kindIs "invalid" $volSnapLoc.enabled) -}} - {{- $enabled = $volSnapLoc.enabled -}} - {{- else -}} - {{- fail (printf "Volume Snapshot Location - Expected the defined key [enabled] in [volumeSnapshotLocation.%s] to not be empty" $name) -}} - {{- end -}} - {{- end -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $volSnapLoc + "name" $name "caller" "Velero Volume Snapshot Location" + "key" "volumeSnapshotLocation")) -}} - {{- if kindIs "string" $enabled -}} - {{- $enabled = tpl $enabled $ -}} - - {{/* After tpl it becomes a string, not a bool */}} - {{- if eq $enabled "true" -}} - {{- $enabled = true -}} - {{- else if eq $enabled "false" -}} - {{- $enabled = false -}} - {{- end -}} - {{- end -}} - - {{- if $enabled -}} + {{- if eq $enabled "true" -}} {{/* Create a copy of the volumesnapshotlocation */}} {{- $objectData := (mustDeepCopy $volSnapLoc) -}} diff --git a/library/common/values.yaml b/library/common/values.yaml index b2949e5d..caf30ee1 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -690,6 +690,7 @@ webhook: webhooks: [] +priorityClass: {} # priorityClass: # example: # provisioner: some.provisioner.io @@ -700,6 +701,7 @@ webhook: # description: "some description" # # -- create storageClasses on demand +storageClass: {} # storageClass: # example: # provisioner: some.provisioner.io