-
Notifications
You must be signed in to change notification settings - Fork 7.5k
fix: replace "github.com/pkg/errors" with stdlib "errors" package #13460
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
Conversation
Signed-off-by: Justen Stall <[email protected]>
Signed-off-by: Justen Stall <[email protected]>
- replace os.IsNotExist with errors.Is and fs.ErrNotExist - use %w directive Signed-off-by: Justen Stall <[email protected]>
Signed-off-by: Justen Stall <[email protected]>
gjenkins8
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.
Can we address the if s.showResources && s.release.Info.Resources != nil change
Otherwise most comments fairly minor.
Thanks for the effort here!
| // Make sure tmpcharts-x is deleted | ||
| tmpPath := filepath.Join(dir(chartname), fmt.Sprintf("tmpcharts-%d", os.Getpid())) | ||
| if _, err := os.Stat(tmpPath); !os.IsNotExist(err) { | ||
| if _, err := os.Stat(tmpPath); !errors.Is(err, fs.ErrNotExist) { |
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.
👍 details (for this substitution and others):
This function predates errors.Is. It only supports errors returned by the os package. New code should use errors.Is(err, fs.ErrNotExist).
https://pkg.go.dev/os#IsNotExist
pkg/storage/driver/secrets_test.go
Outdated
|
|
||
| // fetch the deleted release | ||
| _, err = secrets.Get(key) | ||
| if !reflect.DeepEqual(ErrReleaseNotFound, err) { |
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 guess strictly, reflect.DeepEqual does more than errors.Is. But should be equivalent in this case
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.
Lmk if I should revert
|
(kicked of CI, will find out if any tests rely on error formatting) |
Signed-off-by: Justen Stall <[email protected]>
Co-authored-by: George Jenkins <[email protected]> Signed-off-by: Justen Stall <[email protected]>
Signed-off-by: Justen Stall <[email protected]>
|
(Marked as |
@gjenkins8 Does this mean I should rebase this on the |
No, please (continue to) target the |
|
@gjenkins8 Is there anything I can do to help push this along? |
|
Hello, thank you for your PR, this branch does look like it has some conflicts if you could please address and we can work on getting this in. |
@justenstall I saw you responded 👍 to my request about this in #helm-dev Slack channel. Feel free to ping there when this is complete for a faster response |
Signed-off-by: Justen Stall <[email protected]>
Signed-off-by: Justen Stall <[email protected]>
Signed-off-by: Justen Stall <[email protected]>
|
@scottrigby I opened a child PR with fixes for the lint issues, let me know if they are acceptable and I will add them to this PR: justenstall#1 |
Yes that looks great. Thanks for fixing everywhere 👍 |
Fix lint issues
Signed-off-by: Justen Stall <[email protected]>
Signed-off-by: Justen Stall <[email protected]>
Signed-off-by: Justen Stall <[email protected]>
scottrigby
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.
This PR looks great, apart from one question.
Signed-off-by: Justen Stall <[email protected]>
scottrigby
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.
@justenstall thanks for fixing that.
This PR also needs another rebase again. This is because we just merged another PR that modified an overlapping error—that one was focused on removing a different package and was worth merging separately because it added a golangci-lint depguard rule scoped for that package.
Approving this PR in advance of resolving that new small conflict.
Question: I'm thinking it would be good to add a similar rule for "github.com/pkg/errors" (see #30781 (review)). Are you in the place to add that to this PR as well? If not, that's ok we could do as a fast-follow to your PR, please just let us know.
This PR is ready for another maintainer review either way.
Signed-off-by: Justen Stall <[email protected]>
That's a good idea, I'll add it here. |
Signed-off-by: Justen Stall <[email protected]>
Signed-off-by: Justen Stall <[email protected]>
scottrigby
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.
Nice work. LGTM 👍
The package github.com/pkg/errors was removed via the pull request helm#13460. This change did not correctly handle the case in the windows code and CI did not exercise this to find the error. Signed-off-by: Matt Farina <[email protected]>
The package github.com/pkg/errors was removed via the pull request helm#13460. This change did not correctly handle the case in the windows code and CI did not exercise this to find the error. Signed-off-by: Matt Farina <[email protected]>
What this PR does / why we need it:
Replaces the archived "github.com/pkg/errors" package with the Go standard library equivalents, and updates error handling to use more recent standard library features.
Special notes for your reviewer:
Updates are generally:
errors.Wrap(err, "msg")anderrors.Wrapf(err, "msg")withfmt.Errorf("msg: %w", err)errors.Errorf("msg", args)withfmt.Errorf("msg", args)[]stringandstrings.Joinfor error messages with[]erroranderrors.Join"\n"so they will render the same as beforeos.IsNotExist(err)witherrors.Is(err, fs.ErrNotExist)If applicable:
docs neededlabel should be applied if so)