kiwi-scp/kiwi_scp/commands/cmd_up.py

35 lines
1.1 KiB
Python
Raw Normal View History

2021-11-27 17:13:31 +00:00
from typing import List
import click
2021-12-02 16:19:14 +00:00
from .cmd import KiwiCommandType, KiwiCommand
2021-11-27 17:13:31 +00:00
from .decorators import kiwi_command
from ..executable import COMPOSE_EXE
2021-12-02 16:08:14 +00:00
from ..instance import Instance
from ..project import Project
from ..services import Services
2021-11-27 17:13:31 +00:00
2021-12-01 16:49:19 +00:00
@kiwi_command(short_help="Bring up kiwi services")
2021-11-27 17:13:31 +00:00
class UpCommand(KiwiCommand):
"""Bring up the whole instance, a project or service(s) inside a project"""
2021-12-01 16:49:19 +00:00
type = KiwiCommandType.SERVICES
enabled_only = True
2021-11-27 17:13:31 +00:00
@classmethod
2021-11-27 17:33:46 +00:00
def run_for_filtered_services(cls, instance: Instance, project: Project, services: Services,
new_service_names: List[str], **kwargs) -> None:
if not services:
2021-11-27 17:13:31 +00:00
if not click.confirm(
"Did not find any of those services. \n"
f"Bring up the entire project {project.name} instead?",
default=True
):
return
2022-02-21 15:42:12 +00:00
instance.create_net()
services.copy_configs()
2021-11-27 17:33:46 +00:00
COMPOSE_EXE.run(["up", "-d", *services.names], **project.process_kwargs)