Currently when registry error strings contain new line characters only the last line is displayed to the client. Quote the string to ensure the client can see the entire body value.
fixes #11346
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
... | ... |
@@ -349,7 +349,7 @@ func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry string, t |
349 | 349 |
} else if jsonBody["error"] == "Image already exists" { |
350 | 350 |
return ErrAlreadyExists |
351 | 351 |
} |
352 |
- return fmt.Errorf("HTTP code %d while uploading metadata: %s", res.StatusCode, errBody) |
|
352 |
+ return fmt.Errorf("HTTP code %d while uploading metadata: %q", res.StatusCode, errBody) |
|
353 | 353 |
} |
354 | 354 |
return nil |
355 | 355 |
} |
... | ... |
@@ -385,7 +385,7 @@ func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, regist |
385 | 385 |
} else if jsonBody["error"] == "Image already exists" { |
386 | 386 |
return ErrAlreadyExists |
387 | 387 |
} |
388 |
- return utils.NewHTTPRequestError(fmt.Sprintf("HTTP code %d while uploading metadata: %s", res.StatusCode, errBody), res) |
|
388 |
+ return utils.NewHTTPRequestError(fmt.Sprintf("HTTP code %d while uploading metadata: %q", res.StatusCode, errBody), res) |
|
389 | 389 |
} |
390 | 390 |
return nil |
391 | 391 |
} |
... | ... |
@@ -427,7 +427,7 @@ func (r *Session) PushImageLayerRegistry(imgID string, layer io.Reader, registry |
427 | 427 |
if err != nil { |
428 | 428 |
return "", "", utils.NewHTTPRequestError(fmt.Sprintf("HTTP code %d while uploading metadata and error when trying to parse response body: %s", res.StatusCode, err), res) |
429 | 429 |
} |
430 |
- return "", "", utils.NewHTTPRequestError(fmt.Sprintf("Received HTTP code %d while uploading layer: %s", res.StatusCode, errBody), res) |
|
430 |
+ return "", "", utils.NewHTTPRequestError(fmt.Sprintf("Received HTTP code %d while uploading layer: %q", res.StatusCode, errBody), res) |
|
431 | 431 |
} |
432 | 432 |
|
433 | 433 |
checksumPayload = "sha256:" + hex.EncodeToString(h.Sum(nil)) |
... | ... |
@@ -512,7 +512,7 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate |
512 | 512 |
if err != nil { |
513 | 513 |
return nil, err |
514 | 514 |
} |
515 |
- return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push repository %s: %s", res.StatusCode, remote, errBody), res) |
|
515 |
+ return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push repository %s: %q", res.StatusCode, remote, errBody), res) |
|
516 | 516 |
} |
517 | 517 |
if res.Header.Get("X-Docker-Token") != "" { |
518 | 518 |
tokens = res.Header["X-Docker-Token"] |
... | ... |
@@ -536,7 +536,7 @@ func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate |
536 | 536 |
if err != nil { |
537 | 537 |
return nil, err |
538 | 538 |
} |
539 |
- return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push checksums %s: %s", res.StatusCode, remote, errBody), res) |
|
539 |
+ return nil, utils.NewHTTPRequestError(fmt.Sprintf("Error: Status %d trying to push checksums %s: %q", res.StatusCode, remote, errBody), res) |
|
540 | 540 |
} |
541 | 541 |
} |
542 | 542 |
|