diff --git a/packages/system/cozystack-basics/templates/cozystack-values-secret.yaml b/packages/system/cozystack-basics/templates/cozystack-values-secret.yaml index 72f24e1f9..5c61a3942 100644 --- a/packages/system/cozystack-basics/templates/cozystack-values-secret.yaml +++ b/packages/system/cozystack-basics/templates/cozystack-values-secret.yaml @@ -19,7 +19,8 @@ stringData: ingress-nginx-system in tenant-root, so the key stays empty, as it does for a sub-tenant with no ingress anywhere above it. A missing key keeps tenant-root for Secrets written before it. */ -}} - {{- if eq (toString (index .Values._cluster "ingress-enabled" | default "true")) "true" }} + {{- $ingress := index .Values._cluster "ingress-enabled" }} + {{- if or (kindIs "invalid" $ingress) (eq (toString $ingress) "true") }} ingress: tenant-root {{- end }} {{- /* `gateway` is conditional, the other four `_namespace` keys are diff --git a/packages/system/cozystack-basics/templates/monitoring-external-services.yaml b/packages/system/cozystack-basics/templates/monitoring-external-services.yaml index dcf77c40b..ef06d5908 100644 --- a/packages/system/cozystack-basics/templates/monitoring-external-services.yaml +++ b/packages/system/cozystack-basics/templates/monitoring-external-services.yaml @@ -19,11 +19,13 @@ in sync with Tenant/root spec.monitoring; flipping monitoring.rootEnabled is what refreshes these redirects. - `default dict` guards a null/absent _cluster (missing Secret / dry-run); the - "true" default preserves the historical always-create behaviour for - cozystack-values Secrets written before this key existed. + `default dict` guards a null/absent _cluster (missing Secret / dry-run), and + a missing key keeps the historical always-create behaviour for + cozystack-values Secrets written before this key existed. The key is + checked before `toString`, so a bool false is not taken for a missing one. */ -}} -{{- if eq (toString (index (.Values._cluster | default dict) "monitoring-enabled" | default "true")) "true" }} +{{- $monitoring := index (.Values._cluster | default dict) "monitoring-enabled" }} +{{- if or (kindIs "invalid" $monitoring) (eq (toString $monitoring) "true") }} --- apiVersion: v1 kind: Service diff --git a/packages/system/cozystack-basics/tests/cozystack-values-secret_test.yaml b/packages/system/cozystack-basics/tests/cozystack-values-secret_test.yaml index 33db1dcd5..294049fcc 100644 --- a/packages/system/cozystack-basics/tests/cozystack-values-secret_test.yaml +++ b/packages/system/cozystack-basics/tests/cozystack-values-secret_test.yaml @@ -134,3 +134,12 @@ tests: - matchRegex: path: stringData["values.yaml"] pattern: '(?m)^\s+seaweedfs: tenant-root$' + + - it: omits _namespace.ingress when _cluster.ingress-enabled is a bool false + set: + _cluster: + ingress-enabled: false + asserts: + - notMatchRegex: + path: stringData["values.yaml"] + pattern: '(?m)^\s+ingress:' diff --git a/packages/system/cozystack-basics/tests/monitoring-external-services_test.yaml b/packages/system/cozystack-basics/tests/monitoring-external-services_test.yaml index ec961de31..93e9bbe85 100644 --- a/packages/system/cozystack-basics/tests/monitoring-external-services_test.yaml +++ b/packages/system/cozystack-basics/tests/monitoring-external-services_test.yaml @@ -57,9 +57,17 @@ tests: - hasDocuments: count: 0 + - it: omits all redirects when monitoring-enabled is a bool false + set: + _cluster: + monitoring-enabled: false + asserts: + - hasDocuments: + count: 0 + # Guard: a null _cluster (missing cozystack-values Secret / dry-run) must not - # panic the render; `index (.Values._cluster | default dict) ...` falls back - # to the "true" default and keeps the redirects. + # panic the render; `index (.Values._cluster | default dict) ...` finds no + # key and keeps the redirects. - it: keeps the redirects (no panic) when _cluster is null set: _cluster: null