Merge "Allow running multiple target with -e"
This commit is contained in:
commit
a550f76774
7
dox.yml
7
dox.yml
|
@ -20,3 +20,10 @@ pep8:
|
|||
- pip install -U -r requirements.txt -r test-requirements.txt
|
||||
commands:
|
||||
- flake8
|
||||
|
||||
nulltest:
|
||||
images:
|
||||
- busybox:latest
|
||||
|
||||
commands:
|
||||
- /bin/echo "hello"
|
||||
|
|
58
dox/cmd.py
58
dox/cmd.py
|
@ -85,32 +85,13 @@ def parse_args():
|
|||
|
||||
|
||||
def main():
|
||||
|
||||
args = parse_args()
|
||||
setup_logging(get_log_level(args))
|
||||
|
||||
return run_dox(args)
|
||||
return runner(args)
|
||||
|
||||
|
||||
def run_dox(args):
|
||||
if not dox.runner.Runner(args).is_docker_installed():
|
||||
sys.exit(1)
|
||||
|
||||
options = {'section': args.environment}
|
||||
|
||||
# Get Image
|
||||
if args.images is None:
|
||||
images = dox.images.get_images(options)
|
||||
else:
|
||||
images = args.images.split(',')
|
||||
|
||||
# Get Command
|
||||
if args.command:
|
||||
command = dox.config.cmdline.CommandLine(args.extra_args)
|
||||
logger.debug("Command source is the command line")
|
||||
else:
|
||||
command = dox.commands.Commands(args.extra_args, options)
|
||||
logger.debug("Command source is %s" % command.source.source_name())
|
||||
def run_dox(args, images, command):
|
||||
# Run
|
||||
try:
|
||||
run = functools.partial(dox.runner.Runner(args).run,
|
||||
|
@ -119,3 +100,38 @@ def run_dox(args):
|
|||
except Exception:
|
||||
logger.error("Operation failed, aborting dox.", exc_info=args.debug)
|
||||
return 1
|
||||
|
||||
|
||||
def runner(args):
|
||||
options = {}
|
||||
args_images = None
|
||||
|
||||
if not dox.runner.Runner(args).is_docker_installed():
|
||||
sys.exit(1)
|
||||
|
||||
# Get Image
|
||||
if args.images:
|
||||
args_images = args.images.split(',')
|
||||
|
||||
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)
|
||||
|
||||
if args.environment:
|
||||
sections = args.environment.split(',')
|
||||
else:
|
||||
sections = ['_default']
|
||||
|
||||
for section in sections:
|
||||
options['section'] = section
|
||||
|
||||
if args_images:
|
||||
images = args_images
|
||||
else:
|
||||
images = dox.images.get_images(options)
|
||||
|
||||
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)
|
||||
|
|
|
@ -45,9 +45,11 @@ class DoxYaml(base.ConfigBase):
|
|||
default_keys_of_section = ['images', 'commands', 'add', 'prep']
|
||||
|
||||
def get_section(self, yaml, section):
|
||||
if section == '_default':
|
||||
section = self.default_section
|
||||
|
||||
# NOTE(chmou): This is for compatibility mode with dox.yml with no
|
||||
# sections, probably need to be removed in the future
|
||||
|
||||
if (section is None and
|
||||
(all(i in yaml.keys() for i in self.default_keys_of_section)
|
||||
or all(i in self.default_keys_of_section
|
||||
|
|
|
@ -66,6 +66,10 @@ class ToxIni(base.ConfigBase):
|
|||
"""
|
||||
section = self.options.get('section',
|
||||
self.default_section)
|
||||
|
||||
if section == '_default':
|
||||
section = self.default_section
|
||||
|
||||
ini = self._open_tox_ini()
|
||||
commands = ini.get(section, 'commands').split("\n")
|
||||
extra_args = " ".join(extra_args)
|
||||
|
|
Loading…
Reference in New Issue