gatekeeper icon indicating copy to clipboard operation
gatekeeper copied to clipboard

Gator CLI to render print statements output from rego code to stdout

Open jestadi0795 opened this issue 2 years ago • 5 comments

Just hoping to see if we can view print statements in rego code to be rendered as output when using Gator CLI so that debugging/developing a policy can be much faster.

Slack Conversation - https://openpolicyagent.slack.com/archives/CDTN970AX/p1691700736253819

jestadi0795 avatar Aug 11 '23 20:08 jestadi0795

It looks like print statements are not currently printed.

An interim option would be to use the trace() statement and set the --trace flag, which should inject text into the Rego trace. This is probably a better method for development/debug, as more contextual information is provided.

For potential implementation...

Printing could be enabled by setting the appropriate PrintEnabled() and PrintHook() arguments in the Rego driver:

https://github.com/open-policy-agent/frameworks/blob/e24af74adbaeb6c3e9e71d7ef88d63389fa6a3fb/constraint/pkg/client/drivers/rego/args.go#L63-L77

maxsmythe avatar Aug 14 '23 22:08 maxsmythe

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 13 '23 22:10 stale[bot]

not stale

JaydipGabani avatar Jul 31 '25 22:07 JaydipGabani

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 29 '25 23:09 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 29 '25 19:11 stale[bot]