3 SPDX-License-Identifier: APACHE-2.0
6 {{/* vim: set filetype=mustache: */}}
8 Validate PostgreSQL required passwords are not empty.
11 {{ include "common.validations.values.postgresql.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
13 - secret - String - Required. Name of the secret where postgresql values are stored, e.g: "postgresql-passwords-secret"
14 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
16 {{- define "common.validations.values.postgresql.passwords" -}}
17 {{- $existingSecret := include "common.postgresql.values.existingSecret" . -}}
18 {{- $enabled := include "common.postgresql.values.enabled" . -}}
19 {{- $valueKeyPostgresqlPassword := include "common.postgresql.values.key.postgressPassword" . -}}
20 {{- $valueKeyPostgresqlReplicationEnabled := include "common.postgresql.values.key.replicationPassword" . -}}
21 {{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") -}}
22 {{- $requiredPasswords := list -}}
23 {{- $requiredPostgresqlPassword := dict "valueKey" $valueKeyPostgresqlPassword "secret" .secret "field" "postgresql-password" -}}
24 {{- $requiredPasswords = append $requiredPasswords $requiredPostgresqlPassword -}}
26 {{- $enabledReplication := include "common.postgresql.values.enabled.replication" . -}}
27 {{- if (eq $enabledReplication "true") -}}
28 {{- $requiredPostgresqlReplicationPassword := dict "valueKey" $valueKeyPostgresqlReplicationEnabled "secret" .secret "field" "postgresql-replication-password" -}}
29 {{- $requiredPasswords = append $requiredPasswords $requiredPostgresqlReplicationPassword -}}
32 {{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
37 Auxiliary function to decide whether evaluate global values.
40 {{ include "common.postgresql.values.use.global" (dict "key" "key-of-global" "context" $) }}
42 - key - String - Required. Field to be evaluated within global, e.g: "existingSecret"
44 {{- define "common.postgresql.values.use.global" -}}
45 {{- if .context.Values.global -}}
46 {{- if .context.Values.global.postgresql -}}
47 {{- index .context.Values.global.postgresql .key | quote -}}
53 Auxiliary function to get the right value for existingSecret.
56 {{ include "common.postgresql.values.existingSecret" (dict "context" $) }}
58 {{- define "common.postgresql.values.existingSecret" -}}
59 {{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "existingSecret" "context" .context) -}}
62 {{- default (.context.Values.postgresql.existingSecret | quote) $globalValue -}}
64 {{- default (.context.Values.existingSecret | quote) $globalValue -}}
69 Auxiliary function to get the right value for enabled postgresql.
72 {{ include "common.postgresql.values.enabled" (dict "context" $) }}
74 {{- define "common.postgresql.values.enabled" -}}
76 {{- printf "%v" .context.Values.postgresql.enabled -}}
78 {{- printf "%v" (not .context.Values.enabled) -}}
83 Auxiliary function to get the right value for the key postgressPassword.
86 {{ include "common.postgresql.values.key.postgressPassword" (dict "subchart" "true" "context" $) }}
88 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
90 {{- define "common.postgresql.values.key.postgressPassword" -}}
91 {{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "postgresqlUsername" "context" .context) -}}
93 {{- if not $globalValue -}}
95 postgresql.postgresqlPassword
100 global.postgresql.postgresqlPassword
105 Auxiliary function to get the right value for enabled.replication.
108 {{ include "common.postgresql.values.enabled.replication" (dict "subchart" "true" "context" $) }}
110 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
112 {{- define "common.postgresql.values.enabled.replication" -}}
114 {{- printf "%v" .context.Values.postgresql.replication.enabled -}}
116 {{- printf "%v" .context.Values.replication.enabled -}}
121 Auxiliary function to get the right value for the key replication.password.
124 {{ include "common.postgresql.values.key.replicationPassword" (dict "subchart" "true" "context" $) }}
126 - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
128 {{- define "common.postgresql.values.key.replicationPassword" -}}
130 postgresql.replication.password