Skip to content

Conversation

@justenstall
Copy link
Contributor

@justenstall justenstall commented Nov 18, 2024

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:

  • Replace errors.Wrap(err, "msg") and errors.Wrapf(err, "msg") with fmt.Errorf("msg: %w", err)
  • Replace errors.Errorf("msg", args) with fmt.Errorf("msg", args)
  • Replace uses of []string and strings.Join for error messages with []error and errors.Join
    • Used a simple wrapper type (example) if the error messages were being joined with any string other than "\n" so they will render the same as before
  • Replace os.IsNotExist(err) with errors.Is(err, fs.ErrNotExist)

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

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]>
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 18, 2024
Copy link
Member

@gjenkins8 gjenkins8 left a 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) {
Copy link
Member

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


// fetch the deleted release
_, err = secrets.Get(key)
if !reflect.DeepEqual(ErrReleaseNotFound, err) {
Copy link
Member

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

Copy link
Contributor Author

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

@gjenkins8
Copy link
Member

(kicked of CI, will find out if any tests rely on error formatting)

justenstall and others added 3 commits November 18, 2024 22:28
gjenkins8
gjenkins8 previously approved these changes Nov 19, 2024
@gjenkins8 gjenkins8 added Has One Approval This PR has one approval. It still needs a second approval to be merged. Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR labels Nov 19, 2024
@gjenkins8
Copy link
Member

gjenkins8 commented Nov 19, 2024

(Marked as Needs v3 backport for backport back to dev-v3 branch, as this commit touches enough files that it merge conflicts will likely eventuate when backporting other changes)

@justenstall
Copy link
Contributor Author

(Marked as needs v3 fix for backport back to dev-v3 branch, as this commit touches enough files that it merge conflicts will likely eventuate when backporting other changes)

@gjenkins8 Does this mean I should rebase this on the dev-v3 branch?

@gjenkins8
Copy link
Member

(Marked as needs v3 fix for backport back to dev-v3 branch, as this commit touches enough files that it merge conflicts will likely eventuate when backporting other changes)

@gjenkins8 Does this mean I should rebase this on the dev-v3 branch?

No, please (continue to) target the main branch. We would cherry-pick these commits to dev-v3 branch to backport to Helm v3. This avoids e.g. bugfixes, refactors like this being applied to Helm 3 only. And being "forgotten" to be merged into Helm 4.

@justenstall
Copy link
Contributor Author

@gjenkins8 Is there anything I can do to help push this along?

@gjenkins8 gjenkins8 removed the Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR label Jan 5, 2025
@robertsirc
Copy link
Member

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.

@scottrigby
Copy link
Member

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]>
@justenstall
Copy link
Contributor Author

@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

@scottrigby
Copy link
Member

@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 👍

Signed-off-by: Justen Stall <[email protected]>
Signed-off-by: Justen Stall <[email protected]>
Copy link
Member

@scottrigby scottrigby left a 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.

scottrigby
scottrigby previously approved these changes Apr 22, 2025
Copy link
Member

@scottrigby scottrigby left a 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.

@justenstall
Copy link
Contributor Author

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.

That's a good idea, I'll add it here.

@scottrigby scottrigby added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 23, 2025
@scottrigby scottrigby removed Has One Approval This PR has one approval. It still needs a second approval to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 23, 2025
Copy link
Member

@scottrigby scottrigby left a comment

Choose a reason for hiding this comment

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

Nice work. LGTM 👍

@scottrigby scottrigby added the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Apr 23, 2025
@gjenkins8 gjenkins8 merged commit ecf1730 into helm:main Apr 23, 2025
5 checks passed
mattfarina added a commit to mattfarina/helm that referenced this pull request Apr 25, 2025
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]>
@mattfarina mattfarina mentioned this pull request Apr 25, 2025
3 tasks
Shaps pushed a commit to Shaps/helm that referenced this pull request Sep 27, 2025
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Has One Approval This PR has one approval. It still needs a second approval to be merged. refactor size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants