1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-21 20:33:00 +00:00

"run_for_existing_project" -> "run_for_project"

This commit is contained in:
Jörn-Michael Miehe 2021-11-27 18:32:51 +01:00
parent 3e52ba6e12
commit 7afd540062
5 changed files with 11 additions and 11 deletions

View file

@ -122,17 +122,17 @@ class KiwiCommand:
def run_for_instance(cls, instance: Instance, **kwargs) -> None: def run_for_instance(cls, instance: Instance, **kwargs) -> None:
for project_config in instance.config.projects: for project_config in instance.config.projects:
project = instance.get_project(project_config.name) project = instance.get_project(project_config.name)
cls.run_for_existing_project(instance, project, **kwargs) cls.run_for_project(instance, project, **kwargs)
@classmethod
def run_for_project(cls, instance: Instance, project: Project, **kwargs) -> None:
service_names = [service.name for service in project.services.content]
cls.run_for_services(instance, project, service_names, **kwargs)
@classmethod @classmethod
def run_for_new_project(cls, instance: Instance, project_name: str, **kwargs) -> None: def run_for_new_project(cls, instance: Instance, project_name: str, **kwargs) -> None:
cls.print_error(f"Project '{project_name}' not in kiwi-scp instance at '{instance.directory}'!") cls.print_error(f"Project '{project_name}' not in kiwi-scp instance at '{instance.directory}'!")
@classmethod
def run_for_existing_project(cls, instance: Instance, project: Project, **kwargs) -> None:
service_names = [service.name for service in project.services.content]
cls.run_for_services(instance, project, service_names, **kwargs)
@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:
raise Exception raise Exception

View file

@ -28,7 +28,7 @@ class CmdCommand(KiwiCommand):
"""Run raw docker-compose command in a project""" """Run raw docker-compose command in a project"""
@classmethod @classmethod
def run_for_existing_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: 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)

View file

@ -36,7 +36,7 @@ class DownCommand(KiwiCommand):
# TODO net-down # TODO net-down
@classmethod @classmethod
def run_for_existing_project(cls, instance: Instance, project: Project, **kwargs) -> None: def run_for_project(cls, instance: Instance, project: Project, **kwargs) -> None:
COMPOSE_EXE.run(["down"], **project.process_kwargs) COMPOSE_EXE.run(["down"], **project.process_kwargs)
@classmethod @classmethod

View file

@ -33,7 +33,7 @@ class ListCommand(KiwiCommand):
) )
@classmethod @classmethod
def run_for_existing_project(cls, instance: Instance, project: Project, show: bool = None) -> None: def run_for_project(cls, instance: Instance, project: Project, show: bool = None) -> None:
if show: if show:
KiwiCommand.print_header(f"Showing config for all services in project '{project.name}'.") KiwiCommand.print_header(f"Showing config for all services in project '{project.name}'.")
click.echo_via_pager(str(project.services)) click.echo_via_pager(str(project.services))

View file

@ -53,7 +53,7 @@ def kiwi_command(
project = ctx.get_project(project_name) project = ctx.get_project(project_name)
if project is not None: if project is not None:
_logger.debug(f"running for existing project {project}, kwargs={kwargs}") _logger.debug(f"running for existing project {project}, kwargs={kwargs}")
command_cls.run_for_existing_project(ctx, project, **kwargs) command_cls.run_for_project(ctx, project, **kwargs)
else: else:
_logger.debug(f"running for new project {project_name}, kwargs={kwargs}") _logger.debug(f"running for new project {project_name}, kwargs={kwargs}")