registry: Refactor requestfactory to use http.RoundTrippers
This patch removes the need for requestFactories and decorators by implementing http.RoundTripper transports instead. It refactors some challenging-to-read code. NewSession now takes an *http.Client that can already have a custom Transport, it will add its own auth transport by wrapping it. The idea is that callers of http.Client should not bother setting custom headers for every handler but instead it should be transparent to the callers of a same context. This patch is needed for future refactorings of registry, namely refactoring of the v1 client code. Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
f13f3a774f
commit
89bd48481c
9 changed files with 373 additions and 353 deletions
|
@ -32,7 +32,7 @@ func (s *Service) Auth(authConfig *cliconfig.AuthConfig) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
authConfig.ServerAddress = endpoint.String()
|
||||
return Login(authConfig, endpoint, HTTPRequestFactory(nil))
|
||||
return Login(authConfig, endpoint)
|
||||
}
|
||||
|
||||
// Search queries the public registry for images matching the specified
|
||||
|
@ -42,12 +42,13 @@ func (s *Service) Search(term string, authConfig *cliconfig.AuthConfig, headers
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// *TODO: Search multiple indexes.
|
||||
endpoint, err := repoInfo.GetEndpoint()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r, err := NewSession(authConfig, HTTPRequestFactory(headers), endpoint, true)
|
||||
r, err := NewSession(endpoint.HTTPClient(), authConfig, endpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue