{,x-pack/}auditbeat: replace uses of github.com/pkg/errors with stdlib equivalents#30321
Merged
efd6 merged 4 commits intoelastic:mainfrom Feb 21, 2022
Merged
{,x-pack/}auditbeat: replace uses of github.com/pkg/errors with stdlib equivalents#30321efd6 merged 4 commits intoelastic:mainfrom
efd6 merged 4 commits intoelastic:mainfrom
Conversation
…error handling
This is not completely automatable here due to some semantic differences between
errors.Wrap and fmt.Errorf with the %w verb; the latter will convert a nil error
into a non-nil error, so this must be guarded with a nil error check.
The mechanical transformation was done by running the following commands:
gofmt -w -r 'errors.Errorf -> fmt.Errorf' .
gofmt -w -r 'errors.Wrap(e, m) -> fmt.Errorf(m+": %w", e)' .
gofmt -w -r 'errors.Wrapf(e, m) -> fmt.Errorf(m+": %w", e)' .
gofmt -w -r 'errors.Wrapf(e, m, a) -> fmt.Errorf(m+": %w", a, e)' .
gofmt -w -r 'errors.Wrapf(e, m, a, b) -> fmt.Errorf(m+": %w", a, b, e)' .
gofmt -w -r 'errors.Wrapf(e, m, a, b, c) -> fmt.Errorf(m+": %w", a, b, c, e)' .
find . -name '*.go' -exec gsed -i -e 's/"+": %w",/: %w",/g' '{}' \;
find . -name '*.go' -exec gsed -i -e 's!"github.com/pkg/errors"$!"errors"!g' '{}' \;
goimports -w .
go mod tidy
gofumpt -w .
Replaying that will give the changes here modulo some manual changes that are
made in the next commit. There should be no uses of %w in this change that are
not guarded by a nil-check.
Contributor
…r handling This is the manual part of the change and includes some complete removal of errors and some silently passed bugs resulting from the use of Wrap. In one place the exact semantics of errors.Cause is implemented to fit in with a testing strategy.
a0345f6 to
5a53f65
Compare
Contributor
|
Pinging @elastic/security-external-integrations (Team:Security-External Integrations) |
3 tasks
v1v
added a commit
to v1v/beats
that referenced
this pull request
Feb 21, 2022
…nd-k8s-env * upstream/main: fix typos and improve sentences (elastic#30432) Add drop and explicit tests to avoid duplicate ingest of elasticsearch logs (elastic#30440) {,x-pack/}auditbeat: replace uses of github.com/pkg/errors with stdlib equivalents (elastic#30321) Spelling fix (elastic#30439) packetbeat/beater: make sure Npcap installation runs before interfaces are needed in all cases (elastic#30438) Add BC about Homebrew no longer being available in 8.0 (elastic#30419) Install gawk as a replacement for mawk in Docker containers. (elastic#30452) Clean up python-related system tests (elastic#30415) Fix TestNewModuleRegistry flakiness (elastic#30453) [Filebeat] [auditd]: Support EXECVE events with truncated argument list (elastic#30382) Set `log.offset` to the start of the reported line in filestream (elastic#30445) clarify SelectedPackageTypes meaning and improve its usage (elastic#30142) [elasticsearch module] serialize shards properties (elastic#30408) Add docs about hints and templates autodiscovery priority (elastic#30343)
v1v
added a commit
to v1v/beats
that referenced
this pull request
Feb 22, 2022
…ckaging-docker * upstream/main: (26 commits) Update docker/distribution to 2.8.0 (elastic#30462) Add `parsers` examples to `filestream` reference configuration (elastic#30529) extend documentation about setting orchestrator.cluster fields (elastic#30518) Forward-port 8.0.1 changelog to main (elastic#30522) Switch skip to use `CI` (elastic#30512) packetbeat/beater: don't attempt to install npcap when already installed (elastic#30509) Fix Docker module: rename fields on dashboards (elastic#30500) fix typos and improve sentences (elastic#30432) Add drop and explicit tests to avoid duplicate ingest of elasticsearch logs (elastic#30440) {,x-pack/}auditbeat: replace uses of github.com/pkg/errors with stdlib equivalents (elastic#30321) Spelling fix (elastic#30439) packetbeat/beater: make sure Npcap installation runs before interfaces are needed in all cases (elastic#30438) Add BC about Homebrew no longer being available in 8.0 (elastic#30419) Install gawk as a replacement for mawk in Docker containers. (elastic#30452) Clean up python-related system tests (elastic#30415) Fix TestNewModuleRegistry flakiness (elastic#30453) [Filebeat] [auditd]: Support EXECVE events with truncated argument list (elastic#30382) Set `log.offset` to the start of the reported line in filestream (elastic#30445) clarify SelectedPackageTypes meaning and improve its usage (elastic#30142) [elasticsearch module] serialize shards properties (elastic#30408) ...
This file contains hidden or 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
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.
What does this PR do?
This replaces uses of github.com/pkg/errors with their standard library equivalents.
Why is it important?
github.com/pkg/errors is now archived and additionally does work that we almost never use (see elastic/go-libaudit#99 for background); the one place where this work is used is replaced with a stdlib call.
Checklist
- [ ] I have commented my code, particularly in hard-to-understand areas- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added tests that prove my fix is effective or that my feature worksCHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Author's Checklist
%winfmt.Errorfcalls where the error has not been confirmed to be non-nil.How to test this PR locally
Related issues
Use cases
Screenshots
Logs