1
0
mirror of https://github.com/docker/cli.git synced 2026-01-15 07:40:57 +03:00

Add the X-Docker-Token header to the /v1/search requests.

By adding this header AuthTransport will add Basic authentication to the request and allow 'docker search' results to include private images.

Signed-off-by: Matt Moore <mattmoor@google.com>
Upstream-commit: 5a170484d1d6fab982727987425fa154c96cf25e
Component: engine
This commit is contained in:
Matt Moore
2015-07-09 20:56:23 -07:00
parent aae04e2dff
commit be6a8bd99d

View File

@@ -676,7 +676,14 @@ func shouldRedirect(response *http.Response) bool {
func (r *Session) SearchRepositories(term string) (*SearchResults, error) {
logrus.Debugf("Index server: %s", r.indexEndpoint)
u := r.indexEndpoint.VersionString(1) + "search?q=" + url.QueryEscape(term)
res, err := r.client.Get(u)
req, err := http.NewRequest("GET", u, nil)
if err != nil {
return nil, fmt.Errorf("Error while getting from the server: %v", err)
}
// Have the AuthTransport send authentication, when logged in.
req.Header.Set("X-Docker-Token", "true")
res, err := r.client.Do(req)
if err != nil {
return nil, err
}