feat: add spec.renderPatches support - #15
Merged
Merged
Conversation
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Both descriptions promised that render rules apply on these paths — chart-shipped ones and those from spec.renderPatches alike. They never do: the rollback and uninstall plans consume only diff rules, so a render rule silently has no effect there. nelm draws the same boundary in its own CLI, registering the patches flags for these two commands with NoRender. The text is served by kubectl explain, where users read it as the API contract. Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
The aliases claimed to keep Go importers of this package compiling, but the same rename also renamed the NoDefaultDiffPatches field to NoDefaultPatches, and Go has no way to alias a struct field. An importer the aliases were meant to serve would fail to build anyway, so the promise in their doc comment was never real. Nothing in the repository referenced either name. Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Both plans consume only diff rules — nelm compiles the render rules handed to them and then discards them, so a rule in spec.renderPatches silently did nothing there while still being able to fail the action outright. nelm draws the same boundary in its own CLI, registering the patches flags for these two commands with NoRender. patchesFiles now takes the two rule lists instead of the whole Release, matching the shape of writePatchesFile next to it, so each call site states which classes of rules that path actually consumes. The two tests that asserted the render rules were present are inverted, and a new pair asserts that a Release carrying only render rules produces no patches file at all for these paths. Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
spec.renderPatchesto the Release CRD: jq rules applied to the resourcesrendered from the chart, right after rendering.
Unlike the existing
spec.diffPatches— which only normalize the live and thedesired object before drift comparison and never change what is deployed —
render patches DO change what is stored in the release and applied to the
cluster. Rules run in declaration order, each one on the previous one's output.
Why
nelm already supports render rules in chart-shipped
patches.yaml. This exposesthe same capability declaratively on the Release CR, so a cluster-side override
no longer requires forking or re-templating the chart.
Breaking change
install.noDefaultDiffPatches,rollback.noDefaultDiffPatchesanduninstall.noDefaultDiffPatchesare renamed tonoDefaultPatches: the flag nowgoverns both the render and the diff rules shipped by a chart.
There is no compatibility shim. The API server silently prunes the old field, so
a Release still using
noDefaultDiffPatchesloses the setting and chart-shippedpatches start applying again, with no error and no warning. The operator has no
released version and no consumers yet, so no migration path is provided — update
your manifests when you pick this up.
Other changes
DiffPatch/DiffPatchMatcherare renamed toPatch/PatchMatcher,since the same shape now backs both fields. No aliases are kept.
github.com/werf/nelmis bumped tov1.28.1-0.20260824114051-191171c87ea1,the first version exposing
spec.PatchesFile.RenderPatches.Limits worth knowing
A render patch receives the whole raw resource object and must return exactly one
object. nelm fails the plan if a patch changes resource identity (apiVersion,
kind, name or namespace); resources cannot be added or removed. Chart-shipped
render rules run before
spec.renderPatches, whilespec.extraAnnotationsandspec.extraLabelsare applied after them and therefore take precedence.Testing
Unit tests cover mapping of
spec.renderPatchesandspec.diffPatchesinto thegenerated patches file, rule ordering, and the
noDefaultPatches→DefaultPatchesDisablemapping for all three configs. Render patches are onlypassed on the install and plan-install paths; rollback and uninstall receive
spec.diffPatchesonly, since nelm never applies render rules there.