Files
truecharts/charts/library/common/templates/lib/cnpg/cluster/_backup.tpl
T
8dc3b8e67d feat(common): handle separately backup compression & encryption (#29139)
**Description**

Currently compression is only enabled for backups and wal if the
encryption is enabled

This PR allows to set encryption and compression parameters separately

**⚙️ Type of change**

- [x] ⚙️ Feature/App addition
- [x] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
- Ran the updated tests
- Checked on a live cluster with the different combinations

**📃 Notes:**
I checked if it would impact charts using cnpg with encrypted backups
enabled but didn't find any

**✔️ Checklist:**

- [x] ⚖️ My code follows the style guidelines of this project
- [x] 👀 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
- [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
- [x] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):` or `chore(chart-name):`


---

---------

Signed-off-by: Kjeld Schouten <info@kjeldschouten.nl>
Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
Signed-off-by: Matthieu Simon <matthieu@bluegreen.sh>
Co-authored-by: Kjeld Schouten <info@kjeldschouten.nl>
Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
2024-11-12 14:48:01 +01:00

44 lines
1.5 KiB
Smarty

{{- define "tc.v1.common.lib.cnpg.cluster.backup" -}}
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData -}}
{{- $compression := "bzip2" -}}
{{- if and $objectData.backups.compression (not $objectData.backups.compression.enabled) -}}
{{- $compression = "" -}}
{{- end -}}
{{- $encryption := "" -}}
{{- if and $objectData.backups.encryption $objectData.backups.encryption.enabled -}}
{{- $encryption = "AES256" -}}
{{- end }}
backup:
{{- with $objectData.backups.target }}
target: {{ . }}
{{- end }}
retentionPolicy: {{ $objectData.backups.retentionPolicy }}
barmanObjectStore:
data:
jobs: {{ $objectData.backups.jobs | default 2 }}
{{- with $compression }}
compression: {{ . }}
{{- end -}}
{{- with $encryption }}
encryption: {{ . }}
{{- end -}}
{{- if or $compression $encryption }}
wal:
{{- with $compression }}
compression: {{ . }}
{{- end -}}
{{- with $encryption }}
encryption: {{ . }}
{{- end -}}
{{- end -}}
{{/* Fetch provider data */}}
{{/* Get the creds defined in backup.$provider */}}
{{- $creds := (get $rootCtx.Values.credentials $objectData.backups.credentials) -}}
{{- include "tc.v1.common.lib.credentials.validation" (dict "rootCtx" $rootCtx "caller" "CNPG Backup" "credName" $objectData.backups.credentials) -}}
{{- include (printf "tc.v1.common.lib.cnpg.cluster.barmanObjectStoreConfig.%s" $creds.type) (dict "rootCtx" $rootCtx "objectData" $objectData "data" $creds "type" "backup") | nindent 4 -}}
{{- end -}}