Skip to content

Commit c297770

Browse files
committed
internal/registry: remove pkg/errors
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 219cfc8 commit c297770

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

internal/registry/auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package registry
22

33
import (
44
"context"
5+
"fmt"
56
"net/http"
67
"net/url"
78
"strings"
@@ -12,7 +13,6 @@ import (
1213
"github.com/docker/distribution/registry/client/auth/challenge"
1314
"github.com/docker/distribution/registry/client/transport"
1415
"github.com/moby/moby/api/types/registry"
15-
"github.com/pkg/errors"
1616
)
1717

1818
// AuthClientID is used the ClientID used for the token server
@@ -67,7 +67,7 @@ func loginV2(ctx context.Context, authConfig *registry.AuthConfig, endpoint APIE
6767

6868
if resp.StatusCode != http.StatusOK {
6969
// TODO(dmcgowan): Attempt to further interpret result, status code and error code string
70-
return "", errors.Errorf("login attempt to %s failed with status: %d %s", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode))
70+
return "", fmt.Errorf("login attempt to %s failed with status: %d %s", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode))
7171
}
7272

7373
return credentialAuthConfig.IdentityToken, nil

internal/registry/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package registry
55

66
import (
77
"context"
8+
"fmt"
89
"net"
910
"net/url"
1011
"os"
@@ -117,7 +118,7 @@ skip:
117118
r = host
118119
default:
119120
// unsupported scheme
120-
return nil, invalidParamf("insecure registry %s should not contain '://'", r)
121+
return nil, invalidParam(fmt.Errorf("insecure registry %s should not contain '://'", r))
121122
}
122123
}
123124
// Check if CIDR was passed to --insecure-registry
@@ -133,7 +134,7 @@ skip:
133134
insecureRegistryCIDRs = append(insecureRegistryCIDRs, ipnet)
134135
} else {
135136
if err := validateHostPort(r); err != nil {
136-
return nil, invalidParamWrapf(err, "insecure registry %s is not valid", r)
137+
return nil, invalidParam(fmt.Errorf("insecure registry %s is not valid: %w", r, err))
137138
}
138139
// Assume `host:port` if not CIDR.
139140
indexConfigs[r] = &registry.IndexInfo{

internal/registry/errors.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package registry
22

33
import (
4+
"errors"
5+
"fmt"
46
"net/url"
57

68
"github.com/docker/distribution/registry/api/errcode"
7-
"github.com/pkg/errors"
89
)
910

1011
func translateV2AuthError(err error) error {
@@ -23,11 +24,7 @@ func invalidParam(err error) error {
2324
}
2425

2526
func invalidParamf(format string, args ...interface{}) error {
26-
return invalidParameterErr{errors.Errorf(format, args...)}
27-
}
28-
29-
func invalidParamWrapf(err error, format string, args ...interface{}) error {
30-
return invalidParameterErr{errors.Wrapf(err, format, args...)}
27+
return invalidParameterErr{fmt.Errorf(format, args...)}
3128
}
3229

3330
type unauthorizedErr struct{ error }

internal/registry/registry.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package registry
44
import (
55
"context"
66
"crypto/tls"
7+
"fmt"
78
"net"
89
"net/http"
910
"os"
@@ -82,7 +83,7 @@ func loadTLSConfig(ctx context.Context, directory string, tlsConfig *tls.Config)
8283
if tlsConfig.RootCAs == nil {
8384
systemPool, err := tlsconfig.SystemCertPool()
8485
if err != nil {
85-
return invalidParamWrapf(err, "unable to get system cert pool")
86+
return invalidParam(fmt.Errorf("unable to get system cert pool: %w", err))
8687
}
8788
tlsConfig.RootCAs = systemPool
8889
}

internal/registry/service.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/tls"
66
"errors"
7+
"fmt"
78
"net/url"
89
"strings"
910

@@ -41,7 +42,7 @@ func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, use
4142
}
4243
u, err := url.Parse(serverAddress)
4344
if err != nil {
44-
return "", invalidParamWrapf(err, "unable to parse server address")
45+
return "", invalidParam(fmt.Errorf("unable to parse server address: %w", err))
4546
}
4647
registryHostName = u.Host
4748
}

0 commit comments

Comments
 (0)