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,6 +362,8 @@ func (r *Registry) PushImageJsonIndex(remote string, imgList []*ImgData, validat
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tokens, endpoints []string
|
||||||
|
if !validate {
|
||||||
if res.StatusCode != 200 && res.StatusCode != 201 {
|
if res.StatusCode != 200 && res.StatusCode != 201 {
|
||||||
errBody, err := ioutil.ReadAll(res.Body)
|
errBody, err := ioutil.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -368,8 +371,6 @@ func (r *Registry) PushImageJsonIndex(remote string, imgList []*ImgData, validat
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("Error: Status %d trying to push repository %s: %s", res.StatusCode, remote, errBody)
|
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-Token") != "" {
|
if res.Header.Get("X-Docker-Token") != "" {
|
||||||
tokens = res.Header["X-Docker-Token"]
|
tokens = res.Header["X-Docker-Token"]
|
||||||
utils.Debugf("Auth token: %v", tokens)
|
utils.Debugf("Auth token: %v", tokens)
|
||||||
|
@ -377,13 +378,12 @@ func (r *Registry) PushImageJsonIndex(remote string, imgList []*ImgData, validat
|
||||||
return nil, fmt.Errorf("Index response didn't contain an access token")
|
return nil, fmt.Errorf("Index response didn't contain an access token")
|
||||||
}
|
}
|
||||||
|
|
||||||
var endpoints []string
|
|
||||||
if res.Header.Get("X-Docker-Endpoints") != "" {
|
if res.Header.Get("X-Docker-Endpoints") != "" {
|
||||||
endpoints = res.Header["X-Docker-Endpoints"]
|
endpoints = res.Header["X-Docker-Endpoints"]
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("Index response didn't contain any endpoints")
|
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