diff --git a/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml b/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml index b1137f79..d318a7bd 100644 --- a/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml @@ -7,6 +7,10 @@ release: tests: - it: should generate correct spec with recovery/backup set: + postgres16Image: + repository: ghcr.io/cloudnative-pg/postgresql + tag: "16.3" + pullPolicy: IfNotPresent cnpg: my-pg: enabled: true @@ -33,7 +37,7 @@ tests: path: spec value: enableSuperuserAccess: true - imageName: ghcr.io/cloudnative-pg/postgresql:16.2 + imageName: ghcr.io/cloudnative-pg/postgresql:16.3 primaryUpdateStrategy: unsupervised primaryUpdateMethod: switchover logLevel: info diff --git a/library/common-test/tests/cnpg/cluster_spec_test.yaml b/library/common-test/tests/cnpg/cluster_spec_test.yaml index 62be1400..0138b6d4 100644 --- a/library/common-test/tests/cnpg/cluster_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_spec_test.yaml @@ -7,6 +7,10 @@ release: tests: - it: should generate correct spec set: + postgres16Image: + repository: ghcr.io/cloudnative-pg/postgresql + tag: "16.3" + pullPolicy: IfNotPresent cnpg: my-pg: enabled: true @@ -29,7 +33,7 @@ tests: path: spec value: enableSuperuserAccess: true - imageName: ghcr.io/cloudnative-pg/postgresql:16.2 + imageName: ghcr.io/cloudnative-pg/postgresql:16.3 primaryUpdateStrategy: unsupervised primaryUpdateMethod: switchover logLevel: info diff --git a/library/common-test/tests/lists/credentialsList_test.yaml b/library/common-test/tests/lists/credentialsList_test.yaml new file mode 100644 index 00000000..3728d3d9 --- /dev/null +++ b/library/common-test/tests/lists/credentialsList_test.yaml @@ -0,0 +1,146 @@ +suite: credentials list test +templates: + - common.yaml +release: + name: test-release-name + namespace: test-release-namespace +tests: + - it: should generate correct spec with backups (s3) (credentialsList) + set: + credentialsList: + - name: test + type: s3 + accessKey: some-access-key + secretKey: some-secret-key + bucket: some-bucket + encrKey: some-encr-key + url: some-url + 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 + asserts: + - documentIndex: &secretDoc 1 + 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: + retentionPolicy: 10d + target: primary + barmanObjectStore: + data: + compression: gzip + encryption: AES256 + 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: test-release-name-common-test-cnpg-my-pg + wal: + compression: gzip + encryption: AES256 + + - it: should generate correct spec with volsync (s3) (credentialsList) + set: + persistence: + destbackup: + enabled: true + type: pvc + mountPath: /backedup + volsync: + - name: mybackup1 + type: restic + credentials: mys3 + dest: + enabled: true + src: + enabled: false + credentialsList: + - name: mys3 + type: s3 + url: some-url + bucket: some-bucket + encrKey: some-key + accessKey: some-access-key + secretKey: some-secret-key + asserts: + - documentIndex: &secretDoc 0 + isKind: + of: Secret + - documentIndex: *secretDoc + isAPIVersion: + of: v1 + - documentIndex: *secretDoc + equal: + path: metadata.name + value: test-release-name-common-test-destbackup-volsync-mybackup1 + - documentIndex: *secretDoc + equal: + path: stringData + value: + AWS_ACCESS_KEY_ID: some-access-key + AWS_SECRET_ACCESS_KEY: some-secret-key + RESTIC_PASSWORD: some-key + RESTIC_REPOSITORY: s3:some-url/some-bucket/test-release-name/volsync/destbackup-volsync-mybackup1 + - documentIndex: &replicationDestDoc 1 + isKind: + of: ReplicationDestination + - documentIndex: *replicationDestDoc + isAPIVersion: + of: volsync.backube/v1alpha1 + - documentIndex: *replicationDestDoc + equal: + path: spec + value: + trigger: + manual: restore-once + restic: + repository: test-release-name-common-test-destbackup-volsync-mybackup1 + copyMethod: Snapshot + capacity: 100Gi + accessModes: + - ReadWriteOnce + moverSecurityContext: + fsGroup: 568 + runAsUser: 568 + runAsGroup: 568 diff --git a/library/common-test/tests/volsync/replication_dest_spec_test.yaml b/library/common-test/tests/volsync/replication_dest_spec_test.yaml index 8985f42c..fc9333bb 100644 --- a/library/common-test/tests/volsync/replication_dest_spec_test.yaml +++ b/library/common-test/tests/volsync/replication_dest_spec_test.yaml @@ -37,6 +37,10 @@ tests: - documentIndex: *secretDoc isAPIVersion: of: v1 + - documentIndex: *secretDoc + equal: + path: metadata.name + value: test-release-name-common-test-destbackup-volsync-mybackup1 - documentIndex: *secretDoc equal: path: stringData diff --git a/library/common-test/tests/volsync/validation_test.yaml b/library/common-test/tests/volsync/validation_test.yaml index 4ec27a01..8812e256 100644 --- a/library/common-test/tests/volsync/validation_test.yaml +++ b/library/common-test/tests/volsync/validation_test.yaml @@ -59,10 +59,17 @@ tests: enabled: true dest: enabled: false - credentials: {} + credentials: + my-other-secret: + type: s3 + url: some-url + bucket: some-bucket + encrKey: some-key + accessKey: some-access-key + secretKey: some-secret-key asserts: - failedTemplate: - errorMessage: VolSync - Expected credentials [my-secret] to be defined in [credentials.my-secret] + errorMessage: VolSync - Expected credentials [my-secret] to be defined in [credentials] which currently contains [my-other-secret] keys - it: should fail if credentials.url is empty set: diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 34f651b8..f4bf439e 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,7 +15,7 @@ maintainers: name: common sources: null type: library -version: 23.0.7 +version: 23.0.8 annotations: artifacthub.io/category: "integration-delivery" artifacthub.io/license: "BUSL-1.1" diff --git a/library/common/templates/class/volsync/_replicationDestination.tpl b/library/common/templates/class/volsync/_replicationDestination.tpl index 5e607797..ee239b40 100644 --- a/library/common/templates/class/volsync/_replicationDestination.tpl +++ b/library/common/templates/class/volsync/_replicationDestination.tpl @@ -29,7 +29,7 @@ apiVersion: volsync.backube/v1alpha1 kind: ReplicationDestination metadata: name: {{ printf "%s-%s-dest" $objectData.name $volsyncData.name }} - namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "replicationdestination") }} + namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "Replication Destination") }} {{- $labels := (mustMerge ($volsyncData.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: diff --git a/library/common/templates/lib/credentials/_validation.tpl b/library/common/templates/lib/credentials/_validation.tpl index 2df1b2bc..01b52e99 100644 --- a/library/common/templates/lib/credentials/_validation.tpl +++ b/library/common/templates/lib/credentials/_validation.tpl @@ -6,7 +6,7 @@ {{- $credentials := get $rootCtx.Values.credentials $credName -}} {{- if not $credentials -}} - {{- fail (printf "%s - Expected credentials [%s] to be defined in [credentials.%s]" $caller $credName $credName) -}} + {{- fail (printf "%s - Expected credentials [%s] to be defined in [credentials] which currently contains [%s] keys" $caller $credName (keys $rootCtx.Values.credentials | join ", ")) -}} {{- end -}} {{- $validCredTypes := list "s3" -}}