2017-07-19 17:20:13 +03:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
"github.com/docker/distribution/registry/api/errcode"
|
2018-01-11 22:53:06 +03:00
|
|
|
"github.com/docker/docker/errdefs"
|
2017-07-19 17:20:13 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type notFoundError string
|
|
|
|
|
|
|
|
func (e notFoundError) Error() string {
|
|
|
|
return string(e)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (notFoundError) NotFound() {}
|
|
|
|
|
|
|
|
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-29 07:09:37 +03:00
|
|
|
return errdefs.Unauthorized(err)
|
2017-07-19 17:20:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|