"kiwi push", "kiwi pull" & "kiwi restart"
This commit is contained in:
parent
801f08137f
commit
1590041ab8
3 changed files with 114 additions and 0 deletions
33
kiwi_scp/commands/cmd_pull.py
Normal file
33
kiwi_scp/commands/cmd_pull.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
from .cmd import KiwiCommandType, KiwiCommand
|
||||||
|
from .decorators import kiwi_command
|
||||||
|
from ..executable import COMPOSE_EXE
|
||||||
|
from ..instance import Instance
|
||||||
|
from ..project import Project
|
||||||
|
from ..services import Services
|
||||||
|
|
||||||
|
|
||||||
|
@kiwi_command(
|
||||||
|
short_help="Pull docker images",
|
||||||
|
)
|
||||||
|
class PullCommand(KiwiCommand):
|
||||||
|
"""Pull images for 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"Pull images for the entire project {project.name} instead?",
|
||||||
|
default=True
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
|
COMPOSE_EXE.run(["pull", "--ignore-pull-failures", *services.names], **project.process_kwargs)
|
33
kiwi_scp/commands/cmd_push.py
Normal file
33
kiwi_scp/commands/cmd_push.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
from .cmd import KiwiCommandType, KiwiCommand
|
||||||
|
from .decorators import kiwi_command
|
||||||
|
from ..executable import COMPOSE_EXE
|
||||||
|
from ..instance import Instance
|
||||||
|
from ..project import Project
|
||||||
|
from ..services import Services
|
||||||
|
|
||||||
|
|
||||||
|
@kiwi_command(
|
||||||
|
short_help="Push docker images",
|
||||||
|
)
|
||||||
|
class PushCommand(KiwiCommand):
|
||||||
|
"""Push images for 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"Push images for the entire project {project.name} instead?",
|
||||||
|
default=True
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
|
COMPOSE_EXE.run(["push", *services.names], **project.process_kwargs)
|
48
kiwi_scp/commands/cmd_restart.py
Normal file
48
kiwi_scp/commands/cmd_restart.py
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
from .cmd import KiwiCommandType, KiwiCommand
|
||||||
|
from .decorators import kiwi_command
|
||||||
|
from ..executable import COMPOSE_EXE
|
||||||
|
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="Restart kiwi services",
|
||||||
|
)
|
||||||
|
class RestartCommand(KiwiCommand):
|
||||||
|
"""Restart 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:
|
||||||
|
if not KiwiCommand.danger_confirm(
|
||||||
|
"This will restart the entire instance.",
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
|
super().run_for_instance(instance)
|
||||||
|
|
||||||
|
@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"Restart the entire project {project.name} instead?",
|
||||||
|
default=True
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
|
COMPOSE_EXE.run(["restart", *services.names], **project.process_kwargs)
|
Loading…
Reference in a new issue