-
Notifications
You must be signed in to change notification settings - Fork 172
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: safer context parsing, general refactoring #228
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rfratto
approved these changes
Mar 10, 2020
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.
I have a couple of nits but this LGTM.
Previously, context parsing used a lot of `objx.Must`, which can panic. Also, schemas were not properly resolved, instead just unmarshalled onto `map[string]interface`, so possible errors were not caught. Now uses very explicit error handling so that it does not panic anymore, but instead print proper (and hopefully helpful) error messages
Adds global defer using a custom package so that we can schedule tasks for run on exit. This is used for removing the environment patch from the temp directory after each run, so we don't leak possibly sensitive data there
Improves code style by fixing the most important linter discoveries (golint, govet, golangci-lint)
The native funcs were `var` before, because functions can't be `const`. Variable native funcs made so sense however, so we now use functions returning the native func, so they are effectively constant
Global defers are probably not the best idea and as we can avoid it, we should. Switches the cleanup required for the kubectl nsPatch to the `io.Closer` pattern.
rfratto
approved these changes
Mar 10, 2020
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.
LGTM!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Did some housekeeping in
pkg/kubernetes/client
, replaced mostpanic
situations with proper errors that include context around the cause.This should result in more safe parsing of
kubectl config view
, so that errors from there are not as ugly as before.Also did some general refactoring, linter fixes, etc
/cc @cyriltovena @mplzik