fix(cnpg-backup): BREAKING CHANGE allow toggling encryption (#861)

**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  #849 

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [x] 🪛 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:**

- [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):`

** 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: Kjeld Schouten <info@kjeldschouten.nl>
This commit is contained in:
Stavros Kois
2024-09-27 15:10:01 +03:00
committed by GitHub
parent 3b4623d973
commit c6cfef10a6
8 changed files with 82 additions and 27 deletions

View File

@@ -3,7 +3,7 @@ appVersion: ""
dependencies:
- name: common
repository: file://../common
version: ~24.1.0
version: ~25.0.0
deprecated: false
description: Helper chart to test different use cases of the common library
home: https://github.com/truecharts/apps/tree/master/charts/library/common-test

View File

@@ -61,8 +61,6 @@ tests:
backup:
barmanObjectStore:
data:
compression: gzip
encryption: AES256
jobs: 2
destinationPath: some-path
endpointURL: some-url
@@ -74,9 +72,6 @@ tests:
key: ACCESS_SECRET_KEY
name: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
serverName: test-release-name-common-test-cnpg-my-pg
wal:
compression: gzip
encryption: AES256
retentionPolicy: 10d
target: primary
@@ -131,8 +126,6 @@ tests:
backup:
barmanObjectStore:
data:
compression: gzip
encryption: AES256
jobs: 2
destinationPath: some-path
endpointURL: some-url
@@ -144,9 +137,6 @@ tests:
key: ACCESS_SECRET_KEY
name: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
serverName: test-release-name-common-test-cnpg-my-pg-rsome-revision
wal:
compression: gzip
encryption: AES256
retentionPolicy: 10d
target: primary
@@ -201,8 +191,6 @@ tests:
backup:
barmanObjectStore:
data:
compression: gzip
encryption: AES256
jobs: 2
destinationPath: some-path
endpointURL: some-url
@@ -214,9 +202,6 @@ tests:
key: ACCESS_SECRET_KEY
name: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
serverName: some-server-name
wal:
compression: gzip
encryption: AES256
retentionPolicy: 10d
target: primary
@@ -238,6 +223,72 @@ tests:
destinationPath: some-path
serverName: some-server-name
revision: "1"
asserts:
- documentIndex: *secretDoc
isKind:
of: Secret
- documentIndex: *secretDoc
isAPIVersion:
of: v1
- documentIndex: *secretDoc
equal:
path: metadata.name
value: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
- documentIndex: *secretDoc
equal:
path: stringData
value:
ACCESS_KEY_ID: some-access-key
ACCESS_SECRET_KEY: some-secret-key
- documentIndex: &clusterDoc 0
isKind:
of: Cluster
- documentIndex: *clusterDoc
isAPIVersion:
of: postgresql.cnpg.io/v1
- documentIndex: *clusterDoc
equal:
path: metadata.name
value: test-release-name-common-test-cnpg-my-pg
- documentIndex: *clusterDoc
isSubset:
path: spec
content:
backup:
barmanObjectStore:
data:
jobs: 2
destinationPath: some-path
endpointURL: some-url
s3Credentials:
accessKeyId:
key: ACCESS_KEY_ID
name: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
secretAccessKey:
key: ACCESS_SECRET_KEY
name: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
serverName: some-server-name-r1
retentionPolicy: 10d
target: primary
- it: should enable encryption when set
set:
credentials:
test: *test
cnpg:
my-pg:
enabled: true
user: test-user
database: test-db
password: test-password
backups:
enabled: true
target: primary
retentionPolicy: 10d
credentials: test
destinationPath: some-path
encryption:
enabled: true
asserts:
- documentIndex: *secretDoc
isKind:
@@ -284,7 +335,7 @@ tests:
secretAccessKey:
key: ACCESS_SECRET_KEY
name: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
serverName: some-server-name-r1
serverName: test-release-name-common-test-cnpg-my-pg
wal:
compression: gzip
encryption: AES256

View File

@@ -15,7 +15,7 @@ maintainers:
name: common
sources: null
type: library
version: 24.1.19
version: 25.0.0
annotations:
artifacthub.io/category: "integration-delivery"
artifacthub.io/license: "BUSL-1.1"

View File

@@ -143,7 +143,7 @@
{{- $imageName := $objectData.cluster.imageName -}}
{{- if not $imageName -}}
{{/* Ensure version and container tracking */}}
{{- $imageType := camelcase ($objectData.type | default "postgres") -}}
{{- $imageType := ($objectData.type | default "postgres") | camelcase | title -}}
{{- if eq $imageType "Postgres" -}}
{{- $imageType = "" -}}
{{- end -}}

View File

@@ -7,13 +7,15 @@ backup:
{{- end }}
retentionPolicy: {{ $objectData.backups.retentionPolicy }}
barmanObjectStore:
wal:
compression: gzip
encryption: AES256
data:
compression: gzip
encryption: AES256
jobs: {{ $objectData.backups.jobs | default 2 }}
{{- if and $objectData.backups.encryption $objectData.backups.encryption.enabled }}
compression: "gzip"
encryption: "AES256"
wal:
compression: "gzip"
encryption: "AES256"
{{- end -}}
{{/* Fetch provider data */}}
{{/* Get the creds defined in backup.$provider */}}
{{- $creds := (get $rootCtx.Values.credentials $objectData.backups.credentials) -}}

View File

@@ -57,7 +57,7 @@ objectData: The object data to be used to render the container.
{{- $data = (get $data $name) -}}
{{- if not $data -}}
{{- fail (printf "Container - Expected in [env] the referenced %s [%s] to be defined" (camelcase $item) $name) -}}
{{- fail (printf "Container - Expected in [env] the referenced %s [%s] to be defined" ($item | camelcase | title) $name) -}}
{{- end -}}
{{- $found := false -}}
@@ -68,7 +68,7 @@ objectData: The object data to be used to render the container.
{{- end -}}
{{- if not $found -}}
{{- fail (printf "Container - Expected in [env] the referenced key [%s] in %s [%s] to be defined" $obj.key (camelcase $item) $name) -}}
{{- fail (printf "Container - Expected in [env] the referenced key [%s] in %s [%s] to be defined" $obj.key ($item | camelcase | title) $name) -}}
{{- end -}}
{{- $name = (printf "%s-%s" (include "tc.v1.common.lib.chart.names.fullname" $rootCtx) $name) -}}

View File

@@ -15,7 +15,7 @@
{{- include "tc.v1.common.lib.ingress.integration.homepage.validation" (dict "objectData" $objectData) -}}
{{- $name := $homepage.name | default ($rootCtx.Release.Name | camelcase) -}}
{{- $name := $homepage.name | default ($rootCtx.Release.Name | camelcase | title) -}}
{{- $desc := $homepage.description | default $rootCtx.Chart.Description -}}
{{- $icon := $homepage.icon | default $rootCtx.Chart.Icon -}}
{{- $defaultType := $rootCtx.Chart.Name | lower -}}

View File

@@ -1092,6 +1092,8 @@ cnpg:
backups:
enabled: false # You need to configure backups manually, so backups are disabled by default.
encryption:
enabled: false
## set a revision to append to the serverName to ensure restore and backup dont target the same thing
# revision: 1