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 (#5354)
## What this PR does
`default "true"` treats a bool false as empty, so an unquoted
`_cluster.ingress-enabled: false` or `_cluster.monitoring-enabled:
false` still rendered `_namespace.ingress: tenant-root` and the
monitoring ExternalName redirects. Both gates now check for a missing
key first and otherwise require `"true"` or a bool true, so a missing
key keeps the old behaviour, every string value keeps its old meaning,
and a bool false turns the feature off. #5097 does the same for the
seaweedfs flag.
helm-unittest 1.1.2, cozystack-basics 83 of 83. Against the templates on
main the two new bool-false cases fail.
### Downstream repositories
- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:
### Release note
```release-note
fix(platform): an unquoted false in _cluster.ingress-enabled or _cluster.monitoring-enabled now turns off the tenant-root ingress key and the monitoring redirects.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Ingress and monitoring redirects are no longer enabled when their
settings are explicitly `false` or empty. When settings are missing,
existing default behavior is preserved.
* **Tests**
* Added coverage for disabling ingress and monitoring redirects with
boolean `false`.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from: 18a9530b87
This commit is contained in:
commit
114df65045
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