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

Remove users of pkg/errors.WithStack, pkg/errors.Cause #1588

Merged
merged 15 commits into from Jul 1, 2022

Commits on Jun 30, 2022

  1. 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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    1e700d7 View commit details
    Browse the repository at this point in the history
  2. Remove uses of errors.Errorf

    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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    6accca5 View commit details
    Browse the repository at this point in the history
  3. Fix typos

    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    3852bb9 View commit details
    Browse the repository at this point in the history
  4. 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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    72550dd View commit details
    Browse the repository at this point in the history
  5. Drop the stderrors alias

    ... now that the other package is referred to as perrors.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    cc81081 View commit details
    Browse the repository at this point in the history
  6. 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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    1eb6aa9 View commit details
    Browse the repository at this point in the history
  7. 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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    c175928 View commit details
    Browse the repository at this point in the history
  8. 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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    f11b965 View commit details
    Browse the repository at this point in the history
  9. 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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    d826d8d View commit details
    Browse the repository at this point in the history
  10. 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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    e3aa3d1 View commit details
    Browse the repository at this point in the history
  11. 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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    7356439 View commit details
    Browse the repository at this point in the history
  12. 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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    7dfd1e9 View commit details
    Browse the repository at this point in the history
  13. Simplify GetAllCredentials

    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>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    38ef0e0 View commit details
    Browse the repository at this point in the history
  14. Remove errors.Cause from RemoveAllAuthentication

    Also replace switch with an if
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    bad5406 View commit details
    Browse the repository at this point in the history
  15. Move the main helper removal case to the main path on RemoveAllAuthen…

    …tication
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jun 30, 2022
    Copy the full SHA
    1124042 View commit details
    Browse the repository at this point in the history