49 lines
1.7 KiB
Smarty
49 lines
1.7 KiB
Smarty
{{/*
|
|
Per-instance fully-qualified name. Used as the prefix for every K8s
|
|
object in the chart so instances in the same namespace can't collide.
|
|
*/}}
|
|
{{- define "instance.fullname" -}}
|
|
{{- .Values.instance.code | trunc 40 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Standard labels applied to every K8s object. Keeps `kubectl get -l`
|
|
queries by-instance trivial.
|
|
*/}}
|
|
{{- define "instance.labels" -}}
|
|
app.kubernetes.io/name: odoo
|
|
app.kubernetes.io/instance: {{ .Values.instance.code | quote }}
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
app.kubernetes.io/version: {{ .Values.odoo.tag | quote }}
|
|
odoosky.io/component: instance
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Resources for a given role (`odoo` | `postgres`), looked up against
|
|
the `sizes` table by `instance.size`. Falls back to "small" if the
|
|
operator picked a name that doesn't exist (defensive: a typo
|
|
shouldn't blow up the rendered chart).
|
|
*/}}
|
|
{{- define "instance.resources" -}}
|
|
{{- $size := .Values.instance.size | default "small" -}}
|
|
{{- $cfg := index .Values.sizes $size | default (index .Values.sizes "small") -}}
|
|
{{- toYaml (index $cfg .role) -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Postgres password. Looks up the existing Secret on upgrades; uses
|
|
.Values.postgres.password if set; otherwise generates a 32-char
|
|
random string on first install. The lookup ensures `helm upgrade`
|
|
does NOT silently rotate the password.
|
|
*/}}
|
|
{{- define "instance.pgPassword" -}}
|
|
{{- $existing := lookup "v1" "Secret" .Release.Namespace (printf "%s-pg" .Values.instance.code) -}}
|
|
{{- if and $existing $existing.data $existing.data.POSTGRES_PASSWORD -}}
|
|
{{- index $existing.data "POSTGRES_PASSWORD" | b64dec -}}
|
|
{{- else if .Values.postgres.password -}}
|
|
{{- .Values.postgres.password -}}
|
|
{{- else -}}
|
|
{{- randAlphaNum 32 -}}
|
|
{{- end -}}
|
|
{{- end -}}
|