fixes 1 Andrea Pulvirenti <an.pulvy@gmail.com>

This commit is contained in:
Andrea Pulvirenti 2023-10-22 13:58:18 +02:00 committed by Andrea Pulvirenti
parent 1be1e74c8d
commit 53a4ad4c4b
4 changed files with 9 additions and 8 deletions

View File

@ -2,7 +2,7 @@
{{/* {{/*
Allow namespace to be overriden Allow namespace to be overriden
*/}} */}}
{{- define "common.name.namespace" -}} {{- define "common.names.namespace" -}}
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}} {{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
@ -146,7 +146,7 @@ Params:
*/}} */}}
{{- define "common.configmap.lookup" -}} {{- define "common.configmap.lookup" -}}
{{- $value := "" -}} {{- $value := "" -}}
{{- $configmapData := (lookup "v1" "ConfigMap" (include "common.names.namespace" .context) .configmapName).data -}} {{- $configmapData := (lookup "v1" "ConfigMap" (include "common.names.namespace" .context) (index . "config")).data -}}
{{- if and $configmapData (hasKey $configmapData .key) -}} {{- if and $configmapData (hasKey $configmapData .key) -}}
{{- $value = index $configmapData .key -}} {{- $value = index $configmapData .key -}}
{{- else if .defaultValue -}} {{- else if .defaultValue -}}

View File

@ -1,6 +1,6 @@
{{ if (include "nfs.existing-configmap-provided" .) }} {{ if (include "nfs.existing-configmap-provided" .) }}
{{- $existingConfigMap := (lookup "v1" "ConfigMap" .Values.nfs.existingConfigMap.namespace .Values.nfs.existingConfigMap.name).data | default dict }} {{- $existingConfigMap := (lookup "v1" "ConfigMap" .Values.nfs.existingConfigMap.namespace .Values.nfs.existingConfigMap.name ).data }}
{{- if not $existingConfigMap }} {{- if (not $existingConfigMap) }}
apiVersion: v1 apiVersion: v1
data: data:
path: {{ .Values.nfs.path }} path: {{ .Values.nfs.path }}
@ -9,5 +9,7 @@ immutable: false
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: {{ template "nfs.existing-configmap" . }} name: {{ template "nfs.existing-configmap" . }}
annotation:
helm.sh/hook: pre-install, pre-upgrade
{{- end }} {{- end }}
{{- end }} {{- end }}

View File

@ -1,8 +1,7 @@
{{- $server := .Values.nfs.server | default "0.0.0.0" -}}
{{- $server := .Values.nfs.server -}}
{{- $path := .Values.nfs.path -}} {{- $path := .Values.nfs.path -}}
{{- if (include "nfs.existing-configmap-provided" .) -}} {{- if (include "nfs.existing-configmap-provided" .) -}}
{{- $server := (include "common.configmap.lookup" (dict "config" .Values.nfs.existingConfigMap.name "key" "server" "defaultValue" .Values.nfs.server "context" $)) -}} {{- $server := (include "common.configmap.lookup" (dict "config" .Values.nfs.existingConfigMap.name "key" "server" "0.0.0.0" .Values.nfs.server "context" $)) -}}
{{- $path := (include "common.configmap.lookup" (dict "config" .Values.nfs.existingConfigMap.name "key" "path" "defaultValue" .Values.nfs.path "context" $)) -}} {{- $path := (include "common.configmap.lookup" (dict "config" .Values.nfs.existingConfigMap.name "key" "path" "defaultValue" .Values.nfs.path "context" $)) -}}
{{- end -}} {{- end -}}

View File

@ -16,7 +16,7 @@ nfs:
reclaimPolicy: Retain reclaimPolicy: Retain
# existing configmap in order to get server and path # existing configmap in order to get server and path
existingConfigMap: existingConfigMap:
name: name: "oiadp-nfs-config"
namespace: default namespace: default
# For creating the StorageClass automatically: # For creating the StorageClass automatically: