Skip to content

Commit

Permalink
Merge pull request #1943 from docker/3.1.1-release
Browse files Browse the repository at this point in the history
3.1.1 release
  • Loading branch information
shin- authored Mar 5, 2018
2 parents 79f27c6 + 52c3d52 commit 4c263ee
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docker/api/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
if os.path.exists(dockerignore):
with open(dockerignore, 'r') as f:
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(
path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
Expand Down
4 changes: 3 additions & 1 deletion docker/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def __init__(self, base_url=None, version=None,
)
self.mount('http+docker://', self._custom_adapter)
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://'):
if not IS_WINDOWS_PLATFORM:
raise DockerException(
Expand Down
2 changes: 1 addition & 1 deletion docker/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "3.1.0"
version = "3.1.1"
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])
12 changes: 12 additions & 0 deletions docs/change-log.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
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
-----

Expand Down
7 changes: 6 additions & 1 deletion tests/integration/api_build_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ def test_build_with_dockerignore(self):
'Dockerfile',
'.dockerignore',
'!ignored/subdir/excepted-file',
'', # empty line
'', # empty line,
'#*', # comment line
]))

with open(os.path.join(base_dir, 'not-ignored'), 'w') as f:
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')
os.makedirs(subdir)
with open(os.path.join(subdir, 'file'), 'w') as f:
Expand All @@ -92,6 +96,7 @@ def test_build_with_dockerignore(self):
logs = logs.decode('utf-8')

assert sorted(list(filter(None, logs.split('\n')))) == sorted([
'/test/#file.txt',
'/test/ignored/subdir/excepted-file',
'/test/not-ignored'
])
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def tearDown(self):
pass
for container in self.tmp_containers:
try:
client.api.remove_container(container, force=True)
client.api.remove_container(container, force=True, v=True)
except docker.errors.APIError:
pass
for network in self.tmp_networks:
Expand Down
10 changes: 8 additions & 2 deletions tests/integration/models_containers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ def test_run_with_volume(self):
self.tmp_containers.append(container.id)
container.wait()

name = "container_volume_test"
out = client.containers.run(
"alpine", "cat /insidecontainer/test",
volumes=["%s:/insidecontainer" % path]
volumes=["%s:/insidecontainer" % path],
name=name
)
self.tmp_containers.append(name)
assert out == b'hello\n'

def test_run_with_named_volume(self):
Expand All @@ -66,10 +69,13 @@ def test_run_with_named_volume(self):
self.tmp_containers.append(container.id)
container.wait()

name = "container_volume_test"
out = client.containers.run(
"alpine", "cat /insidecontainer/test",
volumes=["somevolume:/insidecontainer"]
volumes=["somevolume:/insidecontainer"],
name=name
)
self.tmp_containers.append(name)
assert out == b'hello\n'

def test_run_with_network(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/fake_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def post_fake_network_disconnect():


# Maps real api url to fake response callback
prefix = 'http+docker://localunixsocket'
prefix = 'http+docker://localhost'
if constants.IS_WINDOWS_PLATFORM:
prefix = 'http+docker://localnpipe'

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,22 @@ def test_last_line_precedence(self):
['*.md', '!README*.md', 'README-secret.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):
def test_tar_with_excludes(self):
Expand Down

0 comments on commit 4c263ee

Please sign in to comment.