As per new command API
This commit is contained in:
parent
3cdc68885c
commit
d197398c3b
8 changed files with 28 additions and 20 deletions
|
@ -7,12 +7,14 @@ from ..instance import Instance, Project
|
|||
|
||||
|
||||
@kiwi_command(
|
||||
cmd_type=KiwiCommandType.SERVICE,
|
||||
short_help="Build docker images",
|
||||
)
|
||||
class BuildCommand(KiwiCommand):
|
||||
"""Build images for the whole instance, a project or service(s) inside a project"""
|
||||
|
||||
type = KiwiCommandType.SERVICES
|
||||
enabled_only = True
|
||||
|
||||
@classmethod
|
||||
def run_for_services(cls, instance: Instance, project: Project, service_names: List[str], **kwargs) -> None:
|
||||
COMPOSE_EXE.run(["build", "--pull", *service_names], **project.process_kwargs)
|
||||
|
|
|
@ -18,7 +18,6 @@ from ..instance import Instance, Project
|
|||
metavar="COMMAND",
|
||||
)
|
||||
@kiwi_command(
|
||||
cmd_type=KiwiCommandType.PROJECT,
|
||||
short_help="Run docker-compose command",
|
||||
# ignore arguments looking like options
|
||||
# just pass everything down to docker-compose
|
||||
|
@ -27,8 +26,10 @@ from ..instance import Instance, Project
|
|||
class CmdCommand(KiwiCommand):
|
||||
"""Run raw docker-compose command in a project"""
|
||||
|
||||
type = KiwiCommandType.PROJECT
|
||||
enabled_only = True
|
||||
|
||||
@classmethod
|
||||
def run_for_project(cls, instance: Instance, project: Project, compose_cmd: str = None,
|
||||
compose_args: Tuple[str] = None) -> None:
|
||||
if project.project_config.enabled:
|
||||
COMPOSE_EXE.run([compose_cmd, *compose_args], **project.process_kwargs)
|
||||
COMPOSE_EXE.run([compose_cmd, *compose_args], **project.process_kwargs)
|
||||
|
|
|
@ -11,11 +11,11 @@ from ..instance import Instance, Project
|
|||
"--force/--no-force",
|
||||
help=f"skip confirmation",
|
||||
)
|
||||
@kiwi_command(
|
||||
cmd_type=KiwiCommandType.PROJECT,
|
||||
)
|
||||
@kiwi_command()
|
||||
class DisableCommand(KiwiCommand):
|
||||
"""Disable a project"""
|
||||
"""Disable project(s)"""
|
||||
|
||||
type = KiwiCommandType.PROJECTS
|
||||
|
||||
@classmethod
|
||||
def run_for_instance(cls, instance: Instance, force: bool = None) -> None:
|
||||
|
|
|
@ -14,12 +14,14 @@ from ..instance import Instance, Project, Services
|
|||
help=f"skip confirmation",
|
||||
)
|
||||
@kiwi_command(
|
||||
cmd_type=KiwiCommandType.SERVICE,
|
||||
short_help="Bring down kiwi services",
|
||||
)
|
||||
class DownCommand(KiwiCommand):
|
||||
"""Bring down the whole instance, a project or service(s) inside a project"""
|
||||
|
||||
type = KiwiCommandType.SERVICES
|
||||
enabled_only = True
|
||||
|
||||
@classmethod
|
||||
def run_for_instance(cls, instance: Instance, force: bool = None) -> None:
|
||||
if not force:
|
||||
|
|
|
@ -11,11 +11,11 @@ from ..instance import Instance, Project
|
|||
"--force/--no-force",
|
||||
help=f"skip confirmation",
|
||||
)
|
||||
@kiwi_command(
|
||||
cmd_type=KiwiCommandType.PROJECT,
|
||||
)
|
||||
@kiwi_command()
|
||||
class DisableCommand(KiwiCommand):
|
||||
"""Enable a project"""
|
||||
"""Enable project(s)"""
|
||||
|
||||
type = KiwiCommandType.PROJECTS
|
||||
|
||||
@classmethod
|
||||
def run_for_instance(cls, instance: Instance, force: bool = None) -> None:
|
||||
|
|
|
@ -30,12 +30,13 @@ _logger = logging.getLogger(__name__)
|
|||
help=f"use default values even if {KIWI_CONF_NAME} is present",
|
||||
)
|
||||
@kiwi_command(
|
||||
cmd_type=KiwiCommandType.INSTANCE,
|
||||
short_help="Initializes kiwi-scp",
|
||||
)
|
||||
class InitCommand(KiwiCommand):
|
||||
"""Initialize or reconfigure a kiwi-scp instance"""
|
||||
|
||||
type = KiwiCommandType.INSTANCE
|
||||
|
||||
@classmethod
|
||||
def run_for_instance(cls, instance: Instance, directory: Path = None, force: bool = None) -> None:
|
||||
if directory is not None:
|
||||
|
|
|
@ -13,12 +13,13 @@ from ..instance import Instance, Project
|
|||
help=f"show actual config contents instead",
|
||||
)
|
||||
@kiwi_command(
|
||||
cmd_type=KiwiCommandType.SERVICE,
|
||||
short_help="Inspect a kiwi-scp instance",
|
||||
)
|
||||
class ListCommand(KiwiCommand):
|
||||
"""List projects in this instance, services inside a project or service(s) inside a project"""
|
||||
|
||||
type = KiwiCommandType.SERVICES
|
||||
|
||||
@classmethod
|
||||
def run_for_instance(cls, instance: Instance, show: bool = None) -> None:
|
||||
if show:
|
||||
|
@ -43,7 +44,8 @@ class ListCommand(KiwiCommand):
|
|||
KiwiCommand.print_list(service.name for service in project.services.content)
|
||||
|
||||
@classmethod
|
||||
def run_for_services(cls, instance: Instance, project: Project, service_names: List[str], show: bool = None) -> None:
|
||||
def run_for_services(cls, instance: Instance, project: Project, service_names: List[str],
|
||||
show: bool = None) -> None:
|
||||
services = project.services.filter_existing(service_names)
|
||||
if show:
|
||||
service_names = [service.name for service in services.content]
|
||||
|
|
|
@ -8,13 +8,13 @@ from ..executable import COMPOSE_EXE
|
|||
from ..instance import Instance, Project, Services
|
||||
|
||||
|
||||
@kiwi_command(
|
||||
cmd_type=KiwiCommandType.SERVICE,
|
||||
short_help="Bring up kiwi services",
|
||||
)
|
||||
@kiwi_command(short_help="Bring up kiwi services")
|
||||
class UpCommand(KiwiCommand):
|
||||
"""Bring up the whole instance, a project or service(s) inside a project"""
|
||||
|
||||
type = KiwiCommandType.SERVICES
|
||||
enabled_only = True
|
||||
|
||||
@classmethod
|
||||
def run_for_filtered_services(cls, instance: Instance, project: Project, services: Services,
|
||||
new_service_names: List[str], **kwargs) -> None:
|
||||
|
|
Loading…
Reference in a new issue