Conftest

Conftest helps you write tests against structured configuration data. Using Conftest you can
write tests for your Kubernetes configuration, Tekton pipeline definitions, Terraform code,
Serverless configs or any other config files.
Conftest uses the Rego language from Open Policy Agent for writing
the assertions. You can read more about Rego in the Policy Language
section in the Open Policy Agent documentation.
Here's a quick example. Save the following as policy/deployment.rego:
package main
deny contains msg if {
input.kind == "Deployment"
not input.spec.template.spec.securityContext.runAsNonRoot
msg := "Containers must not run as root"
}
deny contains msg if {
input.kind == "Deployment"
not input.spec.selector.matchLabels.app
msg := "Containers must provide app label for pod selectors"
}