mirror of https://github.com/docker/docker-py.git
Merge branch 'cameronmaske-push-tags'
This commit is contained in:
commit
c76fd8d914
|
@ -201,7 +201,7 @@ c.pull(repository, tag=None, stream=False)
|
|||
Identical to the `docker pull` command.
|
||||
|
||||
```python
|
||||
c.push(repository, stream=False)
|
||||
c.push(repository, tag=None, stream=False)
|
||||
```
|
||||
|
||||
Identical to the `docker push` command.
|
||||
|
|
|
@ -747,9 +747,14 @@ class Client(requests.Session):
|
|||
else:
|
||||
return self._result(response)
|
||||
|
||||
def push(self, repository, stream=False):
|
||||
def push(self, repository, tag=None, stream=False):
|
||||
if not tag:
|
||||
repository, tag = utils.parse_repository_tag(repository)
|
||||
registry, repo_name = auth.resolve_repository_name(repository)
|
||||
u = self._url("/images/{0}/push".format(repository))
|
||||
params = {
|
||||
'tag': tag
|
||||
}
|
||||
headers = {}
|
||||
|
||||
if utils.compare_version('1.5', self._version) >= 0:
|
||||
|
@ -765,9 +770,10 @@ class Client(requests.Session):
|
|||
if authcfg:
|
||||
headers['X-Registry-Auth'] = auth.encode_header(authcfg)
|
||||
|
||||
response = self._post_json(u, None, headers=headers, stream=stream)
|
||||
response = self._post_json(u, None, headers=headers,
|
||||
stream=stream, params=params)
|
||||
else:
|
||||
response = self._post_json(u, None, stream=stream)
|
||||
response = self._post_json(u, None, stream=stream, params=params)
|
||||
|
||||
return stream and self._stream_helper(response) \
|
||||
or self._result(response)
|
||||
|
|
|
@ -1306,6 +1306,30 @@ class DockerClientTest(Cleanup, unittest.TestCase):
|
|||
|
||||
fake_request.assert_called_with(
|
||||
url_prefix + 'images/test_image/push',
|
||||
params={
|
||||
'tag': None
|
||||
},
|
||||
data='{}',
|
||||
headers={'Content-Type': 'application/json'},
|
||||
stream=False,
|
||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
||||
)
|
||||
|
||||
def test_push_image_with_tag(self):
|
||||
try:
|
||||
with mock.patch('docker.auth.auth.resolve_authconfig',
|
||||
fake_resolve_authconfig):
|
||||
self.client.push(
|
||||
fake_api.FAKE_IMAGE_NAME, tag=fake_api.FAKE_TAG_NAME
|
||||
)
|
||||
except Exception as e:
|
||||
self.fail('Command should not raise exception: {0}'.format(e))
|
||||
|
||||
fake_request.assert_called_with(
|
||||
url_prefix + 'images/test_image/push',
|
||||
params={
|
||||
'tag': fake_api.FAKE_TAG_NAME,
|
||||
},
|
||||
data='{}',
|
||||
headers={'Content-Type': 'application/json'},
|
||||
stream=False,
|
||||
|
@ -1322,6 +1346,9 @@ class DockerClientTest(Cleanup, unittest.TestCase):
|
|||
|
||||
fake_request.assert_called_with(
|
||||
url_prefix + 'images/test_image/push',
|
||||
params={
|
||||
'tag': None
|
||||
},
|
||||
data='{}',
|
||||
headers={'Content-Type': 'application/json'},
|
||||
stream=True,
|
||||
|
|
Loading…
Reference in New Issue