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: Add --exit-error (-e) flag #49

Merged
merged 3 commits into from Oct 23, 2020
Merged

feat: Add --exit-error (-e) flag #49

merged 3 commits into from Oct 23, 2020

Conversation

stepanstipl
Copy link
Contributor

This PR adds --exit-error (-e) flag for convenience. When enabled this will make kubent return non-zero exit code in case any issues are found. Also, tests for exit codes are added.

Fixes #31.

@stepanstipl stepanstipl requested a review from a user October 22, 2020 20:28
@stepanstipl stepanstipl self-assigned this Oct 22, 2020
@ghost
Copy link

ghost commented Oct 23, 2020

Shouldn't this exit with 0, by default?

@stepanstipl
Copy link
Contributor Author

Shouldn't this exit with 0, by default?

It does, this is kinda for convenience so that you don't have to check this explicitly (#31), it's described better in committed docs, sorry if it wasn't clear from the PR:

kubent will by default return 0 exit code if the program succeeds, even if it finds deprecated resources, and non-zero exit code if there is an error during runtime. Because all info output goes to stderr, it's easy to check in shell if any issues were found:

...

You can also use --exit-error (-e) flag, which will make kubent to exit with non-zero return code (200) in case any issues are found.

cmd/kubent/main.go Outdated Show resolved Hide resolved
cmd/kubent/main_test.go Outdated Show resolved Hide resolved
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Better tests structure now too!

@ghost
Copy link

ghost commented Oct 23, 2020

We should probably change all the tests to use the t.Fatalf, but thats for annother pr

@stepanstipl stepanstipl merged commit fc5e8de into master Oct 23, 2020
@stepanstipl stepanstipl deleted the exit-code branch October 23, 2020 10:49
@stepanstipl stepanstipl mentioned this pull request Oct 23, 2020
@stepanstipl stepanstipl added the feature New feature or request label Nov 11, 2020
@stepanstipl stepanstipl changed the title Add --exit-error (-e) flag feat: Add --exit-error (-e) flag Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI mode
1 participant