New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cmd): Adding fail-non-empty flag6132 #6153
feat(cmd): Adding fail-non-empty flag6132 #6153
Conversation
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great start! I left a few comments, but this is looking good :)
cmd/exec.go
Outdated
cmd.Flags().BoolVarP(¶ms.Fail, "fail", "", false, "exits with non-zero exit code on undefined/empty result and errors") | ||
cmd.Flags().BoolVarP(¶ms.FailDefined, "fail-defined", "", false, "") | ||
cmd.Flags().BoolVarP(¶ms.Fail, "fail", "", false, "") | ||
cmd.Flags().BoolVarP(¶ms.Fail, "fail-non-empty", "", false, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not use ¶ms.Fail
but use the FailNonEmpty
param added for the non-empty case.
Also, removing all documentation from these options seems wrong. I'd go with:
fail-defined
: "exits with non-zero exit code on defined result and errors"
fail
: "exits with non-zero exit code on undefined result and errors"
fail-empty
: "exits with non-zero exit code on empty result and errors"
cmd/exec_test.go
Outdated
description: "--fail-non-empty with true boolean result", | ||
files: map[string]string{ | ||
"files/test.json": `{"foo": 7}`, | ||
"bundle/x.rego": `package fail.defined.flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These package names are misleading. Maybe use something like fail.non.empty.flag
instead?
Thank you for the review, I will check them out. |
/retest |
Could you help me to understand the failure at https://github.com/open-policy-agent/opa/actions/runs/5897177383/job/15996426056?pr=6153#step:6:258? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Just a nit to fix :)
I'll test this out on Monday and if it's all good we should have this merged.
cmd/exec.go
Outdated
cmd.Flags().BoolVarP(¶ms.Fail, "fail", "", false, "exits with non-zero exit code on undefined/empty result and errors") | ||
cmd.Flags().BoolVarP(¶ms.FailDefined, "fail-defined", "", false, "exits with non-zero exit code on defined result and errors") | ||
cmd.Flags().BoolVarP(¶ms.Fail, "fail", "", false, "exits with non-zero exit code on undefined result and errors") | ||
cmd.Flags().BoolVarP(¶ms.FailNonEmpty, "fail-non-empty", "", false, "exits with non-zero exit code on non empty result and errors") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: but we say "non-zero", so we should say "non-empty" too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment, I have modified it at this commit f91f52d
Signed-off-by: Ronnie Personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie Personal <76408835+Ronnie-personal@users.noreply.github.com>
…st case Signed-off-by: Ronnie Personal <76408835+Ronnie-personal@users.noreply.github.com>
Signed-off-by: Ronnie Personal <76408835+Ronnie-personal@users.noreply.github.com>
f91f52d
to
c1e490f
Compare
I've now tried this out locally and it seems like it's working as expected. Thanks for you work on this @Ronnie-personal 👍 |
Why the changes in this PR are needed?
This PR addresses issue #6132
What are the changes in this PR?
'--fail-non-empty' flag is added to 'opa exec' CLI.
Notes to assist PR review:
Further comments: