1 {{/* vim: set filetype=mustache: */}}
3 Validate PostgreSQL required passwords are not empty.
6 {{ include "common.validations.values.postgresql.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
8 - secret - String - Required. Name of the secret where postgresql values are stored, e.g: "postgresql-passwords-secret"
9 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
11 {{- define "common.validations.values.postgresql.passwords" -}}
12 {{- $existingSecret := include "common.postgresql.values.existingSecret" . -}}
13 {{- $enabled := include "common.postgresql.values.enabled" . -}}
14 {{- $valueKeyPostgresqlPassword := include "common.postgresql.values.key.postgressPassword" . -}}
15 {{- $valueKeyPostgresqlReplicationEnabled := include "common.postgresql.values.key.replicationPassword" . -}}
16 {{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") -}}
17 {{- $requiredPasswords := list -}}
18 {{- $requiredPostgresqlPassword := dict "valueKey" $valueKeyPostgresqlPassword "secret" .secret "field" "postgresql-password" -}}
19 {{- $requiredPasswords = append $requiredPasswords $requiredPostgresqlPassword -}}
21 {{- $enabledReplication := include "common.postgresql.values.enabled.replication" . -}}
22 {{- if (eq $enabledReplication "true") -}}
23 {{- $requiredPostgresqlReplicationPassword := dict "valueKey" $valueKeyPostgresqlReplicationEnabled "secret" .secret "field" "postgresql-replication-password" -}}
24 {{- $requiredPasswords = append $requiredPasswords $requiredPostgresqlReplicationPassword -}}
27 {{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
32 Auxiliary function to decide whether evaluate global values.
35 {{ include "common.postgresql.values.use.global" (dict "key" "key-of-global" "context" $) }}
37 - key - String - Required. Field to be evaluated within global, e.g: "existingSecret"
39 {{- define "common.postgresql.values.use.global" -}}
40 {{- if .context.Values.global -}}
41 {{- if .context.Values.global.postgresql -}}
42 {{- index .context.Values.global.postgresql .key | quote -}}
48 Auxiliary function to get the right value for existingSecret.
51 {{ include "common.postgresql.values.existingSecret" (dict "context" $) }}
53 {{- define "common.postgresql.values.existingSecret" -}}
54 {{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "existingSecret" "context" .context) -}}
57 {{- default (.context.Values.postgresql.existingSecret | quote) $globalValue -}}
59 {{- default (.context.Values.existingSecret | quote) $globalValue -}}
64 Auxiliary function to get the right value for enabled postgresql.
67 {{ include "common.postgresql.values.enabled" (dict "context" $) }}
69 {{- define "common.postgresql.values.enabled" -}}
71 {{- printf "%v" .context.Values.postgresql.enabled -}}
73 {{- printf "%v" (not .context.Values.enabled) -}}
78 Auxiliary function to get the right value for the key postgressPassword.
81 {{ include "common.postgresql.values.key.postgressPassword" (dict "subchart" "true" "context" $) }}
83 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
85 {{- define "common.postgresql.values.key.postgressPassword" -}}
86 {{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "postgresqlUsername" "context" .context) -}}
88 {{- if not $globalValue -}}
90 postgresql.postgresqlPassword
95 global.postgresql.postgresqlPassword
100 Auxiliary function to get the right value for enabled.replication.
103 {{ include "common.postgresql.values.enabled.replication" (dict "subchart" "true" "context" $) }}
105 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
107 {{- define "common.postgresql.values.enabled.replication" -}}
109 {{- printf "%v" .context.Values.postgresql.replication.enabled -}}
111 {{- printf "%v" .context.Values.replication.enabled -}}
116 Auxiliary function to get the right value for the key replication.password.
119 {{ include "common.postgresql.values.key.replicationPassword" (dict "subchart" "true" "context" $) }}
121 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
123 {{- define "common.postgresql.values.key.replicationPassword" -}}
125 postgresql.replication.password