From 558726f2618c463e35d85ea62a3e34403be33159 Mon Sep 17 00:00:00 2001 From: ldericher <40151420+ldericher@users.noreply.github.com> Date: Wed, 19 Jan 2022 12:03:42 +0100 Subject: [PATCH] "kiwi update" --- kiwi_scp/commands/cmd_update.py | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 kiwi_scp/commands/cmd_update.py diff --git a/kiwi_scp/commands/cmd_update.py b/kiwi_scp/commands/cmd_update.py new file mode 100644 index 0000000..1330ca5 --- /dev/null +++ b/kiwi_scp/commands/cmd_update.py @@ -0,0 +1,48 @@ +from typing import List + +import click +from click import get_current_context + +from .cmd import KiwiCommandType, KiwiCommand +from .decorators import kiwi_command +from ..instance import Instance +from ..project import Project +from ..services import Services + + +@click.option( + "-f/-F", + "--force/--no-force", + help=f"skip confirmation", +) +@kiwi_command( + short_help="Update kiwi services", +) +class UpdateCommand(KiwiCommand): + """Update 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: + if not services: + if not click.confirm( + "Did not find any of those services. \n" + f"Update the entire project {project.name} instead?", + default=True + ): + return + + from .cmd_build import BuildCommand + from .cmd_down import DownCommand + from .cmd_pull import PullCommand + from .cmd_up import UpCommand + + ctx = get_current_context() + ctx.forward(BuildCommand) + ctx.forward(PullCommand) + # TODO conf-copy + ctx.forward(DownCommand) + ctx.forward(UpCommand)