Skip to content

Commit 915d66f

Browse files
authored
Merge pull request #4 from artis3n/patch-1
feat: support conftest fmt command
2 parents d6214ee + abed773 commit 915d66f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

.pre-commit-hooks.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
language: system
3232
files: (\.rego|\.yml|\.yaml|\.json|\.ini|\.toml|\.conf|\.hcl|\.cue|\.edn|\.vcl|\.xml|\.jsonnet|Dockerfile)$
3333

34+
- id: conftest-fmt
35+
name: Conftest fmt
36+
description: Run `conftest fmt` on staged Rego files
37+
entry: conftest fmt
38+
language: system
39+
args: ['.']
40+
files: (\.rego)$
41+
3442
- id: conftest-verify
3543
name: Conftest verify
3644
description: Run `conftest verify` on rego files

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ Since it doesn't make sense to only provide `opa test` with the files changed (a
4444
args: ['my/policies', 'my/other/policies/']
4545
```
4646

47+
#### `conftest-fmt`
48+
Runs `conftest fmt` on any Rego files in the repository.
49+
50+
Note that any files changed by this hook will need to be re-added (`git add`) to be included in the commit.
51+
4752
#### `conftest-test`
4853
Runs `conftest test` on any configuration file format supported by conftest.
4954

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

5863
#### `conftest-verify`
5964
If rego files are present in commit, runs `conftest verify` in git root directory.
65+
66+
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:
67+
68+
```yaml
69+
- id: conftest-verify
70+
args: ['--policy', 'conftest/policy']
71+
files: conftest/.*\.yaml$
72+
```

0 commit comments

Comments
 (0)