kiwi-scp/src/kiwi/subcommands/up.py

33 lines
910 B
Python
Raw Normal View History

2020-08-17 12:12:33 +00:00
# system
import logging
# local
2020-08-18 11:50:21 +00:00
from ._subcommand import FlexCommand
2020-08-17 12:12:33 +00:00
from .utils.dockercommand import DockerCommand
2020-08-17 12:51:43 +00:00
from .utils.project import get_project_name, list_projects
2020-08-17 12:12:33 +00:00
2020-08-18 11:50:21 +00:00
class UpCommand(FlexCommand):
2020-08-17 12:12:33 +00:00
"""kiwi up"""
def __init__(self):
super().__init__(
2020-08-18 11:50:21 +00:00
'up', description="Bring up the whole instance, a project or service(s) inside a project"
2020-08-17 12:12:33 +00:00
)
2020-08-18 11:50:21 +00:00
def _run_project(self, runner, config, args):
logging.info(f"Bringing up project '{get_project_name(args)}'")
2020-08-17 12:12:33 +00:00
2020-08-18 11:50:21 +00:00
DockerCommand('docker-compose').run(
config, args, ['up', '-d']
)
return True
2020-08-17 12:51:43 +00:00
2020-08-18 11:50:21 +00:00
def _run_services(self, runner, config, args):
logging.info(f"Bringing up services {args.services} in project '{get_project_name(args)}'")
2020-08-17 13:00:05 +00:00
2020-08-18 11:50:21 +00:00
DockerCommand('docker-compose').run(
config, args, ['up', '-d', *args.services]
)
return True