diff --git a/dox/cmd.py b/dox/cmd.py index ac52aad..fb2cd05 100644 --- a/dox/cmd.py +++ b/dox/cmd.py @@ -91,10 +91,10 @@ def main(): return runner(args) -def run_dox(args, images, command): +def run_dox(args, images, command, image_name): # Run try: - run = functools.partial(dox.runner.Runner(args).run, + run = functools.partial(dox.runner.Runner(args, image_name).run, command=command) map(run, images) except Exception: @@ -116,7 +116,7 @@ def runner(args): if args.command: command = dox.config.cmdline.CommandLine(args.extra_args) logger.debug("Command source is the command line") - return run_dox(args, args_images, command) + return run_dox(args, args_images, command, image_name="commandline") if args.environment: sections = args.environment.split(',') @@ -134,4 +134,7 @@ def runner(args): command = dox.commands.Commands(args.extra_args, options) logger.debug("Command source is %s, section %s" % ( command.source.source_name(), section)) - run_dox(args, images, command) + + # TODO(chmouel): add to section a proper image_name that include the + # type of backend i.e: dox_yaml/tox_init + run_dox(args, images, command, image_name=section) diff --git a/dox/runner.py b/dox/runner.py index 0a5eba2..a01b91e 100644 --- a/dox/runner.py +++ b/dox/runner.py @@ -32,11 +32,14 @@ logger = logging.getLogger(__name__) class Runner(object): - def __init__(self, args): + def __init__(self, args, image_name=None): + image_name = image_name and "_" + image_name or "" self.args = args self.project = os.path.basename(os.path.abspath('.')) - self.base_image_name = 'dox_%s_base' % self.project - self.test_image_name = 'dox_%s_test' % self.project + self.base_image_name = '_dox/%s%s_base' % (self.project, + image_name) + self.test_image_name = '_dox/%s%s_test' % (self.project, + image_name) self.user_map = self._get_user_mapping() self.path_map = self._get_path_mapping() diff --git a/dox/tests/test_cmd.py b/dox/tests/test_cmd.py index 1ce54a0..a1fe653 100644 --- a/dox/tests/test_cmd.py +++ b/dox/tests/test_cmd.py @@ -76,5 +76,5 @@ class TestCmd(base.TestCase): @mock.patch('dox.runner.Runner') def test_run_dox(self, m_runner): - dox.cmd.run_dox(default_argp, ['1', '2', '3'], '/bin/echo') + dox.cmd.run_dox(default_argp, ['1', '2', '3'], '/bin/echo', "name") self.assertEqual(1, m_runner.call_count)