- Add since, until and filters parameters to `Client.events`
- Add missing `events`command in the documentation
Signed-off-by: Christophe Labouisse <christophe@labouisse.org>
Avoid crashing when the Docker python client is able to load
registry credentials when building using a remote source
Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
The new docker api allows specifing mac address for containers. This change is to allow docker py the same functionality.
Signed-off-by: James Harris <james@rancher.com>
Rather than have one function that can do 5 things and attempts to guess
what the user wanted, it's good to have a function for each possible
method of importing an image. Error cases are handled a lot better this
way.
The unit test test_import_image_from_file() was changed to be
test_import_image_from_bytes(), because if we try to import a temporary
file in the test, the 'data' parameter of the 'fake_request' object is
an instance of a funny internal type like <_io.BufferedReader
name='/tmp/tmpc9chux'> and it's very hard to match such a thing with
`mock.assert_called_with()`.
This allows streaming a system to the 'import' command, rather than
having to read the whole thing into memory before sending it.
Previously both the UnixAdapter and the docker.Client objects would
track the 'base URL' of the Docker daemon (socket path in the case of
local Unix-domain socket connections). The Client object would construct
URLs which contained the path to the socket with the path of the Docker
API call appended. The UnixHTTPConnection instance would then remove the
known socket path from the URL.
This relied on all calls going through the HTTPConnection.request()
function, where the URL could be rewritten. In the case of 'chunked'
HTTP POST requests this doesn't happen, so such calls would request
a path still including the socket path and would receive a 404 error.
The client now constructs URLs containing just the path of the desired API
endpoint, and expects the Unix socket transport to know the path to the
Docker daemon's socket.
Totally bad test :( (written by me). The documentation and
code should match now. Many thanks to pranavs18 for spotting
the error and proposing the fix.
Data already in local python buffers was lost when stream socket
fileobject was re-created. We now use http.client to handle the chunk
transfer encoding, and we read only the data from each chunk.
This adds a test harness for stream responses which tries to trigger the
lost-buffer behaviour by responding to the HTTP request in full, as
early as possible.
NB: Python's http.client will close the socket fileobj early if there is
no content length or chunked transfer encoding header. If this happens,
requests/urllib3 will reopen it, but we lose some data which was stored
in buffers.