mani-diffy

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

mani-diffy

Tests

This program walks a hierarchy of Argo CD Application templates, renders Kubernetes manifests from the input templates, and posts the rendered files back for the user to review and validate.

It is designed to be called from a CI job within a pull request, enabling the author to update templates and see the resulting manifests directly within the pull request before the changes are applied to the Kubernetes cluster.

The rendered manifests are kept within the repository, making diffs between revisions easy to parse, dramatically improving safety when updating complex application templates.


How it works:

  1. A user makes their desired change to the application's templates (charts, overrides, etc) and submits a PR with the change.
  2. A Github action executes mani-diffy, rendering all manifests affected by the change.
  3. Any updated manifests are submitted back to the same PR as a new commit.
  4. The author and any reviewers will be able to review the diff between the new changes and the previous version of the manifests.

See it in action

🫵 Submit a PR where you make a change to the overrides of the demo, and you'll see the Github action add a commit to your PR with the resulting changes.

1 2

See it in action in a video !

In this screen recording a pull request is opened to make the following changes to the demo:

  1. Bump the count of pods for the foo service in the prod cluster
  2. Add an annotation to all services

https://github.com/chime/mani-diffy/assets/9005904/6c496996-f7af-4932-bf5d-01a5b57bbd99

Output

By default, mani-diffy prints a summary of what it did: how many applications it rendered, how many of those it rendered twice to mask random values, and how many were unchanged since the last run. While rendering, it shows the progress of every root on a terminal, updating in place, or prints a line for each root as it finishes otherwise. With -v, it prints the progress of every application, and Helm's warnings, instead.

Colors are used on a terminal. Otherwise, they're only used with CLICOLOR_FORCE=1, for logs that show colors, like those of GitHub Actions:

- run: mani-diffy
  env:
    CLICOLOR_FORCE: "1"

Config file

Instead of flags, the roots to render and their settings can be listed in .mani-diffy.yaml in the working directory, or in the file given by -config. With several roots, the applications of all of them are rendered by the same workers:

hashStore: json
ignoreSuffix: -console
skipRenderKey: appTag
ignoreValueFile: overrides/apptags
maskRandomValues: true
roots:
  - name: use1-stable
    root: bootstrap/child-applications/us-east-1/stable
    output: zz.auto-generated/root-use1-stable
  - name: use1-prod
    root: bootstrap/child-applications/us-east-1/prod
    output: zz.auto-generated/root-use1-prod

Flags override the config file's settings: -hash-store, -ignore-suffix, -skip-render-key, -ignore-value-file, and -mask-random-values replace the setting of the same name, and -root or -output render only that root instead of the config file's roots.

To render only some of the roots, name them with -only:

mani-diffy -only use1-stable,use1-prod

-list-roots prints the names of the roots that would be rendered, one per line, for example for shell completion.

Post Renderers

mani-diffy also supports something called a "post renderer". This is a command that will be called immediately after an Application is rendered. This can be used to run linting, or alter the output of the generated manifest.

mani-diffy -post-renderer="bin/post-render" -output=.zz-auto-generated

The command will be called with the output directory as the first argument (e.g. .zz-auto-generated/<application name>)

Random values

Charts that generate certificates, passwords, or other random values render a different manifest every time. With -mask-random-values, mani-diffy renders twice each chart that calls a random function, and replaces the values that differ between the two renders with CONSCIOUSLY_NOT_RENDERED, so the rendered manifests only change when the templates do:

mani-diffy -mask-random-values -output=.zz-auto-generated

Values derived from random ones, like checksums of templates that generate certificates, are masked too. The rest of the manifest is left as rendered, and the masked fields of each application are logged.

A chart is rendered twice when a template action in its files, or in its values for charts that render them with tpl, calls one of randAlphaNum, randAlpha, randAscii, randNumeric, randBytes, randInt, shuffle, uuidv4, now, ago, genPrivateKey, genCA, genCAWithKey, genSelfSignedCert, genSelfSignedCertWithKey, genSignedCert, genSignedCertWithKey, bcrypt, htpasswd, or encryptAES. Values that change slower than two renders, like now | date "2006-01-02", are not masked.


Pre-requisites

This is for a new user that is looking to use mani-diffy on a new repo.

In order to make use of mani-diffy on the repo that holds all of your ArgoCD applications the pre-requisites are:

  • You have a "root" Application
  • All of your charts and Application manifests live in the same repo.

mani-diffy itself makes no assumptions about how the repo is structured, as long as it can successfully render the charts it encounters while walking the Application tree.

However, you may find it useful to organize your repo similarly to the demo app, with 3 key directories :

  1. a "root" or "bootstrap" directory that holds all the ArgoCD applications manifests.
  2. a "charts" directory that contains all the helm charts needed for the ArgoCD applications.
  3. a "rendered" or "generated" directory, where all rendered charts will be committed.

You can see an example of that in the demo directory.

FAQ

Q: Is ArgoCD using the rendered manifests in .zz.auto-generated ?

A: No, ArgoCD renders the charts itself. There is no expected discrepancy between the manifest files rendered by mani-diffy and by ArgoCD as long as they are using the same version of Helm.

Q: Which version of Helm does mani-diffy use?

A: mani-diffy renders charts with the Helm library it is built with: the helm.sh/helm/v4 version in go.mod, not the helm binary on your PATH.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
randomvalues
Package randomvalues replaces the values in a manifest that charts fill with a different value on every render, such as generated certificates, with a placeholder, so that re-rendering an unchanged chart gives the same manifest.
Package randomvalues replaces the values in a manifest that charts fill with a different value on every render, such as generated certificates, with a placeholder, so that re-rendering an unchanged chart gives the same manifest.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址