For running pre-commit hooks for kyverno.
There are two hooks available:
kyverno-validate
kyverno-test
Kyverno CLI must be installed
create .pre-commit-config.yaml at the root of repo
repos:
- repo: https://github.com/kyverno/pre-commit-hook
rev: v1.0.0
hooks:
- id: kyverno-test
args: ["kyverno-policies"]
- id: kyverno-validate
args: ["kyverno-policies"]
Note: the args for each hook should be the directory where your kyverno policies are stored
then run:
pre-commit install
pre-commit run --all-files
Further configuration of pre-commit (to only run on push, for example) see the Pre-commit Documentation