vendor containers/iamge for DockerRegistryUserAgent

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-10-11 18:23:09 +02:00
parent c00868148e
commit 5721355da7
No known key found for this signature in database
GPG Key ID: B2BEAD150DE936B9
2 changed files with 6 additions and 1 deletions

View File

@ -125,6 +125,9 @@ func (c *dockerClient) makeRequestToResolvedURL(method, url string, headers map[
req.Header.Add(n, hh)
}
}
if c.ctx != nil && c.ctx.DockerRegistryUserAgent != "" {
req.Header.Add("User-Agent", c.ctx.DockerRegistryUserAgent)
}
if c.wwwAuthenticate != "" {
if err := c.setupRequestAuth(req); err != nil {
return nil, err
@ -317,7 +320,7 @@ type pingResponse struct {
func (c *dockerClient) ping() (*pingResponse, error) {
ping := func(scheme string) (*pingResponse, error) {
url := fmt.Sprintf(baseURL, scheme, c.registry)
resp, err := c.client.Get(url)
resp, err := c.makeRequestToResolvedURL("GET", url, nil, nil, -1)
logrus.Debugf("Ping %s err %#v", url, err)
if err != nil {
return nil, err

View File

@ -244,4 +244,6 @@ type SystemContext struct {
DockerInsecureSkipTLSVerify bool // Allow contacting docker registries over HTTP, or HTTPS with failed TLS verification. Note that this does not affect other TLS connections.
// if nil, the library tries to parse ~/.docker/config.json to retrieve credentials
DockerAuthConfig *DockerAuthConfig
// if not "", an User-Agent header is added to each request when contacting a registry.
DockerRegistryUserAgent string
}