anderseknert / pre-commit-opa

Pre-commit git hooks for Open Policy Agent (OPA) and Rego development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Opa check seems to run only against stages rego files

ryuheechul opened this issue · comments

Describe the bug

opa-check fails with pre commit hook however, running opa check . manually works.

My situation

  • a.rego is already committed.
  • b.rego is staged and it imports a.rego
  • opa-check fails when I try to commit

My speculation
I'm relatively new to pre-commit however I have a feeling that opa check via opa-check is running only against the staged files, which means opa check b.rego and it will fail because it doesn't include a.rego which is necessary.

Either opa check a.rego b.rego or opa check *.rego or opa check . should succeed

Thanks for reporting this @ryuheechul! 👍 Had previously changed other commands to include all Rego files but somehow forgotten to do so for OPA check. Fixed via 5599643, and I'll push a new release in a few minutes.

@anderseknert cool and thanks!