# Buggy code
def login(url=None, username=None, password=None, email=None):
    """
    Wrapper to the ``docker.py`` login method (does not do much yet)

    url
        registry url to authenticate to

    username
        username to authenticate

    password
        password to authenticate

    email
        email to authenticate

    CLI Example:

    .. code-block:: bash

        salt '*' docker.login <url> <username> <password> <email>
    """
    client = _get_client()
    return client.login(url, username, password, email)


# Traceback (APIError)
$ sudo salt-call docker.login https://index.docker.io/v1/ test@email.com testpassword testusername

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
APIError: 500 Server Error: Internal Server Error ("Invalid registry endpoint https://testusername/v1/: Get https://testusername/v1/_ping: dial tcp: i/o timeout. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry testusername` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/testusername/ca.crt")
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 82, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/__init__.py", line 319, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 144, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 81, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/dockerio.py", line 1167, in login
return client.login(url, username, password, email)
File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 739, in login
return self._result(response, json=True)
File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 93, in _result
self._raise_for_status(response)
File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 89, in _raise_for_status
raise errors.APIError(e, response, explanation=explanation)
APIError: 500 Server Error: Internal Server Error ("Invalid registry endpoint https://testusername/v1/: Get https://testusername/v1/_ping: dial tcp: i/o timeout. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry testusername` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/testusername/ca.crt")
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 82, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/__init__.py", line 319, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 144, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 81, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/dockerio.py", line 1167, in login
return client.login(url, username, password, email)
File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 739, in login
return self._result(response, json=True)
File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 93, in _result
self._raise_for_status(response)
File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 89, in _raise_for_status
raise errors.APIError(e, response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("Invalid registry endpoint https://testusername/v1/: Get https://testusername/v1/_ping: dial tcp: i/o timeout. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry testusername` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/testusername/ca.crt")

# Fixed code
def login(url=None, username=None, password=None, email=None):
    """
    Wrapper to the ``docker.py`` login method (does not do much yet)

    url
        registry url to authenticate to

    username
        username to authenticate

    password
        password to authenticate

    email
        email to authenticate

    CLI Example:

    .. code-block:: bash

        salt '*' docker.login <url> <username> <password> <email>
    """
    client = _get_client()
    return client.login(username, password, email, url)