mirror of https://github.com/docker/cli.git
internal/registry: remove pkg/errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
219cfc8b7d
commit
c297770d2d
|
|
@ -2,6 +2,7 @@ package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -12,7 +13,6 @@ import (
|
||||||
"github.com/docker/distribution/registry/client/auth/challenge"
|
"github.com/docker/distribution/registry/client/auth/challenge"
|
||||||
"github.com/docker/distribution/registry/client/transport"
|
"github.com/docker/distribution/registry/client/transport"
|
||||||
"github.com/moby/moby/api/types/registry"
|
"github.com/moby/moby/api/types/registry"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// AuthClientID is used the ClientID used for the token server
|
// 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 {
|
if resp.StatusCode != http.StatusOK {
|
||||||
// TODO(dmcgowan): Attempt to further interpret result, status code and error code string
|
// 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
|
return credentialAuthConfig.IdentityToken, nil
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -117,7 +118,7 @@ skip:
|
||||||
r = host
|
r = host
|
||||||
default:
|
default:
|
||||||
// unsupported scheme
|
// 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
|
// Check if CIDR was passed to --insecure-registry
|
||||||
|
|
@ -133,7 +134,7 @@ skip:
|
||||||
insecureRegistryCIDRs = append(insecureRegistryCIDRs, ipnet)
|
insecureRegistryCIDRs = append(insecureRegistryCIDRs, ipnet)
|
||||||
} else {
|
} else {
|
||||||
if err := validateHostPort(r); err != nil {
|
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.
|
// Assume `host:port` if not CIDR.
|
||||||
indexConfigs[r] = ®istry.IndexInfo{
|
indexConfigs[r] = ®istry.IndexInfo{
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/distribution/registry/api/errcode"
|
"github.com/docker/distribution/registry/api/errcode"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func translateV2AuthError(err error) error {
|
func translateV2AuthError(err error) error {
|
||||||
|
|
@ -23,11 +24,7 @@ func invalidParam(err error) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func invalidParamf(format string, args ...interface{}) error {
|
func invalidParamf(format string, args ...interface{}) error {
|
||||||
return invalidParameterErr{errors.Errorf(format, args...)}
|
return invalidParameterErr{fmt.Errorf(format, args...)}
|
||||||
}
|
|
||||||
|
|
||||||
func invalidParamWrapf(err error, format string, args ...interface{}) error {
|
|
||||||
return invalidParameterErr{errors.Wrapf(err, format, args...)}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type unauthorizedErr struct{ error }
|
type unauthorizedErr struct{ error }
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ package registry
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -82,7 +83,7 @@ func loadTLSConfig(ctx context.Context, directory string, tlsConfig *tls.Config)
|
||||||
if tlsConfig.RootCAs == nil {
|
if tlsConfig.RootCAs == nil {
|
||||||
systemPool, err := tlsconfig.SystemCertPool()
|
systemPool, err := tlsconfig.SystemCertPool()
|
||||||
if err != nil {
|
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
|
tlsConfig.RootCAs = systemPool
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -41,7 +42,7 @@ func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, use
|
||||||
}
|
}
|
||||||
u, err := url.Parse(serverAddress)
|
u, err := url.Parse(serverAddress)
|
||||||
if err != nil {
|
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
|
registryHostName = u.Host
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue