Skip to content

Commit

Permalink
Merge pull request #4 from artis3n/patch-1
Browse files Browse the repository at this point in the history
feat: support conftest fmt command
  • Loading branch information
anderseknert authored Aug 14, 2021
2 parents d6214ee + abed773 commit 915d66f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
language: system
files: (\.rego|\.yml|\.yaml|\.json|\.ini|\.toml|\.conf|\.hcl|\.cue|\.edn|\.vcl|\.xml|\.jsonnet|Dockerfile)$

- id: conftest-fmt
name: Conftest fmt
description: Run `conftest fmt` on staged Rego files
entry: conftest fmt
language: system
args: ['.']
files: (\.rego)$

- id: conftest-verify
name: Conftest verify
description: Run `conftest verify` on rego files
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ Since it doesn't make sense to only provide `opa test` with the files changed (a
args: ['my/policies', 'my/other/policies/']
```

#### `conftest-fmt`
Runs `conftest fmt` on any Rego files in the repository.

Note that any files changed by this hook will need to be re-added (`git add`) to be included in the commit.

#### `conftest-test`
Runs `conftest test` on any configuration file format supported by conftest.

Expand All @@ -57,3 +62,11 @@ Just like with `opa-test` you'll likely want to specify the location of your con

#### `conftest-verify`
If rego files are present in commit, runs `conftest verify` in git root directory.

Just like with `conftest-test` you'll likely want to specify the location of your conftest policies, and possibly what type of files changed should trigger the hook:

```yaml
- id: conftest-verify
args: ['--policy', 'conftest/policy']
files: conftest/.*\.yaml$
```

0 comments on commit 915d66f

Please sign in to comment.