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

Replace github.com/pkg/errors with standard library errors package #1688

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nirs
Copy link
Member

@nirs nirs commented Dec 1, 2024

  • Import apimachinery api errors as k8serrors
  • Replace github.com/pkg/errors with standard errors
  • Fix errors to make revive happy

Fixes #1678

- Rename "k8s.io/apimachinery/pkg/api/errors" to "k8serrors"
- Replace "github.com/pkg/errors" with "errors" package
- Replace usage of errors.Wrap() with fmt.Errorf("...: %w", err)

Part-of: RamenDR#1678
Signed-off-by: Nir Soffer <[email protected]>
@nirs nirs force-pushed the errors-cleanup branch 2 times, most recently from e510dc3 to cf978a9 Compare December 1, 2024 19:25
@nirs nirs marked this pull request as ready for review December 2, 2024 16:09
@nirs

This comment was marked as outdated.

Replacing the "github.com/pkg/errors" with "errors" reveal a lint issue
with the revive linter:

    InitialWaitTimeForDRPCPlacementRule should have name of the form ErrFoo (revive)

While fixing, remove pointless wrapping. errors.Is() is documented to
match any error in err's tree including err itself.

Part-of: RamenDR#1678
Signed-off-by: Nir Soffer <[email protected]>
So we can use the standard library errors package.

Part-of: RamenDR#1678
Signed-off-by: Nir Soffer <[email protected]>
The non standard:

    errors.Wrap(err, "msg")

was replaced with:

    fmt.Errorf("msg: %w", err)

Fixes: RamenDR#1678
Signed-off-by: Nir Soffer <[email protected]>
- Add Err prefix
- Remove unneeded error type
- Start error message with lower letter (Waiting -> waiting)
- Remove tailing punctuation (...)

Signed-off-by: Nir Soffer <[email protected]>
@nirs nirs changed the title Errors package cleanups Replace github.com/pkg/errors with standard library errors package Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace github.com/pkg/errors with standard library errors package
2 participants