Files
instance-template-v3/templates/_helpers.tpl
OdooSky v3 4a8dc61a92 feat(chart): rip out pg dual-mode shim — ESO-only (0.1.8)
A-Chunk 3 finalisation. All live instances are migrated to ESO,
and Tower 0.77.2 makes the migrate + template-deploy paths also
emit ESO-shape overlays (wizard always has). The
`{{- if not .Values.postgres.passwordVaultPath }}` shim in
postgres-secret.yaml has zero remaining production callers.

Changes:
  - DELETE templates/postgres-secret.yaml (dual-mode legacy path)
  - DELETE _helpers.tpl `instance.pgPassword` (only consumed by
    postgres-secret.yaml; no other callers)
  - UNWRAP templates/postgres-password-externalsecret.yaml — the
    outer `{{- if .Values.postgres.passwordVaultPath }}` conditional
    is removed; the template now renders unconditionally and the
    chart's `required` directive on tenant.id is the new boundary
    (chart render fails loud if Tower forgot to populate it)
  - SIMPLIFY values.yaml — drop the legacy `postgres.password` field
    and the dual-mode documentation. `passwordVaultPath` stays as an
    operator-visible advisory string but the chart hardcodes the
    path shape from tenant.id + instance.code

Chart 0.1.7 → 0.1.8. helm template + helm lint verified locally;
helm template with tenant.id missing fails loud with a clear
error pointing the operator at the chart line + the source of the
missing value.

The live instances (erp/erp18v3/v19) carry tenant.id + passwordVaultPath
in their overlays already; this chart version produces the same
manifests for them on next ArgoCD reconcile — no observable change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 13:56:40 +03:00

92 lines
3.8 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: {{ include "instance.odooTag" . | quote }}
odoosky.io/component: instance
{{- end -}}
{{/*
Resolved Odoo image tag.
If `.Values.odoo.tag` matches a key in `.Values.odoo.pinnedTags`, the
chart treats `odoo.tag` as a MAJOR reference (e.g. "18.0") and resolves
it to the pinned date-stamped nightly the platform has tested
(e.g. "18.0-20260421"). Otherwise it's used verbatim that's the
escape hatch for per-instance overrides during testing.
This is what closes the GitOps loop: per-instance overlays carry
`odoo.tag: "18.0"` (a major), the chart resolves to the exact pinned
nightly. Bumping the platform's pinned image becomes a one-line edit
to `pinnedTags` in values.yaml, propagated to every instance on next
pod restart without touching any per-instance overlay.
Source of truth for which nightly each major maps to:
https://git.odoosky.org/odoo-tower/odoosky-odoo (versions.yaml)
The `pinnedTags` map in values.yaml MUST stay in sync with that file.
*/}}
{{- define "instance.odooTag" -}}
{{- $tag := .Values.odoo.tag -}}
{{- $resolved := index .Values.odoo.pinnedTags $tag -}}
{{- if $resolved }}{{ $resolved }}{{ else }}{{ $tag }}{{ end -}}
{{- end -}}
{{/*
Resolved full Odoo image reference (registry mirror + image + resolved
tag). Used by every Odoo container + initContainer in the chart so a
single edit to `pinnedTags` sweeps through every spot.
*/}}
{{- define "instance.odooImage" -}}
{{- $tag := include "instance.odooTag" . -}}
{{- if .Values.imageMirror.registry -}}
{{ .Values.imageMirror.registry }}/{{ .Values.odoo.image }}:{{ $tag }}
{{- else -}}
{{ .Values.odoo.image }}:{{ $tag }}
{{- end -}}
{{- 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 -}}
{{/*
Storage size for a given layer (`filestore` | `database`). Resolution
order, most-specific first:
1. instance.{layer}Storage in the tenant overlay (operator override)
2. sizes[size].storage.{layer} (per-tier default)
3. legacy chart-level fallback (.Values.odoo.filestoreSize / .Values.postgres.storage)
This lets operators decouple storage from CPU/RAM tiers a Small
instance with lots of attachments can have 50 GB filestore without
upgrading to Medium for capacity it doesn't need.
*/}}
{{- define "instance.storage" -}}
{{- $size := .Values.instance.size | default "small" -}}
{{- $tier := index .Values.sizes $size | default (index .Values.sizes "small") -}}
{{- if eq .layer "filestore" -}}
{{- if .Values.instance.filestoreStorage -}}{{ .Values.instance.filestoreStorage }}{{- else if and $tier.storage $tier.storage.filestore -}}{{ $tier.storage.filestore }}{{- else -}}{{ .Values.odoo.filestoreSize | default "10Gi" }}{{- end -}}
{{- else if eq .layer "database" -}}
{{- if .Values.instance.dbStorage -}}{{ .Values.instance.dbStorage }}{{- else if and $tier.storage $tier.storage.database -}}{{ $tier.storage.database }}{{- else -}}{{ .Values.postgres.storage | default "10Gi" }}{{- end -}}
{{- end -}}
{{- end -}}