diff --git a/kiwi_scp/subcommands/purge.py b/kiwi_scp/subcommands/purge.py deleted file mode 100644 index 86cd372..0000000 --- a/kiwi_scp/subcommands/purge.py +++ /dev/null @@ -1,45 +0,0 @@ -# system -import logging -import subprocess - -# local -from ._hidden import _find_net -from ..config import LoadedConfig -from ..executable import Executable -from ..misc import are_you_sure -from ..subcommand import SubCommand - - -class PurgeCommand(SubCommand): - """kiwi purge""" - - def __init__(self): - super().__init__( - 'purge', - action="Tearing down", - description="Remove all running docker artifacts of this instance" - ) - - def _run_instance(self, runner, args): - net_name = LoadedConfig.get()['network:name'] - - if not _find_net(net_name): - logging.info(f"Network '{net_name}' does not exist") - return True - - try: - if are_you_sure("This will bring down this instance's hub network!"): - if runner.run('down'): - Executable('docker').run([ - 'network', 'rm', net_name - ], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - - logging.info(f"Network '{net_name}' removed") - else: - return False - - except subprocess.CalledProcessError: - logging.error(f"Error removing network '{net_name}'") - return False - - return True diff --git a/kiwi_scp/subcommands/update.py b/kiwi_scp/subcommands/update.py deleted file mode 100644 index 35bc6dd..0000000 --- a/kiwi_scp/subcommands/update.py +++ /dev/null @@ -1,37 +0,0 @@ -# local -from ..misc import are_you_sure -from ..subcommand import ServiceCommand - - -class UpdateCommand(ServiceCommand): - """kiwi update""" - - def __init__(self): - super().__init__( - 'update', num_projects='?', num_services='*', - action="Updating", - description="Update the whole instance, a project or service(s) inside a project" - ) - - def _run_instance(self, runner, args): - if are_you_sure([ - "This will update the entire instance at once.", - "", - "This is probably not what you intended, because:", - " - Updates may take a long time", - " - Updates may break beloved functionality", - ]): - return super()._run_instance(runner, args) - - return False - - def _run_services(self, runner, args, project, services): - result = True - - result &= runner.run('build') - result &= runner.run('pull') - result &= runner.run('conf-copy') - result &= runner.run('down') - result &= runner.run('up') - - return result