2018-02-05 16:05:59 -05:00
|
|
|
package registry // import "github.com/docker/docker/registry"
|
2017-07-19 10:20:13 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
"github.com/docker/distribution/registry/api/errcode"
|
2018-01-11 14:53:06 -05:00
|
|
|
"github.com/docker/docker/errdefs"
|
2022-02-26 07:45:12 -05:00
|
|
|
"github.com/pkg/errors"
|
2017-07-19 10:20:13 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
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:
|
2017-11-28 23:09:37 -05:00
|
|
|
return errdefs.Unauthorized(err)
|
2017-07-19 10:20:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
2022-02-26 07:45:12 -05:00
|
|
|
|
|
|
|
func invalidParam(err error) error {
|
|
|
|
return errdefs.InvalidParameter(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func invalidParamf(format string, args ...interface{}) error {
|
|
|
|
return errdefs.InvalidParameter(errors.Errorf(format, args...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func invalidParamWrapf(err error, format string, args ...interface{}) error {
|
|
|
|
return errdefs.InvalidParameter(errors.Wrapf(err, format, args...))
|
|
|
|
}
|