Files
cozystack/packages
Aleksei Sviridkin 301a7fed27 fix(nats): merge config.merge.accounts with the generated accounts map (#4134)
## What this PR does

Fixes #4084.

With `users` set, `templates/nats.yaml` rendered
`config.merge.accounts.A.users` from the generated passwords and then
appended `.Values.config.merge` verbatim. A tenant `config.merge` that
also carried `accounts`, which is the only place to set
`accounts.A.jetstream` for the generated account, produced the key twice
in the HelmRelease values, and the install failed at post-render with
`mapping key "accounts" already defined`.

The template now builds a single `merge` map: a deep copy of
`.Values.config.merge` with the generated users merged in under
`accounts.A.users` via `mergeOverwrite`. The generated user list wins
for account `A`; other keys under `accounts.A`, other accounts and
top-level keys such as `max_payload` are kept; a `config.merge` without
`users` passes through unchanged; and no `merge` block is rendered when
neither is set. The values contract does not change.

`helm unittest`: 67/67 in the chart. The new
`tests/config_merge_test.yaml` covers the six shapes above; against the
previous template the same suite fails on the three cases that combine
`users` with `config.merge.accounts`.

### Downstream repositories

Template and tests only: no values, schema, README or defaults change.

- [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(nats): merge config.merge.accounts with the generated accounts instead of rendering the key twice
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved NATS configuration merging so generated user credentials and
custom account settings are combined consistently.
- Preserved tenant-listed users, additional accounts, and top-level
configuration during merges.
- Prevented empty merge sections from being rendered when no users or
custom merge settings are configured.

- **Tests**
- Added coverage for user generation, account merging, configuration
preservation, and empty-configuration scenarios.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-18 13:44:15 +04:00
..