Skip to content

Write tests against structured configuration data using the Open Policy Agent Rego query language

License

Notifications You must be signed in to change notification settings

amber-beasley-liatrio/conftest

This branch is 2 commits ahead of, 102 commits behind open-policy-agent/conftest:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

713a11a · Apr 12, 2024
Mar 31, 2024
Oct 19, 2023
Dec 13, 2023
Sep 23, 2020
Apr 12, 2024
Feb 21, 2024
Oct 19, 2023
Feb 27, 2024
Oct 20, 2023
Oct 1, 2023
Feb 10, 2024
Mar 31, 2024
Jan 3, 2024
Mar 9, 2023
Mar 31, 2024
Apr 16, 2021
Jan 15, 2024
Sep 1, 2023
Jan 13, 2024
Apr 15, 2021
Jan 10, 2023
Dec 29, 2021
Apr 11, 2024
Apr 1, 2019
Mar 24, 2023
Nov 13, 2021
Jan 29, 2022
Oct 19, 2023
Apr 4, 2024
Apr 4, 2024
May 15, 2020
Jul 16, 2020
Apr 6, 2022
Nov 27, 2022

Repository files navigation

Conftest

Go Report Card Netlify

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 How do I write policies in the Open Policy Agent documentation.

Here's a quick example. Save the following as policy/deployment.rego:

package main

deny[msg] {
  input.kind == "Deployment"
  not input.spec.template.spec.securityContext.runAsNonRoot

  msg := "Containers must not run as root"
}

deny[msg] {
  input.kind == "Deployment"
  not input.spec.selector.matchLabels.app

  msg := "Containers must provide app label for pod selectors"
}

Assuming you have a Kubernetes deployment in deployment.yaml you can run Conftest like so:

$ conftest test deployment.yaml
FAIL - deployment.yaml - Containers must not run as root
FAIL - deployment.yaml - Containers must provide app label for pod selectors

2 tests, 0 passed, 0 warnings, 2 failures, 0 exceptions

Conftest isn't specific to Kubernetes. It will happily let you write tests for any configuration files in a variety of different formats. See the documentation for installation instructions and more details about the features.

Want to contribute to Conftest?

For discussions and questions join us on the Open Policy Agent Slack in the #opa-conftest channel.

About

Write tests against structured configuration data using the Open Policy Agent Rego query language

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 85.7%
  • Shell 11.9%
  • Other 2.4%