Add environement target in image name
Image name were named exactly the same no matter which environement/section we were running. We now have : _dox/$project_name_$environment_(base|test) as image name, the _dox and not dox is cause docker wants a namespace with at least three chars. Change-Id: I3ea05c0907fb911aaca96a18215c5a44ce2a6ebc
This commit is contained in:
parent
9f33ae5252
commit
2997c592e7
11
dox/cmd.py
11
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)
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue