From e66199cec9a815fa91585fb3e3f9998439d1938b Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Tue, 30 Apr 2024 10:55:46 +0300 Subject: [PATCH] chore(volsync): clearer namings and usage --- .../lib/cnpg/barmanObjectStore/_azure.tpl | 4 ++-- .../lib/cnpg/barmanObjectStore/_google.tpl | 4 ++-- .../lib/cnpg/barmanObjectStore/_s3.tpl | 4 ++-- library/common/templates/spawner/_pvc.tpl | 17 ++++++++--------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl b/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl index b5d96001..72ffc9e4 100644 --- a/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl +++ b/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl @@ -29,9 +29,9 @@ {{- fail (printf "CNPG %s - You need to specify [%s.azure.containerName] or [%s.destinationPath]" ($type | camelcase) $key $key) -}} {{- end -}} {{- 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) -}} + {{- $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) -}} + {{- $destinationPath = (printf "https://%s.%s.core.windows.net/%s/%s/cnpg" $data.storageAccount $data.serviceName $data.containerName $rootCtx.Release.Name) -}} {{- end -}} {{- end }} endpointURL: {{ $endpointURL }} diff --git a/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl b/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl index 28cc5a27..9e8e3d6b 100644 --- a/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl +++ b/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl @@ -28,9 +28,9 @@ {{- fail (printf "CNPG %s - You need to specify [%s.google.bucket] or [%s.destinationPath]" ($type | camelcase) $key $key) -}} {{- end -}} {{- if $data.path -}} - {{- $destinationPath = (printf "gs://%s/%s/%s/cnpg" $data.bucket ($data.path | trimSuffix "/") $rootCtx.Release.Name) -}} + {{- $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) -}} + {{- $destinationPath = (printf "gs://%s/%s/cnpg" $data.bucket $rootCtx.Release.Name) -}} {{- end -}} {{- end }} endpointURL: {{ $endpointURL }} diff --git a/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl b/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl index d193c7c9..9ab1a68d 100644 --- a/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl +++ b/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl @@ -23,9 +23,9 @@ {{- fail (printf "CNPG %s - You need to specify [%s.s3.bucket] or [%s.destinationPath]" ($type | camelcase) $key $key) -}} {{- end -}} {{- if $data.path -}} - {{- $destinationPath = (printf "s3://%s/%s/%s/cnpg" $data.bucket ($data.path | trimSuffix "/") $rootCtx.Release.Name ) -}} + {{- $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) -}} + {{- $destinationPath = (printf "s3://%s/%s/cnpg" $data.bucket $rootCtx.Release.Name) -}} {{- end -}} {{- end -}} {{- if not $endpointURL -}} diff --git a/library/common/templates/spawner/_pvc.tpl b/library/common/templates/spawner/_pvc.tpl index 7a2cfffc..d15de648 100644 --- a/library/common/templates/spawner/_pvc.tpl +++ b/library/common/templates/spawner/_pvc.tpl @@ -102,26 +102,25 @@ {{- $credentials := get $.Values.credentials $volsync.credentials -}} - {{- $resticrepository := printf "s3:%s/%s/%s/volsync/%s-volsync-%s" $credentials.url $credentials.bucket $.Release.Name $objectData.shortName $volsyncData.name -}} + {{- $baseRepo := printf "s3:%s/%s" $credentials.url $credentials.bucket -}} + {{- $repoSuffix := printf "%s/volsync/%s-volsync-%s" $.Release.Name $objectData.shortName $volsyncData.name -}} + {{- $resticrepository := printf "%s/%s" $baseRepo $repoSuffix -}} {{- if $credentials.path -}} - {{- $resticrepository = printf "s3:%s/%s/%s/%s/volsync/%s-volsync-%s" $credentials.url $credentials.bucket ( $credentials.path | trimSuffix "/" ) $.Release.Name $objectData.shortName $volsyncData.name -}} + {{- $resticrepository = printf "%s/%s/%s" $baseRepo ($credentials.path | trimSuffix "/") $repoSuffix -}} {{- end -}} - {{- $resticpassword := ( $credentials.encrKey | default $.Release.Name ) -}} - {{- $s3id := $credentials.accessKey -}} - {{- $s3key := $credentials.secretKey -}} - {{- $volsyncSecretData := (dict "name" $volsyncSecretName "labels" ($volsync.labels | default dict) "annotations" ($volsync.annotations | default dict) "data" (dict "RESTIC_REPOSITORY" $resticrepository - "RESTIC_PASSWORD" $resticpassword - "AWS_ACCESS_KEY_ID" $s3id - "AWS_SECRET_ACCESS_KEY" $s3key + "RESTIC_PASSWORD" $credentials.encrKey + "AWS_ACCESS_KEY_ID" $credentials.accessKey + "AWS_SECRET_ACCESS_KEY" $credentials.secretKey ) ) -}} + {{- include "tc.v1.common.class.secret" (dict "rootCtx" $ "objectData" $volsyncSecretData) -}} {{/* Create VolSync resources*/}} {{- if $srcEnabled -}}