Coder Social home page Coder Social logo

jdolitsky / conftest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from open-policy-agent/conftest

0.0 1.0 0.0 3.25 MB

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

Home Page: https://conftest.dev

License: Other

Go 89.38% Dockerfile 0.99% Shell 9.19% Makefile 0.44%

conftest's Introduction

Conftest

CircleCI 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 #conftest channel.

conftest's People

Contributors

alonrolnik avatar anderseknert avatar arminbhy avatar blokje5 avatar boranx avatar carlpett avatar davewongillies avatar dependabot[bot] avatar foostan avatar garethr avatar jdorel avatar jimangel avatar johnkeates avatar jpreese avatar jremond avatar keisukeyamashita avatar kenfdev avatar menendezjaume avatar mnuthan1 avatar mrueg avatar proplex avatar salamandastron1 avatar sarcasticadmin avatar shteou avatar srenatus avatar sublimino avatar tsandall avatar v-ymarchanka avatar xchapter7x avatar zelinzky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.