mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 13:24:16 -03:00
**Description** Does what it says on the tin Fixes: #727 **⚙️ Type of change** - [x] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [x] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] 🔃 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:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 I have performed a self-review of my own code - [x] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [x] ⚠️ My changes generate no new warnings - [x] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [x] ⬆️ 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 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._ --------- Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Co-authored-by: Stavros kois <s.kois@outlook.com>
76 lines
3.0 KiB
Smarty
76 lines
3.0 KiB
Smarty
{{/* PersistentVolume Class */}}
|
|
{{/* Call this template:
|
|
{{ include "tc.v1.common.class.pv" (dict "rootCtx" $ "objectData" $objectData) }}
|
|
|
|
rootCtx: The root context of the chart.
|
|
objectData:
|
|
name: The name of the PV.
|
|
labels: The labels of the PV.
|
|
annotations: The annotations of the PV.
|
|
provisioner: The provisioner to use for the PersistentVolume.
|
|
driver: The driver to use for the csi
|
|
retain: Whether to retain the PV after deletion. (Default: false)
|
|
size: The size of the PersistentVolume. (Default: 1Gi)
|
|
*/}}
|
|
|
|
{{- define "tc.v1.common.class.pv" -}}
|
|
|
|
{{- $rootCtx := .rootCtx -}}
|
|
{{- $objectData := .objectData -}}
|
|
|
|
{{- $retain := $rootCtx.Values.global.fallbackDefaults.pvcRetain -}}
|
|
{{- if not (kindIs "invalid" $objectData.retain) -}}
|
|
{{- $retain = $objectData.retain -}}
|
|
{{- end -}}
|
|
|
|
{{- $reclaimPolicy := ternary "Retain" "Delete" $retain -}}
|
|
|
|
{{- $pvcSize := $rootCtx.Values.global.fallbackDefaults.pvcSize -}}
|
|
{{- with $objectData.size -}}
|
|
{{- $pvcSize = tpl . $rootCtx -}}
|
|
{{- end }}
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata:
|
|
name: {{ $objectData.name }}
|
|
{{- $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)) -}}
|
|
{{- if $retain -}}
|
|
{{- $_ := set $annotations "\"helm.sh/resource-policy\"" "keep" -}}
|
|
{{- end -}}
|
|
{{- $_ := set $annotations "pv.kubernetes.io/provisioned-by" $objectData.provisioner -}}
|
|
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
|
|
annotations:
|
|
{{- . | nindent 4 }}
|
|
{{- end }}
|
|
spec:
|
|
capacity:
|
|
storage: {{ $pvcSize }}
|
|
persistentVolumeReclaimPolicy: {{ $reclaimPolicy }}
|
|
storageClassName: {{ $objectData.name }}
|
|
accessModes:
|
|
{{- include "tc.v1.common.lib.pvc.accessModes" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "Persistent Volume") | trim | nindent 4 -}}
|
|
{{- if $objectData.mountOptions }}
|
|
mountOptions:
|
|
{{- range $opt := $objectData.mountOptions -}}
|
|
{{- if $opt.value }}
|
|
- {{ printf "%s=%s" (tpl $opt.key $rootCtx) (tpl (include "tc.v1.common.helper.makeIntOrNoop" $opt.value) $rootCtx) }}
|
|
{{- else }}
|
|
- {{ tpl $opt.key $rootCtx }}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- if $objectData.static -}}
|
|
{{- if eq "smb" $objectData.static.mode -}}
|
|
{{- include "tc.v1.common.lib.storage.smbCSI" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 -}}
|
|
{{- else if eq "nfs" $objectData.static.mode -}}
|
|
{{- include "tc.v1.common.lib.storage.nfsCSI" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|