mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.
Remove these imports in preparation of migrating our code to become an
actual go module.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
72 lines
1.3 KiB
Go
72 lines
1.3 KiB
Go
package registry
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
"github.com/docker/distribution/registry/api/errcode"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func translateV2AuthError(err error) error {
|
|
switch e := err.(type) {
|
|
case *url.Error:
|
|
switch e2 := e.Err.(type) {
|
|
case errcode.Error:
|
|
switch e2.Code {
|
|
case errcode.ErrorCodeUnauthorized:
|
|
return unauthorizedErr{err}
|
|
}
|
|
}
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func invalidParam(err error) error {
|
|
return invalidParameterErr{err}
|
|
}
|
|
|
|
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...)}
|
|
}
|
|
|
|
type unauthorizedErr struct{ error }
|
|
|
|
func (unauthorizedErr) Unauthorized() {}
|
|
|
|
func (e unauthorizedErr) Cause() error {
|
|
return e.error
|
|
}
|
|
|
|
func (e unauthorizedErr) Unwrap() error {
|
|
return e.error
|
|
}
|
|
|
|
type invalidParameterErr struct{ error }
|
|
|
|
func (invalidParameterErr) InvalidParameter() {}
|
|
|
|
func (e invalidParameterErr) Unwrap() error {
|
|
return e.error
|
|
}
|
|
|
|
type systemErr struct{ error }
|
|
|
|
func (systemErr) System() {}
|
|
|
|
func (e systemErr) Unwrap() error {
|
|
return e.error
|
|
}
|
|
|
|
type errUnknown struct{ error }
|
|
|
|
func (errUnknown) Unknown() {}
|
|
|
|
func (e errUnknown) Unwrap() error {
|
|
return e.error
|
|
}
|