1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #33005 from alfred-landrum/denied-error

Suggest login on pull denial
This commit is contained in:
Sebastiaan van Stijn 2017-06-13 01:51:18 +02:00 committed by GitHub
commit f4bf61c79d
3 changed files with 4 additions and 3 deletions

View file

@ -73,6 +73,7 @@ func GetHTTPErrorStatusCode(err error) int {
{"this node", http.StatusServiceUnavailable}, {"this node", http.StatusServiceUnavailable},
{"needs to be unlocked", http.StatusServiceUnavailable}, {"needs to be unlocked", http.StatusServiceUnavailable},
{"certificates have expired", http.StatusServiceUnavailable}, {"certificates have expired", http.StatusServiceUnavailable},
{"repository does not exist", http.StatusNotFound},
} { } {
if strings.Contains(errStr, status.keyword) { if strings.Contains(errStr, status.keyword) {
statusCode = status.code statusCode = status.code

View file

@ -78,7 +78,7 @@ func TranslatePullError(err error, ref reference.Named) error {
switch v.Code { switch v.Code {
case errcode.ErrorCodeDenied: case errcode.ErrorCodeDenied:
// ErrorCodeDenied is used when access to the repository was denied // ErrorCodeDenied is used when access to the repository was denied
newErr = errors.Errorf("repository %s not found: does not exist or no pull access", reference.FamiliarName(ref)) newErr = errors.Errorf("pull access denied for %s, repository does not exist or may require 'docker login'", reference.FamiliarName(ref))
case v2.ErrorCodeManifestUnknown: case v2.ErrorCodeManifestUnknown:
newErr = errors.Errorf("manifest for %s not found", reference.FamiliarString(ref)) newErr = errors.Errorf("manifest for %s not found", reference.FamiliarString(ref))
case v2.ErrorCodeNameUnknown: case v2.ErrorCodeNameUnknown:

View file

@ -98,11 +98,11 @@ func (s *DockerHubPullSuite) TestPullNonExistingImage(c *check.C) {
for record := range recordChan { for record := range recordChan {
if len(record.option) == 0 { if len(record.option) == 0 {
c.Assert(record.err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", record.out)) c.Assert(record.err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", record.out))
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")) 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"))
} else { } else {
// pull -a on a nonexistent registry should fall back as well // pull -a on a nonexistent registry should fall back as well
c.Assert(record.err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", record.out)) c.Assert(record.err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", record.out))
c.Assert(record.out, checker.Contains, fmt.Sprintf("repository %s not found", record.e.repo), check.Commentf("expected image not found error messages")) 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"))
c.Assert(record.out, checker.Not(checker.Contains), "unauthorized", check.Commentf(`message should not contain "unauthorized"`)) c.Assert(record.out, checker.Not(checker.Contains), "unauthorized", check.Commentf(`message should not contain "unauthorized"`))
} }
} }