From 7a148e5a3ffbf01047c99abda69730247cebb682 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Sat, 5 Dec 2020 23:03:57 +0500 Subject: [PATCH] Properly configure postgres host path --- test/nextcloud/2.3.2/questions.yaml | 3 ++- test/nextcloud/2.3.2/templates/_helpers.tpl | 24 ++++++++++++++----- .../nextcloud/2.3.2/templates/deployment.yaml | 1 - .../2.3.2/templates/postgres-deployment.yaml | 4 ++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/test/nextcloud/2.3.2/questions.yaml b/test/nextcloud/2.3.2/questions.yaml index ff3cc82e765..6e5e14bfd34 100644 --- a/test/nextcloud/2.3.2/questions.yaml +++ b/test/nextcloud/2.3.2/questions.yaml @@ -138,7 +138,8 @@ questions: label: "Dataset Name" schema: type: string - required: true + default: "nextcloud_data" + editable: false - variable: configureHostPath label: "Configure Host Path for storage" diff --git a/test/nextcloud/2.3.2/templates/_helpers.tpl b/test/nextcloud/2.3.2/templates/_helpers.tpl index 004ec38d447..1719889fd6d 100644 --- a/test/nextcloud/2.3.2/templates/_helpers.tpl +++ b/test/nextcloud/2.3.2/templates/_helpers.tpl @@ -48,13 +48,25 @@ Create chart name and version as used by the chart label. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Retrieve host path from ix volumes based on dataset name +*/}} +{{- define "retrieveHostPathFromiXVolume" -}} +{{- range $index, $hostPathConfiguration := $.ixVolumes }} +{{- $dsName := base $hostPathConfiguration.hostPath -}} +{{- if eq $.datasetName $dsName -}} +{{- $hostPathConfiguration.hostPath -}} +{{- end -}} +{{- end }} +{{- end -}} + {{/* Retrieve host path defined in volume */}} {{- define "configuredHostPath" -}} {{- if .Values.configureiXVolume -}} -{{- $volDict := first .Values.ixVolumes -}} -{{- $volDict.hostPath -}} +{{- $volDict := dict "datasetName" $.Values.volume.datasetName "ixVolumes" $.Values.ixVolumes -}} +{{- include "retrieveHostPathFromiXVolume" $volDict -}} {{- else if .Values.configureHostPath -}} {{- .Values.volumeHostPath -}} {{- else -}} @@ -66,16 +78,16 @@ Retrieve host path defined in volume Retrieve backup postgresql host path defined in volume */}} {{- define "configuredBackupPostgresHostPath" -}} -{{- $backupVolDict := first .Values.postgresql.backupVolume -}} -{{- $backupVolDict.hostPath -}} +{{- $volDict := dict "datasetName" $.Values.postgresql.backupVolume.datasetName "ixVolumes" $.Values.ixVolumes -}} +{{- include "retrieveHostPathFromiXVolume" $volDict -}} {{- end -}} {{/* Retrieve postgresql data host path defined in volume */}} {{- define "configuredPostgresHostPath" -}} -{{- $dataVolDict := first .Values.postgresql.dataVolume -}} -{{- $dataVolDict.hostPath -}} +{{- $volDict := dict "datasetName" $.Values.postgresql.dataVolume.datasetName "ixVolumes" $.Values.ixVolumes -}} +{{- include "retrieveHostPathFromiXVolume" $volDict -}} {{- end -}} {{/* diff --git a/test/nextcloud/2.3.2/templates/deployment.yaml b/test/nextcloud/2.3.2/templates/deployment.yaml index 4af94c6ce0e..97dfba7d9e6 100644 --- a/test/nextcloud/2.3.2/templates/deployment.yaml +++ b/test/nextcloud/2.3.2/templates/deployment.yaml @@ -57,7 +57,6 @@ spec: secretKeyRef: name: db-details key: db-password - {{- end }} - name: NEXTCLOUD_ADMIN_USER valueFrom: secretKeyRef: diff --git a/test/nextcloud/2.3.2/templates/postgres-deployment.yaml b/test/nextcloud/2.3.2/templates/postgres-deployment.yaml index fb63d918f06..2214fc340b5 100644 --- a/test/nextcloud/2.3.2/templates/postgres-deployment.yaml +++ b/test/nextcloud/2.3.2/templates/postgres-deployment.yaml @@ -50,7 +50,7 @@ spec: volumes: - name: postgres-data hostPath: - path: "/mnt/evo/ix-applications/releases/nextcloud/volumes/ix_volumes/ix-postgres_data" + path: {{ template "configuredPostgresHostPath" . }} - name: postgres-backup hostPath: - path: "/mnt/evo/ix-applications/releases/nextcloud/volumes/ix_volumes/ix-postgres_backups" + path: {{ template "configuredBackupPostgresHostPath" . }}