Skip to content
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

Merged
merged 4 commits into from Aug 21, 2023

Conversation

Ronnie-personal
Copy link
Contributor

@Ronnie-personal Ronnie-personal commented Aug 11, 2023

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:

@netlify
Copy link

netlify bot commented Aug 11, 2023

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit c1e490f
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/64e32b95f1e50b00082f6b78
😎 Deploy Preview https://deploy-preview-6153--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Ronnie-personal Ronnie-personal marked this pull request as ready for review August 11, 2023 03:04
Copy link
Member

@anderseknert anderseknert left a 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(&params.Fail, "fail", "", false, "exits with non-zero exit code on undefined/empty result and errors")
cmd.Flags().BoolVarP(&params.FailDefined, "fail-defined", "", false, "")
cmd.Flags().BoolVarP(&params.Fail, "fail", "", false, "")
cmd.Flags().BoolVarP(&params.Fail, "fail-non-empty", "", false, "")
Copy link
Member

Choose a reason for hiding this comment

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

This should not use &params.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 Show resolved Hide resolved
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
Copy link
Member

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?

@Ronnie-personal
Copy link
Contributor Author

This is a great start! I left a few comments, but this is looking good :)

Thank you for the review, I will check them out.

@Ronnie-personal
Copy link
Contributor Author

/retest

@Ronnie-personal
Copy link
Contributor Author

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?
Do we have the failure details in the log?
I run 'make test' in my local environment, opa/runtime actually passed.

Thanks.

Copy link
Member

@anderseknert anderseknert left a 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(&params.Fail, "fail", "", false, "exits with non-zero exit code on undefined/empty result and errors")
cmd.Flags().BoolVarP(&params.FailDefined, "fail-defined", "", false, "exits with non-zero exit code on defined result and errors")
cmd.Flags().BoolVarP(&params.Fail, "fail", "", false, "exits with non-zero exit code on undefined result and errors")
cmd.Flags().BoolVarP(&params.FailNonEmpty, "fail-non-empty", "", false, "exits with non-zero exit code on non empty result and errors")
Copy link
Member

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.

Copy link
Contributor Author

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>
@anderseknert
Copy link
Member

I've now tried this out locally and it seems like it's working as expected. Thanks for you work on this @Ronnie-personal 👍

@anderseknert anderseknert merged commit c3854aa into open-policy-agent:main Aug 21, 2023
25 checks passed
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.

None yet

2 participants