Got git? Then you have a person who has inadvertently committed something that fails downstream in the CI (or worse). The solution? pre-commit hooks. The framework? pre-commit. its pretty fantastic, you createa a .pre-commit-hooks.yaml file in the root of your repo, select from a menu of validators etc, and, when you commit, it does a quick local check for you. Much faster, much better developer experience.
What I found missing was a simple way to validate Kubernetes YAML against the API. Tools like kubeval exist, but, they don’t cache the API, and, assume all input is Kubernetes, meaning you can’t have other YAML in the repo.
So, I present to you, a fast, caching, skip-non-kubernetes-yaml pre-commit hook. You are one block like this away from satistfaction.
- repo: https://github.com/Agilicus/pre-commit-hook-k8svalidate.git
rev: v0.0.6
hooks:
- id: k8svalidate
args: [--exclude, '**/*.patch.yaml']
files: .yaml$
Leave a Reply