mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-27 10:18:39 +00:00
[nats] Fixes for NATS App Helm chart, fix template issues with config.merge value ## What this PR does This PR fixes two critical bugs in the NATS application chart (`packages/apps/nats`) that prevented successful deployment when using user authentication with custom configuration: **Bug #1: YAML Parse Error with Empty config.merge** - When users were defined but `config.merge` was empty (`{}`), the Helm template would fail with YAML parse errors - Fixed by adding safe existence checks before accessing `.Values.config.merge` and preventing rendering of empty merge blocks **Bug #2: Incorrect Config Nesting** - When both `users` and `config.merge` were defined, custom NATS config values (e.g., `max_payload`, `max_connections`) were incorrectly nested as children of the `accounts` object instead of being placed at the root NATS configuration level - This caused NATS pods to crash with "Expected map entries for accounts" errors - Fixed by correcting the indentation from `nindent 12` to `nindent 10` in the template The related issue is #1354 ### Changes Made **File**: `packages/apps/nats/templates/nats.yaml` 1. Line 55: Added safe existence checks for `.Values.config.merge` 2. Line 66: Added length validation to prevent rendering empty merge objects 3. Line 67: Fixed indentation to ensure config values merge at root level ### Impact - Enables NATS deployments with user authentication and custom configuration - Fixes Stalwart mail server clustering scenarios that require NATS with authentication - Resolves HelmRelease failures in multi-tenant environments ### Testing Can be tested with: ```yaml apiVersion: apps.cozystack.io/v1alpha1 kind: NATS metadata: name: test-nats spec: replicas: 2 users: testuser: {} config: merge: max_payload: 2097152 max_connections: 500 ``` Expected result: HelmRelease succeeds, NATS pods start successfully, and configuration is valid. --- ### Release note ```release-note [nats] Fix NATS application chart template bugs that prevented deployments with user authentication and custom configuration. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced configuration validation with improved guard conditions to ensure proper handling of merge configurations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
How to test packages local
cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete po -l app=source-controller -n cozy-fluxcd