subcommand "conf-clean"
This commit is contained in:
parent
f9cb784760
commit
b3456f8ec3
2 changed files with 39 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
# local
|
# local
|
||||||
from .build import BuildCommand
|
from .build import BuildCommand
|
||||||
from .cmd import CmdCommand
|
from .cmd import CmdCommand
|
||||||
from .conf import ConfCopyCommand, ConfPurgeCommand
|
from .conf import ConfCopyCommand, ConfPurgeCommand, ConfCleanCommand
|
||||||
from .disable import DisableCommand
|
from .disable import DisableCommand
|
||||||
from .down import DownCommand
|
from .down import DownCommand
|
||||||
from .enable import EnableCommand
|
from .enable import EnableCommand
|
||||||
|
@ -22,6 +22,7 @@ __all__ = [
|
||||||
'CmdCommand',
|
'CmdCommand',
|
||||||
'ConfCopyCommand',
|
'ConfCopyCommand',
|
||||||
'ConfPurgeCommand',
|
'ConfPurgeCommand',
|
||||||
|
'ConfCleanCommand',
|
||||||
'DisableCommand',
|
'DisableCommand',
|
||||||
'DownCommand',
|
'DownCommand',
|
||||||
'EnableCommand',
|
'EnableCommand',
|
||||||
|
|
|
@ -62,3 +62,40 @@ class ConfPurgeCommand(SubCommand):
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class ConfCleanCommand(SubCommand):
|
||||||
|
"""kiwi conf-clean"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(
|
||||||
|
'conf-clean',
|
||||||
|
description="Cleanly sync all configs to target folder, relaunch affected projects"
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self, runner, config, args):
|
||||||
|
result = True
|
||||||
|
|
||||||
|
# down all projects with config directories
|
||||||
|
affected_projects = []
|
||||||
|
|
||||||
|
for project_name in list_projects(config):
|
||||||
|
project_conf = f"{get_project_dir(config, project_name)}/{CONF_DIRECTORY_NAME}"
|
||||||
|
|
||||||
|
if os.path.isdir(project_conf):
|
||||||
|
affected_projects.append(project_name)
|
||||||
|
|
||||||
|
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-purge')
|
||||||
|
|
||||||
|
# bring projects back up
|
||||||
|
for project_name in affected_projects:
|
||||||
|
args.projects = project_name
|
||||||
|
result &= runner.run('up')
|
||||||
|
|
||||||
|
return result
|
Loading…
Reference in a new issue