Make V2 login errors more descriptive

If login fails, we now call validate again to get the reason for the failure, and then surface it to the user of the CLI. This allows for more actionable responses, such as:

$ docker login 10.0.2.2:5000
Username (devtable): devtable
Password:

Error response from daemon: Get http://10.0.2.2:5000/v2/: unauthorized: Client login with unencrypted passwords is disabled. Please generate an encrypted password in the user admin panel for use here.
This commit is contained in:
Joseph Schorr 2017-03-16 17:06:05 -04:00
parent 651666b60b
commit 95e1cf6673
2 changed files with 17 additions and 8 deletions

View file

@ -146,3 +146,12 @@ class Unsupported(V2RegistryException):
'The operation is unsupported.',
detail,
405)
class InvalidLogin(V2RegistryException):
def __init__(self, message=None):
super(InvalidLogin, self).__init__('UNAUTHORIZED',
message or 'Specified credentials are invalid',
{},
401)