added client's kernel version

This commit is contained in:
Nan Monnand Deng 2013-06-28 17:48:37 -04:00
parent 342460ed9a
commit cf8afcf647

View file

@ -119,9 +119,15 @@ func (r *Registry) setUserAgent(req *http.Request, extra ...VersionChecker) {
userAgent := make(map[string]string, len(r.baseVersions)+len(extra))
for _, v := range r.baseVersions {
if v == nil {
continue
}
userAgent[v.Name()] = v.Version()
}
for _, v := range extra {
if v == nil {
continue
}
userAgent[v.Name()] = v.Version()
}
@ -188,7 +194,7 @@ func (r *Registry) GetRemoteImageJSON(imgID, registry string, token []string) ([
return nil, -1, fmt.Errorf("Failed to download json: %s", err)
}
req.Header.Set("Authorization", "Token "+strings.Join(token, ", "))
r.setUserAgent(req, nil)
r.setUserAgent(req)
res, err := r.client.Do(req)
if err != nil {
return nil, -1, fmt.Errorf("Failed to download json: %s", err)
@ -216,7 +222,7 @@ func (r *Registry) GetRemoteImageLayer(imgID, registry string, token []string) (
return nil, fmt.Errorf("Error while getting from the server: %s\n", err)
}
req.Header.Set("Authorization", "Token "+strings.Join(token, ", "))
r.setUserAgent(req, nil)
r.setUserAgent(req)
res, err := r.client.Do(req)
if err != nil {
return nil, err
@ -237,7 +243,7 @@ func (r *Registry) GetRemoteTags(registries []string, repository string, token [
return nil, err
}
req.Header.Set("Authorization", "Token "+strings.Join(token, ", "))
r.setUserAgent(req, nil)
r.setUserAgent(req)
res, err := r.client.Do(req)
if err != nil {
return nil, err
@ -276,7 +282,7 @@ func (r *Registry) GetRepositoryData(indexEp, remote string) (*RepositoryData, e
req.SetBasicAuth(r.authConfig.Username, r.authConfig.Password)
}
req.Header.Set("X-Docker-Token", "true")
r.setUserAgent(req, nil)
r.setUserAgent(req)
res, err := r.client.Do(req)
if err != nil {
@ -340,7 +346,7 @@ func (r *Registry) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, regis
req.Header.Add("Content-type", "application/json")
req.Header.Set("Authorization", "Token "+strings.Join(token, ","))
req.Header.Set("X-Docker-Checksum", imgData.Checksum)
r.setUserAgent(req, nil)
r.setUserAgent(req)
utils.Debugf("Setting checksum for %s: %s", imgData.ID, imgData.Checksum)
res, err := doWithCookies(r.client, req)
@ -375,7 +381,7 @@ func (r *Registry) PushImageLayerRegistry(imgID string, layer io.Reader, registr
req.ContentLength = -1
req.TransferEncoding = []string{"chunked"}
req.Header.Set("Authorization", "Token "+strings.Join(token, ","))
r.setUserAgent(req, nil)
r.setUserAgent(req)
res, err := doWithCookies(r.client, req)
if err != nil {
return fmt.Errorf("Failed to upload layer: %s", err)
@ -413,7 +419,7 @@ func (r *Registry) PushRegistryTag(remote, revision, tag, registry string, token
}
req.Header.Add("Content-type", "application/json")
req.Header.Set("Authorization", "Token "+strings.Join(token, ","))
r.setUserAgent(req, nil)
r.setUserAgent(req)
req.ContentLength = int64(len(revision))
res, err := doWithCookies(r.client, req)
if err != nil {
@ -446,7 +452,7 @@ func (r *Registry) PushImageJSONIndex(indexEp, remote string, imgList []*ImgData
req.SetBasicAuth(r.authConfig.Username, r.authConfig.Password)
req.ContentLength = int64(len(imgListJSON))
req.Header.Set("X-Docker-Token", "true")
r.setUserAgent(req, nil)
r.setUserAgent(req)
if validate {
req.Header["X-Docker-Endpoints"] = regs
}
@ -467,7 +473,7 @@ func (r *Registry) PushImageJSONIndex(indexEp, remote string, imgList []*ImgData
req.SetBasicAuth(r.authConfig.Username, r.authConfig.Password)
req.ContentLength = int64(len(imgListJSON))
req.Header.Set("X-Docker-Token", "true")
r.setUserAgent(req, nil)
r.setUserAgent(req)
if validate {
req.Header["X-Docker-Endpoints"] = regs
}