mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #14679 from tiborvass/fix-docker-py-search-test
Fix issue where Search API endpoint would panic due to empty AuthConfig
This commit is contained in:
commit
48a01a317c
1 changed files with 4 additions and 1 deletions
|
@ -89,13 +89,16 @@ func (tr *authTransport) RoundTrip(orig *http.Request) (*http.Response, error) {
|
||||||
tr.mu.Unlock()
|
tr.mu.Unlock()
|
||||||
|
|
||||||
if tr.alwaysSetBasicAuth {
|
if tr.alwaysSetBasicAuth {
|
||||||
|
if tr.AuthConfig == nil {
|
||||||
|
return nil, errors.New("unexpected error: empty auth config")
|
||||||
|
}
|
||||||
req.SetBasicAuth(tr.Username, tr.Password)
|
req.SetBasicAuth(tr.Username, tr.Password)
|
||||||
return tr.RoundTripper.RoundTrip(req)
|
return tr.RoundTripper.RoundTrip(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't override
|
// Don't override
|
||||||
if req.Header.Get("Authorization") == "" {
|
if req.Header.Get("Authorization") == "" {
|
||||||
if req.Header.Get("X-Docker-Token") == "true" && len(tr.Username) > 0 {
|
if req.Header.Get("X-Docker-Token") == "true" && tr.AuthConfig != nil && len(tr.Username) > 0 {
|
||||||
req.SetBasicAuth(tr.Username, tr.Password)
|
req.SetBasicAuth(tr.Username, tr.Password)
|
||||||
} else if len(tr.token) > 0 {
|
} else if len(tr.token) > 0 {
|
||||||
req.Header.Set("Authorization", "Token "+strings.Join(tr.token, ","))
|
req.Header.Set("Authorization", "Token "+strings.Join(tr.token, ","))
|
||||||
|
|
Loading…
Reference in a new issue