fix: wrap subchart values on save/unwrap on read for correct Helm deployment - #20
Conversation
- deployments.js POST: reads Chart.yaml dependency name and wraps values under it before writing to disk, so ArgoCD receives correct helm subchart values - deployments.js GET: unwraps subchart key before returning to frontend, preserving bare-key contract with the table editor UI - render.js: removes wrapValuesForSubchart() workaround; now runs helm template directly on the deployment directory so render behavior matches ArgoCD exactly - adds integration tests for wrap/unwrap round-trip Closes #19 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Preview environment torn down. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughA new ChangesSubchart Value Wrapping in Deployments API
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
rophy
left a comment
There was a problem hiding this comment.
alertCount in the list endpoint (deployments.js:40-44) and folder tree (folders.js:48-55) will always be 0 for wrapped values — both loops look for top-level arrays, but after wrapping the only top-level key is the dep name (an object).
Please fix the counting to unwrap first, and add a test that writes a wrapped values.yaml and asserts the correct alertCount.
|
Bug: No migration for existing bare values.yaml files The 3 existing |
|
Bug: Existing tests mask the alertCount regression
|
|
Cleanup: Extract shared The "read Chart.yaml, return first dependency name" logic now exists in |
…wrap Add server/lib/subchart.js with getDepName/wrapValues/unwrapValues/countAlerts so the wrap/unwrap/count logic lives in one place instead of being duplicated across deployments.js, folders.js and render.js. - deployments.js list endpoint now unwraps before counting, so alertCount is correct for subchart-wrapped values (previously always 0); GET/POST reuse the shared wrap/unwrap helpers. - folders.js tree count uses countAlerts (same unwrap fix), and POST /init now wraps the chart's default values under the dependency name so a freshly created deployment renders correctly without a UI re-save. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The three sample deployment values.yaml files were in bare-key format. Since render.js no longer wraps at template time, rendering them directly would feed the subchart no values. Wrap each under the mariadb-alerts dependency name to match what the backend now writes on save. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- subchart.test.js: unit tests for the shared helper (getDepName, wrap/unwrap round-trip, countAlerts on wrapped/legacy/empty values) - deployments-api / folders-tree: assert correct alertCount on wrapped values and keep backward-compat coverage for legacy bare-key files - folders-api: assert POST /init writes subchart-wrapped values - chartRendering: render the deployment through its parent chart (helm dependency build + template in a temp dir) instead of feeding wrapped values straight to the subchart, matching how render.js consumes them Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
While testing the new-deployment flow — clicking Create in the "New Deployment" dialog (the I'm wondering whether new deployments should start empty instead. As it stands, a user who creates a deployment and deploys it without editing ships 13 alerts targeting the One subtlety I confirmed while testing: simply writing an empty Before I touch this: is the pre-filled-defaults behavior intentional (e.g. a discoverable template the user edits down), or would you prefer empty deployments? Happy to implement the empty-start variant — it's the cc @rophy |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/unit/chartRendering.test.js`:
- Around line 141-142: Replace the two `execSync` calls with `execFileSync` to
avoid shell parsing of the Helm commands. For the first call executing helm
dependency build, change from using execSync with a template literal string to
execFileSync with the command 'helm' and an array argument containing
['dependency', 'build', deployDir]. For the second call executing helm template,
similarly change to execFileSync with command 'helm' and array argument
containing ['template', 'prod-release', deployDir]. This prevents shell
expansion and makes the paths safer when they contain special characters.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 67bb10fd-4dc5-42af-a142-3e84ed6e0deb
📒 Files selected for processing (11)
sample/deployments/mariadb-1/production/values.yamlsample/deployments/mariadb-1/staging/values.yamlsample/deployments/mariadb-2/production/values.yamlserver/lib/subchart.jsserver/routes/deployments.jsserver/routes/folders.jstests/integration/deployments-api.test.jstests/integration/folders-api.test.jstests/integration/folders-tree.test.jstests/unit/chartRendering.test.jstests/unit/subchart.test.js
✅ Files skipped from review due to trivial changes (1)
- sample/deployments/mariadb-2/production/values.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
- server/routes/deployments.js
Avoid shell parsing of interpolated paths by passing helm arguments as an array (execFileSync) instead of interpolating into a shell command string. Addresses CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rophy
left a comment
There was a problem hiding this comment.
LGTM. All prior review comments addressed — alertCount unwrapping, deployment creation wrapping, and execFileSync migration all landed in follow-up commits. Good test coverage across unit and integration layers.
|
Good catch — let's start empty. Tracked as #23, no need to address in this PR. |
Summary
deployments.jsPOST now wraps values under the Chart.yaml dependency name before writing to disk, so any Helm invocation (ArgoCD, Flux, directhelm install) receives correct subchart valuesdeployments.jsGET now unwraps the subchart key before returning to the frontend, preserving the bare-key contract with the table editor UIrender.jsremoves thewrapValuesForSubchart()workaround and runshelm templatedirectly on the deployment directory, making render behavior consistent with any Helm invocationRoot Cause
The frontend intentionally uses bare keys for the table editor. The backend was supposed to act as the translation layer between bare keys and Helm subchart wrap format, but the wrap was never implemented on save. A temporary
wrapValuesForSubchart()workaround inrender.jsmasked the issue — preview looked correct while any direct Helm deployment silently used default values.This is a Helm subchart values issue, not specific to ArgoCD. The same problem would affect Flux,
helm install, or any other tool that consumesvalues.yamldirectly.Test plan
tests/integration/deployments-api.test.js— 5 new tests covering POST wrap, GET unwrap, backward compatibility, and round-trip consistencyCloses #19
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Refactor
values.yamlformats.Tests