forked from TrueCloudLab/distribution
Update Push to reflect the correct API
This commit is contained in:
parent
40ccd26d82
commit
9373c8e459
1 changed files with 24 additions and 24 deletions
|
@ -326,10 +326,11 @@ func (r *Registry) PushImageJsonIndex(remote string, imgList []*ImgData, validat
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var suffix string
|
||||||
utils.Debugf("json sent: %s\n", imgListJson)
|
if validate {
|
||||||
|
suffix = "images"
|
||||||
req, err := http.NewRequest("PUT", auth.IndexServerAddress()+"/repositories/"+remote+"/", bytes.NewReader(imgListJson))
|
}
|
||||||
|
req, err := http.NewRequest("PUT", auth.IndexServerAddress()+"/repositories/"+remote+"/"+suffix, bytes.NewReader(imgListJson))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -361,29 +362,28 @@ func (r *Registry) PushImageJsonIndex(remote string, imgList []*ImgData, validat
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.StatusCode != 200 && res.StatusCode != 201 {
|
var tokens, endpoints []string
|
||||||
errBody, err := ioutil.ReadAll(res.Body)
|
if !validate {
|
||||||
if err != nil {
|
if res.StatusCode != 200 && res.StatusCode != 201 {
|
||||||
return nil, err
|
errBody, err := ioutil.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Error: Status %d trying to push repository %s: %s", res.StatusCode, remote, errBody)
|
||||||
|
}
|
||||||
|
if res.Header.Get("X-Docker-Token") != "" {
|
||||||
|
tokens = res.Header["X-Docker-Token"]
|
||||||
|
utils.Debugf("Auth token: %v", tokens)
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("Index response didn't contain an access token")
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("Error: Status %d trying to push repository %s: %s", res.StatusCode, remote, errBody)
|
|
||||||
}
|
|
||||||
|
|
||||||
var tokens []string
|
if res.Header.Get("X-Docker-Endpoints") != "" {
|
||||||
if res.Header.Get("X-Docker-Token") != "" {
|
endpoints = res.Header["X-Docker-Endpoints"]
|
||||||
tokens = res.Header["X-Docker-Token"]
|
} else {
|
||||||
utils.Debugf("Auth token: %v", tokens)
|
return nil, fmt.Errorf("Index response didn't contain any endpoints")
|
||||||
} else {
|
}
|
||||||
return nil, fmt.Errorf("Index response didn't contain an access token")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var endpoints []string
|
|
||||||
if res.Header.Get("X-Docker-Endpoints") != "" {
|
|
||||||
endpoints = res.Header["X-Docker-Endpoints"]
|
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("Index response didn't contain any endpoints")
|
|
||||||
}
|
|
||||||
|
|
||||||
if validate {
|
if validate {
|
||||||
if res.StatusCode != 204 {
|
if res.StatusCode != 204 {
|
||||||
if errBody, err := ioutil.ReadAll(res.Body); err != nil {
|
if errBody, err := ioutil.ReadAll(res.Body); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue