Kubeconform flux files
What
When writing flux config, it's possible that your IDE has no idea about the schema (Looking at you intelliJ) as such, you may land up committing some real garbage
This all assumes you're using kustomizations.yaml
to wrap up flux files. If that's not the case, see native files
GitHub action
I have written a GitHub action to do this
Tools required
- cURL
- kustomize
- kubeconform
How
Download the schemas and un-package them
curl -sL https://github.com/fluxcd/flux2/releases/latest/download/crd-schemas.tar.gz | tar zxf - -C /tmp/flux-crd-schemas/master-standalone-strict
why master-standalone-strict?
I am not sure, but when running kubeconform
in verbose mode, it looks for /tmp/flux-crd-schemas/master-standalone-strict/*.json
➜ cat gotk-sync.yaml| kubeconform "-strict" "-schema-location" "/tmp/flux-crd-schemas" "-summary" "-verbose" "-output" "pretty" "-exit-on-error" "-debug"
2024/03/23 12:16:45 using schema found at /tmp/flux-crd-schemas/master-standalone-strict/gitrepository-source-v1.json
✔ stdin: GitRepository flux-system is valid
2024/03/23 12:16:45 using schema found at /tmp/flux-crd-schemas/master-standalone-strict/kustomization-kustomize-v1.json
✔ stdin: Kustomization flux-system is valid
Summary: 2 resources found parsing stdin - Valid: 2, Invalid: 0, Errors: 0, Skipped: 0
Kustomize build and validate
The below will not fail if it finds schemas it doesn't recognise
Native files
If you are not using kustomizations to bundle files, you can use the below
The below will not fail if it finds schemas it doesn't recognise
Want to make this site better? Open a PR or help fund hosting costs