@@ -2,6 +2,7 @@ package trust
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67 "io"
78 "os"
@@ -14,7 +15,6 @@ import (
1415 "github.com/docker/cli/cli/trust"
1516 "github.com/docker/cli/internal/lazyregexp"
1617 "github.com/docker/cli/opts"
17- "github.com/pkg/errors"
1818 "github.com/spf13/cobra"
1919 "github.com/theupdateframework/notary/client"
2020 "github.com/theupdateframework/notary/tuf/data"
@@ -106,7 +106,7 @@ func addSignerToRepo(ctx context.Context, dockerCLI command.Cli, signerName stri
106106 newSignerRoleName := data .RoleName (path .Join (data .CanonicalTargetsRole .String (), signerName ))
107107
108108 if err := addStagedSigner (notaryRepo , newSignerRoleName , signerPubKeys ); err != nil {
109- return errors . Wrapf ( err , "could not add signer to repo: %s" , strings .TrimPrefix (newSignerRoleName .String (), "targets/" ))
109+ return fmt . Errorf ( "could not add signer to repo: %s: %w " , strings .TrimPrefix (newSignerRoleName .String (), "targets/" ), err )
110110 }
111111
112112 return notaryRepo .Publish ()
@@ -118,20 +118,20 @@ func ingestPublicKeys(pubKeyPaths []string) ([]data.PublicKey, error) {
118118 // Read public key bytes from PEM file, limit to 1 KiB
119119 pubKeyFile , err := os .OpenFile (pubKeyPath , os .O_RDONLY , 0o666 )
120120 if err != nil {
121- return nil , errors . Wrap ( err , "unable to read public key from file" )
121+ return nil , fmt . Errorf ( "unable to read public key from file: %w" , err )
122122 }
123123 defer pubKeyFile .Close ()
124124 // limit to
125125 l := io .LimitReader (pubKeyFile , 1 << 20 )
126126 pubKeyBytes , err := io .ReadAll (l )
127127 if err != nil {
128- return nil , errors . Wrap ( err , "unable to read public key from file" )
128+ return nil , fmt . Errorf ( "unable to read public key from file: %w" , err )
129129 }
130130
131131 // Parse PEM bytes into type PublicKey
132132 pubKey , err := tufutils .ParsePEMPublicKey (pubKeyBytes )
133133 if err != nil {
134- return nil , errors . Wrapf ( err , "could not parse public key from file: %s" , pubKeyPath )
134+ return nil , fmt . Errorf ( "could not parse public key from file: %s: %w " , pubKeyPath , err )
135135 }
136136 pubKeys = append (pubKeys , pubKey )
137137 }
0 commit comments