Skip to content

feat: add spec.renderPatches support - #15

Merged
dmmordvi merged 5 commits into
mainfrom
feat/render-patches
Aug 26, 2026
Merged

dmmordvi merged 5 commits into
mainfrom
feat/render-patches

Conversation

@dmmordvi

@dmmordvi dmmordvi commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds spec.renderPatches to the Release CRD: jq rules applied to the resources
rendered from the chart, right after rendering.

Unlike the existing spec.diffPatches — which only normalize the live and the
desired 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.

spec:
  renderPatches:
  - match:
      kinds: [Deployment]
      names: ["/web-.*/"]
    patch: |
      .spec.template.spec.priorityClassName = "production-high"

Why

nelm already supports render rules in chart-shipped patches.yaml. This exposes
the 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.noDefaultDiffPatches and
uninstall.noDefaultDiffPatches are renamed to noDefaultPatches: the flag now
governs 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 noDefaultDiffPatches loses the setting and chart-shipped
patches 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

  • Go types DiffPatch/DiffPatchMatcher are renamed to Patch/PatchMatcher,
    since the same shape now backs both fields. No aliases are kept.
  • github.com/werf/nelm is bumped to v1.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, while spec.extraAnnotations and
spec.extraLabels are applied after them and therefore take precedence.

Testing

Unit tests cover mapping of spec.renderPatches and spec.diffPatches into the
generated patches file, rule ordering, and the noDefaultPatches →
DefaultPatchesDisable mapping for all three configs. Render patches are only
passed on the install and plan-install paths; rollback and uninstall receive
spec.diffPatches only, since nelm never applies render rules there.

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>
@dmmordvi
dmmordvi merged commit a194dd9 into main Aug 26, 2026
5 of 7 checks passed
@dmmordvi
dmmordvi deleted the feat/render-patches branch August 26, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant