mirror of https://github.com/docker/docker-py.git
commit
4c263ee2c9
|
@ -143,7 +143,8 @@ class BuildApiMixin(object):
|
||||||
if os.path.exists(dockerignore):
|
if os.path.exists(dockerignore):
|
||||||
with open(dockerignore, 'r') as f:
|
with open(dockerignore, 'r') as f:
|
||||||
exclude = list(filter(
|
exclude = list(filter(
|
||||||
bool, [l.strip() for l in f.read().splitlines()]
|
lambda x: x != '' and x[0] != '#',
|
||||||
|
[l.strip() for l in f.read().splitlines()]
|
||||||
))
|
))
|
||||||
context = utils.tar(
|
context = utils.tar(
|
||||||
path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
|
path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
|
||||||
|
|
|
@ -119,7 +119,9 @@ class APIClient(
|
||||||
)
|
)
|
||||||
self.mount('http+docker://', self._custom_adapter)
|
self.mount('http+docker://', self._custom_adapter)
|
||||||
self._unmount('http://', 'https://')
|
self._unmount('http://', 'https://')
|
||||||
self.base_url = 'http+docker://localunixsocket'
|
# host part of URL should be unused, but is resolved by requests
|
||||||
|
# module in proxy_bypass_macosx_sysconf()
|
||||||
|
self.base_url = 'http+docker://localhost'
|
||||||
elif base_url.startswith('npipe://'):
|
elif base_url.startswith('npipe://'):
|
||||||
if not IS_WINDOWS_PLATFORM:
|
if not IS_WINDOWS_PLATFORM:
|
||||||
raise DockerException(
|
raise DockerException(
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
version = "3.1.0"
|
version = "3.1.1"
|
||||||
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])
|
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
Change log
|
Change log
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
3.1.1
|
||||||
|
-----
|
||||||
|
|
||||||
|
[List of PRs / issues for this release](https://github.com/docker/docker-py/milestone/46?closed=1)
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
|
||||||
|
* Fixed a bug that caused costly DNS lookups on Mac OSX when connecting to the
|
||||||
|
engine through UNIX socket
|
||||||
|
* Fixed a bug that caused `.dockerignore` comments to be read as exclusion
|
||||||
|
patterns
|
||||||
|
|
||||||
3.1.0
|
3.1.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,16 @@ class BuildTest(BaseAPIIntegrationTest):
|
||||||
'Dockerfile',
|
'Dockerfile',
|
||||||
'.dockerignore',
|
'.dockerignore',
|
||||||
'!ignored/subdir/excepted-file',
|
'!ignored/subdir/excepted-file',
|
||||||
'', # empty line
|
'', # empty line,
|
||||||
|
'#*', # comment line
|
||||||
]))
|
]))
|
||||||
|
|
||||||
with open(os.path.join(base_dir, 'not-ignored'), 'w') as f:
|
with open(os.path.join(base_dir, 'not-ignored'), 'w') as f:
|
||||||
f.write("this file should not be ignored")
|
f.write("this file should not be ignored")
|
||||||
|
|
||||||
|
with open(os.path.join(base_dir, '#file.txt'), 'w') as f:
|
||||||
|
f.write('this file should not be ignored')
|
||||||
|
|
||||||
subdir = os.path.join(base_dir, 'ignored', 'subdir')
|
subdir = os.path.join(base_dir, 'ignored', 'subdir')
|
||||||
os.makedirs(subdir)
|
os.makedirs(subdir)
|
||||||
with open(os.path.join(subdir, 'file'), 'w') as f:
|
with open(os.path.join(subdir, 'file'), 'w') as f:
|
||||||
|
@ -92,6 +96,7 @@ class BuildTest(BaseAPIIntegrationTest):
|
||||||
logs = logs.decode('utf-8')
|
logs = logs.decode('utf-8')
|
||||||
|
|
||||||
assert sorted(list(filter(None, logs.split('\n')))) == sorted([
|
assert sorted(list(filter(None, logs.split('\n')))) == sorted([
|
||||||
|
'/test/#file.txt',
|
||||||
'/test/ignored/subdir/excepted-file',
|
'/test/ignored/subdir/excepted-file',
|
||||||
'/test/not-ignored'
|
'/test/not-ignored'
|
||||||
])
|
])
|
||||||
|
|
|
@ -36,7 +36,7 @@ class BaseIntegrationTest(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
for container in self.tmp_containers:
|
for container in self.tmp_containers:
|
||||||
try:
|
try:
|
||||||
client.api.remove_container(container, force=True)
|
client.api.remove_container(container, force=True, v=True)
|
||||||
except docker.errors.APIError:
|
except docker.errors.APIError:
|
||||||
pass
|
pass
|
||||||
for network in self.tmp_networks:
|
for network in self.tmp_networks:
|
||||||
|
|
|
@ -47,10 +47,13 @@ class ContainerCollectionTest(BaseIntegrationTest):
|
||||||
self.tmp_containers.append(container.id)
|
self.tmp_containers.append(container.id)
|
||||||
container.wait()
|
container.wait()
|
||||||
|
|
||||||
|
name = "container_volume_test"
|
||||||
out = client.containers.run(
|
out = client.containers.run(
|
||||||
"alpine", "cat /insidecontainer/test",
|
"alpine", "cat /insidecontainer/test",
|
||||||
volumes=["%s:/insidecontainer" % path]
|
volumes=["%s:/insidecontainer" % path],
|
||||||
|
name=name
|
||||||
)
|
)
|
||||||
|
self.tmp_containers.append(name)
|
||||||
assert out == b'hello\n'
|
assert out == b'hello\n'
|
||||||
|
|
||||||
def test_run_with_named_volume(self):
|
def test_run_with_named_volume(self):
|
||||||
|
@ -66,10 +69,13 @@ class ContainerCollectionTest(BaseIntegrationTest):
|
||||||
self.tmp_containers.append(container.id)
|
self.tmp_containers.append(container.id)
|
||||||
container.wait()
|
container.wait()
|
||||||
|
|
||||||
|
name = "container_volume_test"
|
||||||
out = client.containers.run(
|
out = client.containers.run(
|
||||||
"alpine", "cat /insidecontainer/test",
|
"alpine", "cat /insidecontainer/test",
|
||||||
volumes=["somevolume:/insidecontainer"]
|
volumes=["somevolume:/insidecontainer"],
|
||||||
|
name=name
|
||||||
)
|
)
|
||||||
|
self.tmp_containers.append(name)
|
||||||
assert out == b'hello\n'
|
assert out == b'hello\n'
|
||||||
|
|
||||||
def test_run_with_network(self):
|
def test_run_with_network(self):
|
||||||
|
|
|
@ -512,7 +512,7 @@ def post_fake_network_disconnect():
|
||||||
|
|
||||||
|
|
||||||
# Maps real api url to fake response callback
|
# Maps real api url to fake response callback
|
||||||
prefix = 'http+docker://localunixsocket'
|
prefix = 'http+docker://localhost'
|
||||||
if constants.IS_WINDOWS_PLATFORM:
|
if constants.IS_WINDOWS_PLATFORM:
|
||||||
prefix = 'http+docker://localnpipe'
|
prefix = 'http+docker://localnpipe'
|
||||||
|
|
||||||
|
|
|
@ -902,6 +902,22 @@ class ExcludePathsTest(unittest.TestCase):
|
||||||
['*.md', '!README*.md', 'README-secret.md']
|
['*.md', '!README*.md', 'README-secret.md']
|
||||||
) == set(['README.md', 'README-bis.md'])
|
) == set(['README.md', 'README-bis.md'])
|
||||||
|
|
||||||
|
def test_parent_directory(self):
|
||||||
|
base = make_tree(
|
||||||
|
[],
|
||||||
|
['a.py',
|
||||||
|
'b.py',
|
||||||
|
'c.py'])
|
||||||
|
# Dockerignore reference stipulates that absolute paths are
|
||||||
|
# equivalent to relative paths, hence /../foo should be
|
||||||
|
# equivalent to ../foo. It also stipulates that paths are run
|
||||||
|
# through Go's filepath.Clean, which explicitely "replace
|
||||||
|
# "/.." by "/" at the beginning of a path".
|
||||||
|
assert exclude_paths(
|
||||||
|
base,
|
||||||
|
['../a.py', '/../b.py']
|
||||||
|
) == set(['c.py'])
|
||||||
|
|
||||||
|
|
||||||
class TarTest(unittest.TestCase):
|
class TarTest(unittest.TestCase):
|
||||||
def test_tar_with_excludes(self):
|
def test_tar_with_excludes(self):
|
||||||
|
|
Loading…
Reference in New Issue