Skip to content

Allow structured errors in rules#243

Merged
jpreese merged 5 commits into
open-policy-agent:masterfrom
jpreese:structured-errors
Feb 19, 2020
Merged

Allow structured errors in rules#243
jpreese merged 5 commits into
open-policy-agent:masterfrom
jpreese:structured-errors

Conversation

@jpreese

@jpreese jpreese commented Feb 18, 2020

Copy link
Copy Markdown
Member

This is based heavily off of the work done by @gwkunze in #100. Master has diverged quite a bit since the original discussions and PRs, so the important bits were cherrypicked from there.

This PR enables rego rules to use structured errors in their rules

e.g.

warn[msg] {
  kubernetes.is_service
  msg = sprintf("Found service %s but services are not allowed", [name])
}

could now be

violation[{"msg": msg, "details":{"additional": "extra stuff here if wanted"}}] {
  kubernetes.is_service
  msg = sprintf("Found service %s but services are not allowed", [name])
}

This will enable us to support Gatekeeper policies that require a rule header of

violation[{"msg": msg, "details":{}}]

@jpreese jpreese mentioned this pull request Feb 18, 2020
@boranx

boranx commented Feb 19, 2020

Copy link
Copy Markdown
Member

@jpreese overall looks good
I'd prefer to merge it after commits are squashed into one.

@jpreese

jpreese commented Feb 19, 2020

Copy link
Copy Markdown
Member Author

@boranx once approved we can click the Squash and merge button. I usually don't bother squashing until that point.

@boranx boranx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jpreese jpreese merged commit 93ee280 into open-policy-agent:master Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants