Better error output upon push failure

This commit is contained in:
Guillaume J. Charmes 2013-05-08 14:19:38 -07:00
parent 8ff1765674
commit 6cafed45af
1 changed files with 10 additions and 5 deletions

View File

@ -427,9 +427,15 @@ func pushImageRec(graph *Graph, stdout io.Writer, img *Image, registry string, t
if err != nil { if err != nil {
return fmt.Errorf("Failed to upload layer: %s", err) return fmt.Errorf("Failed to upload layer: %s", err)
} }
res3.Body.Close() defer res3.Body.Close()
if res3.StatusCode != 200 { if res3.StatusCode != 200 {
return fmt.Errorf("Received HTTP code %d while uploading layer", res3.StatusCode) errBody, err := ioutil.ReadAll(res3.Body)
if err != nil {
return fmt.Errorf("HTTP code %d while uploading metadata and error when"+
" trying to parse response body: %v", res.StatusCode, err)
}
return fmt.Errorf("Received HTTP code %d while uploading layer: %s", res3.StatusCode, errBody)
} }
return nil return nil
} }
@ -612,8 +618,7 @@ func (graph *Graph) PushRepository(stdout io.Writer, remote string, localRepo Re
} }
func (graph *Graph) Checksums(output io.Writer, repo Repository) ([]map[string]string, error) { func (graph *Graph) Checksums(output io.Writer, repo Repository) ([]map[string]string, error) {
var result []map[string]string checksums := make(map[string]string)
checksums := map[string]string{}
for _, id := range repo { for _, id := range repo {
img, err := graph.Get(id) img, err := graph.Get(id)
if err != nil { if err != nil {
@ -634,7 +639,7 @@ func (graph *Graph) Checksums(output io.Writer, repo Repository) ([]map[string]s
} }
} }
i := 0 i := 0
result = make([]map[string]string, len(checksums)) result := make([]map[string]string, len(checksums))
for id, sum := range checksums { for id, sum := range checksums {
result[i] = map[string]string{ result[i] = map[string]string{
"id": id, "id": id,