From 3b677449d86791679da9e7ce23f754fb1ae8beef Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 11 Aug 2025 15:10:09 +0200 Subject: [PATCH] cli/context: use stdlib errors Signed-off-by: Sebastiaan van Stijn --- cli/context/docker/load.go | 7 ++++--- cli/context/tlsdata.go | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cli/context/docker/load.go b/cli/context/docker/load.go index 55095c20f..1994bda65 100644 --- a/cli/context/docker/load.go +++ b/cli/context/docker/load.go @@ -4,6 +4,8 @@ import ( "crypto/tls" "crypto/x509" "encoding/pem" + "errors" + "fmt" "net" "net/http" "strings" @@ -14,7 +16,6 @@ import ( "github.com/docker/cli/cli/context/store" "github.com/docker/go-connections/tlsconfig" "github.com/moby/moby/client" - "github.com/pkg/errors" ) // EndpointMeta is a typed wrapper around a context-store generic endpoint describing @@ -68,7 +69,7 @@ func (ep *Endpoint) tlsConfig() (*tls.Config, error) { x509cert, err := tls.X509KeyPair(ep.TLSData.Cert, keyBytes) if err != nil { - return nil, errors.Wrap(err, "failed to retrieve context tls info") + return nil, fmt.Errorf("failed to retrieve context tls info: %w", err) } tlsOpts = append(tlsOpts, func(cfg *tls.Config) { cfg.Certificates = []tls.Certificate{x509cert} @@ -160,7 +161,7 @@ func EndpointFromContext(metadata store.Metadata) (EndpointMeta, error) { } typed, ok := ep.(EndpointMeta) if !ok { - return EndpointMeta{}, errors.Errorf("endpoint %q is not of type EndpointMeta", DockerEndpoint) + return EndpointMeta{}, fmt.Errorf("endpoint %q is not of type EndpointMeta", DockerEndpoint) } return typed, nil } diff --git a/cli/context/tlsdata.go b/cli/context/tlsdata.go index c758612a1..9a53d2fd0 100644 --- a/cli/context/tlsdata.go +++ b/cli/context/tlsdata.go @@ -1,10 +1,10 @@ package context import ( + "fmt" "os" "github.com/docker/cli/cli/context/store" - "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -45,14 +45,14 @@ func (data *TLSData) ToStoreTLSData() *store.EndpointTLSData { func LoadTLSData(s store.Reader, contextName, endpointName string) (*TLSData, error) { tlsFiles, err := s.ListTLSFiles(contextName) if err != nil { - return nil, errors.Wrapf(err, "failed to retrieve TLS files for context %q", contextName) + return nil, fmt.Errorf("failed to retrieve TLS files for context %q: %w", contextName, err) } if epTLSFiles, ok := tlsFiles[endpointName]; ok { var tlsData TLSData for _, f := range epTLSFiles { data, err := s.GetTLSData(contextName, endpointName, f) if err != nil { - return nil, errors.Wrapf(err, "failed to retrieve TLS data (%s) for context %q", f, contextName) + return nil, fmt.Errorf("failed to retrieve TLS data (%s) for context %q: %w", f, contextName, err) } switch f { case caKey: