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

Allow overwriting exit code #544

Closed
danielpacak opened this issue Apr 20, 2021 · 3 comments
Closed

Allow overwriting exit code #544

danielpacak opened this issue Apr 20, 2021 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@danielpacak
Copy link

Dear Maintainers,

I'm running Conftest as a Kubernetes Job. In case of any failure Conftest returns non zero exit code, hence the Job is failing.
A quick and dirty solution that I came up with is to use the following command:

sh -c "conftest test --output json --all-namespaces --policy /project/policy /project/workload.yaml || true"

However, I'd love to overwrite exit code with a flag:

conftest test --exit-code 0 --output json --all-namespaces --policy /project/policy /project/workload.yaml 

Do you think it makes sense to allow overwriting exit code? If yes would you be interested in reviewing a PR that adds the exit-code flag? Or please advice otherwise.

@jpreese
Copy link
Member

jpreese commented Apr 20, 2021

Can you think of any scenarios where you'd want to set the exit code to a non-zero number?

I could see adding a flag such as --no-fail which would make it such that conftest would always return zero. Would this work for your use case?

@jpreese jpreese added the enhancement New feature or request label Apr 20, 2021
@danielpacak
Copy link
Author

danielpacak commented Apr 20, 2021

In my case I want to set exit code to 0 when policies are evaluated with no errors so the --no-fail flag would be enough.

@jpreese jpreese modified the milestones: v0.24.0, v0.25.0 Apr 20, 2021
@jpreese
Copy link
Member

jpreese commented Apr 21, 2021

The OPA binary uses --fail and --fail-defined for its eval command so --no-fail feels appropriate. PR added here: #547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants