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
Remove users of pkg/errors.WithStack, pkg/errors.Cause #1588
Commits on Jun 30, 2022
-
Stop using pkg/errors.WithStack
It's not a part of the API promise, it's fairly costly, and we want to move away from pkg/errors. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
This means we won't save the stack, which is cheaper (and possibly might break callers' format strings that want to print the stack, but we never promised the stack to be available). Use either fmt.Errorf, or errors.New (usually as a local edit, not carring about errors.new vs. pkg/errors.New; that's going to be cleaned up later). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Always refer to pkg/errors as perrors
This will allow imports of errors and pkg/errors to coexist in a single package, avoid adding accidental new uses via errors.New(), make any potential new additions more visible in reviews. Files that can import errors only (typically because they only use errors.New) have been updated to that import instead of renaming. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
... now that the other package is referred to as perrors. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Replace uses of perrors.New with errors.New
This removes the stack trace, potentially visible to callers. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Remove uses of errors.cause in copy/copy.go
For these marker errors, presence at any location in the unwrap stack was most likely intentional, so this should be safe. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Remove use of errors.Cause in pkg/blobcache
fs.ErrNotExist anywhere on the unwrap stack should be sufficient, so use the recommended modern replacement for os.IsNotExist, making errors.Cause unnecessary. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Remove uses of errors.Cause in storage_test.go
Presence of storage.ErrDuplicateID anywhere on the unwrap stack seems appropriate here. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Remove uses of errors.Cause in storage_image.go
Accepting ErrDuplicateID or ErrLayerUnknown anywhere on the unwrap stack seems appropriate. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Reorganize flow in pkg/docker/config
By construction of pkg/errors.WithStack / pkg/errors.WithMessage / pkg/errors.Wrap*, pkg/errors.Cause() can only return nil if the error is nil. Move that away from the error handling code. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Remove use of errors.Cause in GetAllCredentials
Presence of exec.ErrNotFound anywhere on the unwrap stack seems appropriate. Also replace the switch with an if. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
In the exec.ErrNotFound case, set creds to nil so that we have the ordinary handling on the main line. Then eliminate two consecutive if statements with the same condition. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Remove errors.Cause from RemoveAllAuthentication
Also replace switch with an if Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-
Move the main helper removal case to the main path on RemoveAllAuthen…
…tication Signed-off-by: Miloslav Trmač <mitr@redhat.com>