mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
fix(platform): honour a bool false in ingress-enabled and monitoring-enabled
Helm's default treats a bool false as empty, so an unquoted false in either _cluster flag still rendered _namespace.ingress and the monitoring redirects. Check for a missing key first and require "true" or a bool true otherwise. Assisted-by: LLM Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
This commit is contained in:
1 parent
d88322197f
commit
a314dacb86
4 files changed
+27
-7
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:'
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user