mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-22 04:43:00 +00:00
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(
|
@kiwi_command(
|
||||||
cmd_type=KiwiCommandType.SERVICE,
|
|
||||||
short_help="Build docker images",
|
short_help="Build docker images",
|
||||||
)
|
)
|
||||||
class BuildCommand(KiwiCommand):
|
class BuildCommand(KiwiCommand):
|
||||||
"""Build images for the whole instance, a project or service(s) inside a project"""
|
"""Build images for the whole instance, a project or service(s) inside a project"""
|
||||||
|
|
||||||
|
type = KiwiCommandType.SERVICES
|
||||||
|
enabled_only = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_for_services(cls, instance: Instance, project: Project, service_names: List[str], **kwargs) -> None:
|
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)
|
COMPOSE_EXE.run(["build", "--pull", *service_names], **project.process_kwargs)
|
||||||
|
|
|
@ -18,7 +18,6 @@ from ..instance import Instance, Project
|
||||||
metavar="COMMAND",
|
metavar="COMMAND",
|
||||||
)
|
)
|
||||||
@kiwi_command(
|
@kiwi_command(
|
||||||
cmd_type=KiwiCommandType.PROJECT,
|
|
||||||
short_help="Run docker-compose command",
|
short_help="Run docker-compose command",
|
||||||
# ignore arguments looking like options
|
# ignore arguments looking like options
|
||||||
# just pass everything down to docker-compose
|
# just pass everything down to docker-compose
|
||||||
|
@ -27,8 +26,10 @@ from ..instance import Instance, Project
|
||||||
class CmdCommand(KiwiCommand):
|
class CmdCommand(KiwiCommand):
|
||||||
"""Run raw docker-compose command in a project"""
|
"""Run raw docker-compose command in a project"""
|
||||||
|
|
||||||
|
type = KiwiCommandType.PROJECT
|
||||||
|
enabled_only = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_for_project(cls, instance: Instance, project: Project, compose_cmd: str = None,
|
def run_for_project(cls, instance: Instance, project: Project, compose_cmd: str = None,
|
||||||
compose_args: Tuple[str] = None) -> 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",
|
"--force/--no-force",
|
||||||
help=f"skip confirmation",
|
help=f"skip confirmation",
|
||||||
)
|
)
|
||||||
@kiwi_command(
|
@kiwi_command()
|
||||||
cmd_type=KiwiCommandType.PROJECT,
|
|
||||||
)
|
|
||||||
class DisableCommand(KiwiCommand):
|
class DisableCommand(KiwiCommand):
|
||||||
"""Disable a project"""
|
"""Disable project(s)"""
|
||||||
|
|
||||||
|
type = KiwiCommandType.PROJECTS
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_for_instance(cls, instance: Instance, force: bool = None) -> None:
|
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",
|
help=f"skip confirmation",
|
||||||
)
|
)
|
||||||
@kiwi_command(
|
@kiwi_command(
|
||||||
cmd_type=KiwiCommandType.SERVICE,
|
|
||||||
short_help="Bring down kiwi services",
|
short_help="Bring down kiwi services",
|
||||||
)
|
)
|
||||||
class DownCommand(KiwiCommand):
|
class DownCommand(KiwiCommand):
|
||||||
"""Bring down the whole instance, a project or service(s) inside a project"""
|
"""Bring down the whole instance, a project or service(s) inside a project"""
|
||||||
|
|
||||||
|
type = KiwiCommandType.SERVICES
|
||||||
|
enabled_only = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_for_instance(cls, instance: Instance, force: bool = None) -> None:
|
def run_for_instance(cls, instance: Instance, force: bool = None) -> None:
|
||||||
if not force:
|
if not force:
|
||||||
|
|
|
@ -11,11 +11,11 @@ from ..instance import Instance, Project
|
||||||
"--force/--no-force",
|
"--force/--no-force",
|
||||||
help=f"skip confirmation",
|
help=f"skip confirmation",
|
||||||
)
|
)
|
||||||
@kiwi_command(
|
@kiwi_command()
|
||||||
cmd_type=KiwiCommandType.PROJECT,
|
|
||||||
)
|
|
||||||
class DisableCommand(KiwiCommand):
|
class DisableCommand(KiwiCommand):
|
||||||
"""Enable a project"""
|
"""Enable project(s)"""
|
||||||
|
|
||||||
|
type = KiwiCommandType.PROJECTS
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_for_instance(cls, instance: Instance, force: bool = None) -> None:
|
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",
|
help=f"use default values even if {KIWI_CONF_NAME} is present",
|
||||||
)
|
)
|
||||||
@kiwi_command(
|
@kiwi_command(
|
||||||
cmd_type=KiwiCommandType.INSTANCE,
|
|
||||||
short_help="Initializes kiwi-scp",
|
short_help="Initializes kiwi-scp",
|
||||||
)
|
)
|
||||||
class InitCommand(KiwiCommand):
|
class InitCommand(KiwiCommand):
|
||||||
"""Initialize or reconfigure a kiwi-scp instance"""
|
"""Initialize or reconfigure a kiwi-scp instance"""
|
||||||
|
|
||||||
|
type = KiwiCommandType.INSTANCE
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_for_instance(cls, instance: Instance, directory: Path = None, force: bool = None) -> None:
|
def run_for_instance(cls, instance: Instance, directory: Path = None, force: bool = None) -> None:
|
||||||
if directory is not None:
|
if directory is not None:
|
||||||
|
|
|
@ -13,12 +13,13 @@ from ..instance import Instance, Project
|
||||||
help=f"show actual config contents instead",
|
help=f"show actual config contents instead",
|
||||||
)
|
)
|
||||||
@kiwi_command(
|
@kiwi_command(
|
||||||
cmd_type=KiwiCommandType.SERVICE,
|
|
||||||
short_help="Inspect a kiwi-scp instance",
|
short_help="Inspect a kiwi-scp instance",
|
||||||
)
|
)
|
||||||
class ListCommand(KiwiCommand):
|
class ListCommand(KiwiCommand):
|
||||||
"""List projects in this instance, services inside a project or service(s) inside a project"""
|
"""List projects in this instance, services inside a project or service(s) inside a project"""
|
||||||
|
|
||||||
|
type = KiwiCommandType.SERVICES
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_for_instance(cls, instance: Instance, show: bool = None) -> None:
|
def run_for_instance(cls, instance: Instance, show: bool = None) -> None:
|
||||||
if show:
|
if show:
|
||||||
|
@ -43,7 +44,8 @@ class ListCommand(KiwiCommand):
|
||||||
KiwiCommand.print_list(service.name for service in project.services.content)
|
KiwiCommand.print_list(service.name for service in project.services.content)
|
||||||
|
|
||||||
@classmethod
|
@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)
|
services = project.services.filter_existing(service_names)
|
||||||
if show:
|
if show:
|
||||||
service_names = [service.name for service in services.content]
|
service_names = [service.name for service in services.content]
|
||||||
|
|
|
@ -8,13 +8,13 @@ from ..executable import COMPOSE_EXE
|
||||||
from ..instance import Instance, Project, Services
|
from ..instance import Instance, Project, Services
|
||||||
|
|
||||||
|
|
||||||
@kiwi_command(
|
@kiwi_command(short_help="Bring up kiwi services")
|
||||||
cmd_type=KiwiCommandType.SERVICE,
|
|
||||||
short_help="Bring up kiwi services",
|
|
||||||
)
|
|
||||||
class UpCommand(KiwiCommand):
|
class UpCommand(KiwiCommand):
|
||||||
"""Bring up the whole instance, a project or service(s) inside a project"""
|
"""Bring up the whole instance, a project or service(s) inside a project"""
|
||||||
|
|
||||||
|
type = KiwiCommandType.SERVICES
|
||||||
|
enabled_only = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_for_filtered_services(cls, instance: Instance, project: Project, services: Services,
|
def run_for_filtered_services(cls, instance: Instance, project: Project, services: Services,
|
||||||
new_service_names: List[str], **kwargs) -> None:
|
new_service_names: List[str], **kwargs) -> None:
|
||||||
|
|
Loading…
Reference in a new issue