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 ebb69eae..67685b27 100644 --- a/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml @@ -78,6 +78,7 @@ tests: type: google applicationCredentials: some-credentials bucket: some-bucket + path: some-path cnpg: my-pg: enabled: true @@ -85,7 +86,6 @@ tests: database: test-db password: test-password mode: recovery - path: some-path recovery: method: object_store credentials: test @@ -138,7 +138,7 @@ tests: - name: test-release-name-common-test-cnpg-my-pg barmanObjectStore: serverName: test-release-name-common-test-cnpg-my-pg - destinationPath: gs://some-bucket/some-path + destinationPath: gs://some-bucket/some-path/test-release-name/cnpg endpointURL: null googleCredentials: applicationCredentials: @@ -229,6 +229,7 @@ tests: secretKey: some-secret-key bucket: some-bucket region: some-region + path: some-path cnpg: my-pg: enabled: true @@ -236,7 +237,6 @@ tests: database: test-db password: test-password mode: recovery - path: some-path recovery: method: object_store credentials: test @@ -287,7 +287,7 @@ tests: - name: test-release-name-common-test-cnpg-my-pg barmanObjectStore: serverName: test-release-name-common-test-cnpg-my-pg - destinationPath: s3://some-bucket/some-path + destinationPath: s3://some-bucket/some-path/test-release-name/cnpg endpointURL: https://s3.some-region.amazonaws.com s3Credentials: accessKeyId: @@ -382,6 +382,7 @@ tests: storageAccount: some-storage-account serviceName: some-service-name containerName: some-container-name + path: some-path cnpg: my-pg: @@ -390,7 +391,6 @@ tests: database: test-db password: test-password mode: recovery - path: some-path recovery: method: object_store credentials: test @@ -442,7 +442,7 @@ tests: - name: test-release-name-common-test-cnpg-my-pg barmanObjectStore: serverName: test-release-name-common-test-cnpg-my-pg - destinationPath: https://some-storage-account.some-service-name.core.windows.net/some-container-name/some-path + destinationPath: https://some-storage-account.some-service-name.core.windows.net/some-container-name/some-path/test-release-name/cnpg endpointURL: null azureCredentials: connectionString: diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 4ad9f07c..f04afc56 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,7 +15,7 @@ maintainers: name: common sources: null type: library -version: 22.0.0 +version: 22.0.1 annotations: artifacthub.io/category: "integration-delivery" artifacthub.io/license: "BUSL-1.1" diff --git a/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl b/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl index 6dc3bb6c..b5d96001 100644 --- a/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl +++ b/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl @@ -28,7 +28,11 @@ {{- if not $data.containerName -}} {{- fail (printf "CNPG %s - You need to specify [%s.azure.containerName] or [%s.destinationPath]" ($type | camelcase) $key $key) -}} {{- end -}} - {{- $destinationPath = (printf "https://%s.%s.core.windows.net/%s/%s" $data.storageAccount $data.serviceName $data.containerName (($objectData.path | default "/") | trimSuffix "/")) -}} + {{- if $data.path -}} + {{- $destinationPath = (printf "https://%s.%s.core.windows.net/%s/%s/%s/cnpg" $data.storageAccount $data.serviceName $data.containerName ($data.path | trimSuffix "/") $rootCtx.Release.Name) -}} + {{- else -}} + {{- $destinationPath = (printf "https://%s.%s.core.windows.net/%s/%s/cnpg" $data.storageAccount $data.serviceName $data.containerName $rootCtx.Release.Name) -}} + {{- end -}} {{- end }} endpointURL: {{ $endpointURL }} destinationPath: {{ $destinationPath }} diff --git a/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl b/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl index 2aa2da95..28cc5a27 100644 --- a/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl +++ b/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl @@ -27,7 +27,11 @@ {{- if not $data.bucket -}} {{- fail (printf "CNPG %s - You need to specify [%s.google.bucket] or [%s.destinationPath]" ($type | camelcase) $key $key) -}} {{- end -}} - {{- $destinationPath = (printf "gs://%s/%s" $data.bucket (($objectData.path | default "/") | trimSuffix "/")) -}} + {{- if $data.path -}} + {{- $destinationPath = (printf "gs://%s/%s/%s/cnpg" $data.bucket ($data.path | trimSuffix "/") $rootCtx.Release.Name) -}} + {{- else -}} + {{- $destinationPath = (printf "gs://%s/%s/cnpg" $data.bucket $rootCtx.Release.Name) -}} + {{- end -}} {{- end }} endpointURL: {{ $endpointURL }} destinationPath: {{ $destinationPath }} diff --git a/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl b/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl index 659fc96e..d193c7c9 100644 --- a/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl +++ b/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl @@ -22,7 +22,11 @@ {{- if not $data.bucket -}} {{- fail (printf "CNPG %s - You need to specify [%s.s3.bucket] or [%s.destinationPath]" ($type | camelcase) $key $key) -}} {{- end -}} - {{- $destinationPath = (printf "s3://%s/%s" $data.bucket (($objectData.path | default "/") | trimSuffix "/")) -}} + {{- if $data.path -}} + {{- $destinationPath = (printf "s3://%s/%s/%s/cnpg" $data.bucket ($data.path | trimSuffix "/") $rootCtx.Release.Name ) -}} + {{- else -}} + {{- $destinationPath = (printf "s3://%s/%s/cnpg" $data.bucket $rootCtx.Release.Name) -}} + {{- end -}} {{- end -}} {{- if not $endpointURL -}} {{- if not $data.region -}} diff --git a/library/common/templates/spawner/_pvc.tpl b/library/common/templates/spawner/_pvc.tpl index 8823f8d2..a62728af 100644 --- a/library/common/templates/spawner/_pvc.tpl +++ b/library/common/templates/spawner/_pvc.tpl @@ -101,8 +101,13 @@ {{- $_ := set $volsyncData "repository" $volsyncSecretName -}} {{- $credentials := get $.Values.credentials $volsync.credentials -}} - {{- $resticrepository := printf "s3:%s/%s/%s/%s" $credentials.url $credentials.bucket $.Release.Name $volsyncSecretName -}} - {{- $resticpassword := $credentials.encrKey -}} + + {{- $resticrepository := printf "s3:%s/%s/volsync/%s" $credentials.url $credentials.bucket $.Release.Name $volsyncSecretName -}} + {{- if $credentials.path -}} + {{- $resticrepository = printf "s3:%s/%s/%s/volsync/%s" $credentials.url $credentials.bucket ( $credentials.path | trimSuffix "/" ) $.Release.Name $volsyncSecretName -}} + {{- end -}} + + {{- $resticpassword := ( $credentials.encrKey | default $.Release.Name ) -}} {{- $s3id := $credentials.accessKey -}} {{- $s3key := $credentials.secretKey -}} diff --git a/library/common/values.yaml b/library/common/values.yaml index 2535a3de..5ef45e63 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -229,14 +229,17 @@ credentials: {} # mys3: # type: s3 # url: "" + # path: "" # region: "" # bucket: "" # accessKey: "" # secretKey: "" + # ## Is used in cases where things are encrypted by a backup utility # encrKey: "" # azure: + # path: "" # connectionString: "" # storageAccount: "" # storageKey: "" @@ -247,6 +250,7 @@ credentials: {} ## TODO: Add support for google: # google: + # path: "" # bucket: "" # gkeEnvironment: false # applicationCredentials: "" @@ -284,6 +288,7 @@ persistence: medium: Memory targetSelectAll: true # backupexample: +# ## the default backup path, is the credential path suffixed by the releasename, volsync and both the pvc and volsync names # enabled: true # type: pvc # mountPath: /backedup @@ -1123,7 +1128,6 @@ cnpg: # Azure: https://..core.windows.net/ # Google: gs:// destinationPath: "" - path: "/" # Database cluster backup configuration backups: @@ -1146,7 +1150,6 @@ cnpg: # name of credentials in .Values.Credentials credentials: "" - path: "/" scheduledBackups: - name: daily-backup # Daily at midnight