2018-02-05 21:05:59 +00:00
|
|
|
package registry // import "github.com/docker/docker/registry"
|
2017-07-19 14:20:13 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
"github.com/docker/distribution/registry/api/errcode"
|
2018-01-11 19:53:06 +00:00
|
|
|
"github.com/docker/docker/errdefs"
|
2017-07-19 14:20:13 +00: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-29 04:09:37 +00:00
|
|
|
return errdefs.Unauthorized(err)
|
2017-07-19 14:20:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|