Merge pull request #1542 from runcom/typed-errors
registry: client: auth: type errors
This commit is contained in:
commit
71d808de07
@ -15,9 +15,15 @@ import (
|
|||||||
"github.com/docker/distribution/registry/client/transport"
|
"github.com/docker/distribution/registry/client/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
// ErrNoBasicAuthCredentials is returned if a request can't be authorized with
|
// ErrNoBasicAuthCredentials is returned if a request can't be authorized with
|
||||||
// basic auth due to lack of credentials.
|
// basic auth due to lack of credentials.
|
||||||
var ErrNoBasicAuthCredentials = errors.New("no basic auth credentials")
|
ErrNoBasicAuthCredentials = errors.New("no basic auth credentials")
|
||||||
|
|
||||||
|
// ErrNoToken is returned if a request is successful but the body does not
|
||||||
|
// contain an authorization token.
|
||||||
|
ErrNoToken = errors.New("authorization server did not include a token in the response")
|
||||||
|
)
|
||||||
|
|
||||||
const defaultClientID = "registry-client"
|
const defaultClientID = "registry-client"
|
||||||
|
|
||||||
@ -402,7 +408,7 @@ func (th *tokenHandler) fetchTokenWithBasicAuth(realm *url.URL, service string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tr.Token == "" {
|
if tr.Token == "" {
|
||||||
return "", time.Time{}, errors.New("authorization server did not include a token in the response")
|
return "", time.Time{}, ErrNoToken
|
||||||
}
|
}
|
||||||
|
|
||||||
if tr.ExpiresIn < minimumTokenLifetimeSeconds {
|
if tr.ExpiresIn < minimumTokenLifetimeSeconds {
|
||||||
|
Loading…
Reference in New Issue
Block a user