From 679a47e4fa17a96d44bc7579cd82d449ab309d0e Mon Sep 17 00:00:00 2001 From: ldericher Date: Tue, 18 Aug 2020 14:37:07 +0200 Subject: [PATCH] subcommands "build", "pull", "update" --- src/kiwi/subcommands/__init__.py | 6 ++++++ src/kiwi/subcommands/build.py | 19 +++++++++++++++++++ src/kiwi/subcommands/pull.py | 19 +++++++++++++++++++ src/kiwi/subcommands/update.py | 21 +++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 src/kiwi/subcommands/build.py create mode 100644 src/kiwi/subcommands/pull.py create mode 100644 src/kiwi/subcommands/update.py diff --git a/src/kiwi/subcommands/__init__.py b/src/kiwi/subcommands/__init__.py index 6b37a7e..11e6dfc 100644 --- a/src/kiwi/subcommands/__init__.py +++ b/src/kiwi/subcommands/__init__.py @@ -1,15 +1,19 @@ # local +from .build import BuildCommand from .cmd import CmdCommand from .conf import ConfCopyCommand, ConfPurgeCommand from .down import DownCommand from .init import InitCommand from .logs import LogsCommand from .net import NetUpCommand, NetDownCommand +from .pull import PullCommand from .sh import ShCommand from .show import ShowCommand from .up import UpCommand +from .update import UpdateCommand __all__ = [ + 'BuildCommand', 'CmdCommand', 'ConfCopyCommand', 'ConfPurgeCommand', @@ -18,7 +22,9 @@ __all__ = [ 'LogsCommand', 'NetUpCommand', 'NetDownCommand', + 'PullCommand', 'ShCommand', 'ShowCommand', 'UpCommand', + 'UpdateCommand', ] diff --git a/src/kiwi/subcommands/build.py b/src/kiwi/subcommands/build.py new file mode 100644 index 0000000..bc13757 --- /dev/null +++ b/src/kiwi/subcommands/build.py @@ -0,0 +1,19 @@ +# local +from ._subcommand import FlexCommand +from .utils.dockercommand import DockerCommand + + +class BuildCommand(FlexCommand): + """kiwi build""" + + def __init__(self): + super().__init__( + 'build', "Building images", + description="Build images for the whole instance, a project or service(s) inside a project" + ) + + def _run_services(self, runner, config, args, services): + DockerCommand('docker-compose').run( + config, args, ['build', '--pull', *services] + ) + return True diff --git a/src/kiwi/subcommands/pull.py b/src/kiwi/subcommands/pull.py new file mode 100644 index 0000000..3497517 --- /dev/null +++ b/src/kiwi/subcommands/pull.py @@ -0,0 +1,19 @@ +# local +from ._subcommand import FlexCommand +from .utils.dockercommand import DockerCommand + + +class PullCommand(FlexCommand): + """kiwi pull""" + + def __init__(self): + super().__init__( + 'pull', "Pulling images", + description="Pull images for the whole instance, a project or service(s) inside a project" + ) + + def _run_services(self, runner, config, args, services): + DockerCommand('docker-compose').run( + config, args, ['pull', '--ignore-pull-failures', *services] + ) + return True diff --git a/src/kiwi/subcommands/update.py b/src/kiwi/subcommands/update.py new file mode 100644 index 0000000..045c192 --- /dev/null +++ b/src/kiwi/subcommands/update.py @@ -0,0 +1,21 @@ +# local +from ._subcommand import FlexCommand + + +class UpdateCommand(FlexCommand): + """kiwi update""" + + def __init__(self): + super().__init__( + 'update', "Updating", + description="Update the whole instance, a project or service(s) inside a project" + ) + + def _run_services(self, runner, config, args, services): + result = runner.run('build') + result &= runner.run('pull') + result &= runner.run('conf-copy') + result &= runner.run('down') + result &= runner.run('up') + + return result