-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🌱 Use errors package of Go #10875
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
🌱 Use errors package of Go #10875
Conversation
neolit123
left a comment
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.
generally seems better to use Is() and As() instead of the type assertions.
|
/assign |
e594fc8 to
d75a32f
Compare
d75a32f to
5f7ac82
Compare
5f7ac82 to
2f50f5b
Compare
|
I currently don't find the time to review this PR. Just one comment, we have to be really really sure this doesn't break anything accidentally (by catching more or less errors than before) |
anmazzotti
left a comment
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.
Agree with @neolit123 a few instances could use errors.Is instead, but this is also ok.
sbueringer
left a comment
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.
Let's use errors.As only if we actually want to use the error afterwards. In a lot of cases we only check but never use the error value
bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go
Outdated
Show resolved
Hide resolved
|
I rebased and fixed some review points. Thanks. |
2f50f5b to
3464653
Compare
e0f31c0 to
aed4673
Compare
|
The list that I should write UnitTests
|
09c3e85 to
955b195
Compare
4e9cb5f to
121d9fb
Compare
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
8af499e to
77d9e30
Compare
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.
as i commented here, kubeadm wrapped the stdlib errors package to resemble pkg/errors in a consistent manner.
that i think is the better solution instead of importing the stdlib errors and using fmt.Errorf in some places.
capi can fork the relevant bits from kubeadm. maybe we can put this code in k/component-base eventually but that needs agreement with other sigs.
|
It sounds good, then if we decide to use it, we might be able to drop the direct dependence of pkg/errors completely. |
|
Can we please stick with using pkg/errors for this PR? We can have the discussion on how to migrate and then make this a dedicated effort, but it should not be mixed with other changes in my opinion. (For what it's worth, I agree with Lubomir's suggestion on how to migrate) |
77d9e30 to
90ec76a
Compare
Signed-off-by: sivchari <[email protected]>
Signed-off-by: sivchari <[email protected]>
Signed-off-by: sivchari <[email protected]>
90ec76a to
de80ccb
Compare
|
Thx! /lgtm |
|
LGTM label has been added. Git tree hash: 2f3a32316c42371c579f7a6cece3686d37c59a49
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbueringer The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Will be fixed elsewhere /override pull-cluster-api-e2e-main |
|
@sbueringer: Overrode contexts on behalf of sbueringer: pull-cluster-api-e2e-main In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What this PR does / why we need it:
Go has errors package to use Is() and As(). These API can check recursively if the err is one we want.
So I use errors package to check recursively.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #