Suggest login on pull denial
| ... | ... |
@@ -73,6 +73,7 @@ func GetHTTPErrorStatusCode(err error) int {
|
| 73 | 73 |
{"this node", http.StatusServiceUnavailable},
|
| 74 | 74 |
{"needs to be unlocked", http.StatusServiceUnavailable},
|
| 75 | 75 |
{"certificates have expired", http.StatusServiceUnavailable},
|
| 76 |
+ {"repository does not exist", http.StatusNotFound},
|
|
| 76 | 77 |
} {
|
| 77 | 78 |
if strings.Contains(errStr, status.keyword) {
|
| 78 | 79 |
statusCode = status.code |
| ... | ... |
@@ -78,7 +78,7 @@ func TranslatePullError(err error, ref reference.Named) error {
|
| 78 | 78 |
switch v.Code {
|
| 79 | 79 |
case errcode.ErrorCodeDenied: |
| 80 | 80 |
// ErrorCodeDenied is used when access to the repository was denied |
| 81 |
- newErr = errors.Errorf("repository %s not found: does not exist or no pull access", reference.FamiliarName(ref))
|
|
| 81 |
+ newErr = errors.Errorf("pull access denied for %s, repository does not exist or may require 'docker login'", reference.FamiliarName(ref))
|
|
| 82 | 82 |
case v2.ErrorCodeManifestUnknown: |
| 83 | 83 |
newErr = errors.Errorf("manifest for %s not found", reference.FamiliarString(ref))
|
| 84 | 84 |
case v2.ErrorCodeNameUnknown: |
| ... | ... |
@@ -98,11 +98,11 @@ func (s *DockerHubPullSuite) TestPullNonExistingImage(c *check.C) {
|
| 98 | 98 |
for record := range recordChan {
|
| 99 | 99 |
if len(record.option) == 0 {
|
| 100 | 100 |
c.Assert(record.err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", record.out))
|
| 101 |
- c.Assert(record.out, checker.Contains, fmt.Sprintf("repository %s not found: does not exist or no pull access", record.e.repo), check.Commentf("expected image not found error messages"))
|
|
| 101 |
+ c.Assert(record.out, checker.Contains, fmt.Sprintf("pull access denied for %s, repository does not exist or may require 'docker login'", record.e.repo), check.Commentf("expected image not found error messages"))
|
|
| 102 | 102 |
} else {
|
| 103 | 103 |
// pull -a on a nonexistent registry should fall back as well |
| 104 | 104 |
c.Assert(record.err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", record.out))
|
| 105 |
- c.Assert(record.out, checker.Contains, fmt.Sprintf("repository %s not found", record.e.repo), check.Commentf("expected image not found error messages"))
|
|
| 105 |
+ c.Assert(record.out, checker.Contains, fmt.Sprintf("pull access denied for %s, repository does not exist or may require 'docker login'", record.e.repo), check.Commentf("expected image not found error messages"))
|
|
| 106 | 106 |
c.Assert(record.out, checker.Not(checker.Contains), "unauthorized", check.Commentf(`message should not contain "unauthorized"`)) |
| 107 | 107 |
} |
| 108 | 108 |
} |