From 75138b72cd5a20ce3cea5f0216ae1521cf8d4fbc Mon Sep 17 00:00:00 2001 From: willnx Date: Wed, 28 Aug 2019 15:25:14 -0700 Subject: [PATCH 1/2] ContainerShell support multiple mount paths inside the container --- VERSION | 2 +- container_shell/lib/dockage.py | 9 +++++---- sample.config.ini | 3 +++ tests/test_dockage.py | 9 +++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 324cf0a..027870b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2019.08.26 +2019.08.28 diff --git a/container_shell/lib/dockage.py b/container_shell/lib/dockage.py index 301f21b..e13db0a 100644 --- a/container_shell/lib/dockage.py +++ b/container_shell/lib/dockage.py @@ -86,10 +86,11 @@ def mounts(mount_dict): """ the_mounts = [] for local_dir, container_dir in mount_dict.items(): - a_mount = docker.types.Mount(source=local_dir, - target=container_dir, - type='bind') - the_mounts.append(a_mount) + for mount_point in container_dir.split(','): + a_mount = docker.types.Mount(source=local_dir, + target=mount_point, + type='bind') + the_mounts.append(a_mount) return the_mounts #pylint: disable=R0913 diff --git a/sample.config.ini b/sample.config.ini index d763805..e6d547b 100644 --- a/sample.config.ini +++ b/sample.config.ini @@ -43,6 +43,9 @@ servers = 8.8.8.8,8.8.8.9 # containered environment. Omit this whole section to perform no host mounts. [mounts] /home=/home +# if you want the same host location mounted to multiple paths *inside* the +# host, seperaste those paths wtih a command like this +/some/host/path=/mnt/foo,/mnt/bar # Limit the resources a container can use. # Omit lines to put zero limits on that specific resource. diff --git a/tests/test_dockage.py b/tests/test_dockage.py index e3ce66e..ec42c8f 100644 --- a/tests/test_dockage.py +++ b/tests/test_dockage.py @@ -68,6 +68,15 @@ def test_objects(self): self.assertEqual(mount_obj, expected) + def test_multiple_mounts(self): + """``dockage`` 'mounts' parses a common, and mounts that path to multiple locations""" + mount_dict = {'/home': '/home/bob,/home/jill'} + + mount_objs = dockage.mounts(mount_dict) + expected = [docker.types.Mount(source='/home', target='/home/bob', type='bind'), + docker.types.Mount(source='/home', target='/home/jill', type='bind')] + + self.assertEqual(mount_objs, expected) class TestContainerCommand(unittest.TestCase): """A suite of test cases for the ``container_command`` function""" From 9d5c18ac9b2518de317f70de9bc436f816191f52 Mon Sep 17 00:00:00 2001 From: willnx Date: Wed, 28 Aug 2019 15:27:18 -0700 Subject: [PATCH 2/2] fixed grammer derp --- sample.config.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample.config.ini b/sample.config.ini index e6d547b..752e911 100644 --- a/sample.config.ini +++ b/sample.config.ini @@ -43,8 +43,8 @@ servers = 8.8.8.8,8.8.8.9 # containered environment. Omit this whole section to perform no host mounts. [mounts] /home=/home -# if you want the same host location mounted to multiple paths *inside* the -# host, seperaste those paths wtih a command like this +# If you want the same host location mounted to multiple paths *inside* the +# container, seperaste those paths wtih a command like this /some/host/path=/mnt/foo,/mnt/bar # Limit the resources a container can use.