diff --git a/src/etc/command_help.txt b/src/etc/command_help.txt index 51ae022..d730f3b 100644 --- a/src/etc/command_help.txt +++ b/src/etc/command_help.txt @@ -2,7 +2,6 @@ Commands for Operation: up Bring up the whole instance, a project or service(s) inside a project down Bring down the whole instance, a project or service(s) inside a project update Update the whole instance, a project or service(s) inside a project - clean Cleanly sync all configs to target folder, then relaunch affected projects purge Remove all running docker artifacts of this instance Commands for Instance Management: diff --git a/src/kiwi/subcommands/__init__.py b/src/kiwi/subcommands/__init__.py index 76ff7ab..aed1a90 100644 --- a/src/kiwi/subcommands/__init__.py +++ b/src/kiwi/subcommands/__init__.py @@ -1,8 +1,7 @@ # local -from ._hidden import ConfCopyCommand, ConfPurgeCommand, NetUpCommand +from ._hidden import ConfCopyCommand, NetUpCommand from .build import BuildCommand -from .clean import CleanCommand from .cmd import CmdCommand from .config import ConfigCommand from .disable import DisableCommand @@ -20,11 +19,9 @@ from .update import UpdateCommand __all__ = [ 'ConfCopyCommand', - 'ConfPurgeCommand', 'NetUpCommand', 'BuildCommand', - 'CleanCommand', 'CmdCommand', 'ConfigCommand', 'DisableCommand', diff --git a/src/kiwi/subcommands/_hidden.py b/src/kiwi/subcommands/_hidden.py index bd7bbc8..28ce50d 100644 --- a/src/kiwi/subcommands/_hidden.py +++ b/src/kiwi/subcommands/_hidden.py @@ -25,6 +25,7 @@ class ConfCopyCommand(SubCommand): conf_dirs = [ project.conf_dir_name() for project in Projects.from_dir().filter_enabled() + if project.has_configs() ] if conf_dirs: @@ -33,33 +34,12 @@ class ConfCopyCommand(SubCommand): logging.info(f"Sync directories: {conf_dirs}") Rootkit('rsync').run([ - 'rsync', '-r', *prefix_path_mnt(conf_dirs) + 'rsync', '-rpt', '--delete', *prefix_path_mnt(conf_dirs) ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) return True -class ConfPurgeCommand(SubCommand): - """kiwi conf-purge""" - - def __init__(self): - super().__init__( - 'conf-purge', - action="Removing all configs for", add_parser=False, - description="Remove all config files in target directory" - ) - - def _run_instance(self, runner, args): - conf_target = f"{LoadedConfig.get()['runtime:storage']}/{CONF_DIRECTORY_NAME}" - logging.info(f"Purging directories: {conf_target}") - - Rootkit().run([ - 'rm', '-rf', prefix_path_mnt(conf_target) - ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - - return True - - def _find_net(net_name): ps = Executable('docker').run([ 'network', 'ls', '--filter', f"name={net_name}", '--format', '{{.Name}}' diff --git a/src/kiwi/subcommands/clean.py b/src/kiwi/subcommands/clean.py deleted file mode 100644 index 22422e5..0000000 --- a/src/kiwi/subcommands/clean.py +++ /dev/null @@ -1,37 +0,0 @@ -from ..projects import Projects -from ..subcommand import SubCommand - - -class CleanCommand(SubCommand): - """kiwi clean""" - - def __init__(self): - super().__init__( - 'clean', - action="Cleaning all configs for", - description="Cleanly sync all configs to target folder, then relaunch affected projects" - ) - - def _run_instance(self, runner, args): - result = True - - affected_projects = [ - project.get_name() - for project in Projects.from_dir() - if project.has_configs() - ] - - for project_name in affected_projects: - args.projects = project_name - result &= runner.run('down') - - # cleanly sync configs - result &= runner.run('conf-purge') - result &= runner.run('conf-copy') - - # bring projects back up - for project_name in affected_projects: - args.projects = project_name - result &= runner.run('up') - - return result