internal/registry: remove pkg/errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-07-24 23:15:40 +02:00
parent 219cfc8b7d
commit c297770d2d
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 12 additions and 12 deletions

View File

@ -2,6 +2,7 @@ package registry
import (
"context"
"fmt"
"net/http"
"net/url"
"strings"
@ -12,7 +13,6 @@ import (
"github.com/docker/distribution/registry/client/auth/challenge"
"github.com/docker/distribution/registry/client/transport"
"github.com/moby/moby/api/types/registry"
"github.com/pkg/errors"
)
// AuthClientID is used the ClientID used for the token server
@ -67,7 +67,7 @@ func loginV2(ctx context.Context, authConfig *registry.AuthConfig, endpoint APIE
if resp.StatusCode != http.StatusOK {
// TODO(dmcgowan): Attempt to further interpret result, status code and error code string
return "", errors.Errorf("login attempt to %s failed with status: %d %s", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode))
return "", fmt.Errorf("login attempt to %s failed with status: %d %s", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode))
}
return credentialAuthConfig.IdentityToken, nil

View File

@ -5,6 +5,7 @@ package registry
import (
"context"
"fmt"
"net"
"net/url"
"os"
@ -117,7 +118,7 @@ skip:
r = host
default:
// unsupported scheme
return nil, invalidParamf("insecure registry %s should not contain '://'", r)
return nil, invalidParam(fmt.Errorf("insecure registry %s should not contain '://'", r))
}
}
// Check if CIDR was passed to --insecure-registry
@ -133,7 +134,7 @@ skip:
insecureRegistryCIDRs = append(insecureRegistryCIDRs, ipnet)
} else {
if err := validateHostPort(r); err != nil {
return nil, invalidParamWrapf(err, "insecure registry %s is not valid", r)
return nil, invalidParam(fmt.Errorf("insecure registry %s is not valid: %w", r, err))
}
// Assume `host:port` if not CIDR.
indexConfigs[r] = &registry.IndexInfo{

View File

@ -1,10 +1,11 @@
package registry
import (
"errors"
"fmt"
"net/url"
"github.com/docker/distribution/registry/api/errcode"
"github.com/pkg/errors"
)
func translateV2AuthError(err error) error {
@ -23,11 +24,7 @@ func invalidParam(err error) error {
}
func invalidParamf(format string, args ...interface{}) error {
return invalidParameterErr{errors.Errorf(format, args...)}
}
func invalidParamWrapf(err error, format string, args ...interface{}) error {
return invalidParameterErr{errors.Wrapf(err, format, args...)}
return invalidParameterErr{fmt.Errorf(format, args...)}
}
type unauthorizedErr struct{ error }

View File

@ -4,6 +4,7 @@ package registry
import (
"context"
"crypto/tls"
"fmt"
"net"
"net/http"
"os"
@ -82,7 +83,7 @@ func loadTLSConfig(ctx context.Context, directory string, tlsConfig *tls.Config)
if tlsConfig.RootCAs == nil {
systemPool, err := tlsconfig.SystemCertPool()
if err != nil {
return invalidParamWrapf(err, "unable to get system cert pool")
return invalidParam(fmt.Errorf("unable to get system cert pool: %w", err))
}
tlsConfig.RootCAs = systemPool
}

View File

@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"errors"
"fmt"
"net/url"
"strings"
@ -41,7 +42,7 @@ func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, use
}
u, err := url.Parse(serverAddress)
if err != nil {
return "", invalidParamWrapf(err, "unable to parse server address")
return "", invalidParam(fmt.Errorf("unable to parse server address: %w", err))
}
registryHostName = u.Host
}