mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-04 22:01:23 -03:00
**Description** <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> ⚒️ Fixes #584 **⚙️ 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?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ 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._
54 lines
2.1 KiB
Smarty
54 lines
2.1 KiB
Smarty
{{/* PVC - Storage Class Name */}}
|
|
{{/* Call this template:
|
|
{{ include "tc.v1.common.lib.storage.storageClassName" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
|
rootCtx: The root context of the chart.
|
|
objectData: The object data of the pvc
|
|
*/}}
|
|
{{- define "tc.v1.common.lib.storage.storageClassName" -}}
|
|
{{- $objectData := .objectData -}}
|
|
{{- $rootCtx := .rootCtx -}}
|
|
{{- $caller := .caller -}}
|
|
|
|
{{/*
|
|
If storageClass is defined on the objectData:
|
|
* "-" returns "", which means requesting a PV without class
|
|
* "SCALE-ZFS" returns the value set on Values.global.ixChartContext.storageClassName
|
|
* Else return the original defined storageClass
|
|
|
|
Else if we are in an ixChartContext, always return the storageClassName defined on the ixChartContext
|
|
|
|
Else if there is a storageClass defined in Values.fallbackDefaults.storageClass, return this
|
|
|
|
In any other case, return nothing
|
|
*/}}
|
|
|
|
{{- $className := "" -}}
|
|
{{- if $objectData.storageClass -}}
|
|
{{- $storageClass := (tpl $objectData.storageClass $rootCtx) -}}
|
|
|
|
{{- if eq "-" $storageClass -}}
|
|
{{- $className = "\"\"" -}}
|
|
{{- else if eq "SCALE-ZFS" $storageClass -}}
|
|
{{- if not $rootCtx.Values.global.ixChartContext.storageClassName -}}
|
|
{{- fail (printf "%s - Expected non-empty [global.ixChartContext.storageClassName] on [SCALE-ZFS] storageClass" $caller) -}}
|
|
{{- end -}}
|
|
{{- $className = tpl $rootCtx.Values.global.ixChartContext.storageClassName $rootCtx -}}
|
|
{{- else -}}
|
|
{{- $className = tpl $storageClass $rootCtx -}}
|
|
{{- end -}}
|
|
|
|
{{- else if $rootCtx.Values.global.ixChartContext -}}
|
|
{{- if not $rootCtx.Values.global.ixChartContext.storageClassName -}}
|
|
{{- fail (printf "%s - Expected non-empty [global.ixChartContext.storageClassName]" $caller) -}}
|
|
{{- end -}}
|
|
{{- $className = tpl $rootCtx.Values.global.ixChartContext.storageClassName $rootCtx -}}
|
|
|
|
{{- else if $rootCtx.Values.fallbackDefaults.storageClass -}}
|
|
|
|
{{- $className = tpl $rootCtx.Values.fallbackDefaults.storageClass $rootCtx -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $className -}}
|
|
{{- end -}}
|