From 8e719a47870319d511d8c50b2e5bcf72c2b9b7f6 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Fri, 4 Dec 2020 00:48:31 +0500 Subject: [PATCH] Allow using host path or ix volume for persistent data storage --- test/nextcloud/2.3.2/questions.yaml | 51 +++++++++++++++++++ test/nextcloud/2.3.2/templates/_helpers.tpl | 14 +++++ .../nextcloud/2.3.2/templates/deployment.yaml | 3 ++ 3 files changed, 68 insertions(+) diff --git a/test/nextcloud/2.3.2/questions.yaml b/test/nextcloud/2.3.2/questions.yaml index ed104821677..fafc322b0ec 100644 --- a/test/nextcloud/2.3.2/questions.yaml +++ b/test/nextcloud/2.3.2/questions.yaml @@ -3,6 +3,8 @@ groups: description: "Image to be used for container" - name: "Nextcloud Configuration" description: "Configuration details for Nextcloud workload" + - name: "Storage Configuration" + description: "Configure Storage for Nextcloud" questions: # Image related @@ -101,3 +103,52 @@ questions: max: 65535 default: 9000 required: true + + - variable: configureiXVolume + label: "Configure iX Volume" + group: "Storage Configuration" + description: "Use iX Volume for persistent storage" + schema: + type: boolean + default: true + required: true + show_subquestions_if: true + subquestions: + - variable: volume + label: "Configure iXVolume" + group: "Storage Configuration" + schema: + type: dict + $ref: + - "normalize/ixVolume" + attrs: + - variable: mountPath + label: "Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + editable: false + default: "/var/www" + - variable: datasetName + label: "Dataset Name" + schema: + type: string + required: true + + - variable: configureHostPath + label: "Configure Host Path for storage" + description: "Use a path on host for persistent data storage" + group: "Storage Configuration" + schema: + type: boolean + default: false + required: true + show_if: [["configureiXVolume", "=", false]] + show_subquestions_if: true + subquestions: + - variable: volumeHostPath + label: "Host Path" + group: "Storage Configuration" + schema: + type: hostpath + required: true diff --git a/test/nextcloud/2.3.2/templates/_helpers.tpl b/test/nextcloud/2.3.2/templates/_helpers.tpl index 87c6e91d1bd..0761b84d9c0 100644 --- a/test/nextcloud/2.3.2/templates/_helpers.tpl +++ b/test/nextcloud/2.3.2/templates/_helpers.tpl @@ -47,3 +47,17 @@ Create chart name and version as used by the chart label. {{- define "nextcloud.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Retrieve host path defined in volume +*/}} +{{- define "configuredHostPath" -}} +{{- if .Values.configureiXVolume -}} +{{- $volDict := first .Values.ixVolumes -}} +{{- $volDict.hostPath -}} +{{- else if .Values.configureHostPath -}} +{{- .Values.volumeHostPath -}} +{{- else -}} +{{- printf "" -}} +{{- end -}} +{{- end -}} diff --git a/test/nextcloud/2.3.2/templates/deployment.yaml b/test/nextcloud/2.3.2/templates/deployment.yaml index fad0d7a3b6d..ad73b1fd298 100644 --- a/test/nextcloud/2.3.2/templates/deployment.yaml +++ b/test/nextcloud/2.3.2/templates/deployment.yaml @@ -328,6 +328,9 @@ spec: {{- if .Values.persistence.enabled }} persistentVolumeClaim: claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud{{- end }} + {{- else if ne (include "configuredHostPath" .) "" }} + hostPath: + path: {{ template "configuredHostPath" . }} {{- else }} emptyDir: {} {{- end }}