mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-12-25 18:42:59 +00:00
return values
This commit is contained in:
parent
2acbc1c534
commit
11dafb0db6
9 changed files with 42 additions and 19 deletions
|
@ -36,13 +36,14 @@ class Runner:
|
|||
logging.debug(f"Running '{cmd}' with args: {args}")
|
||||
|
||||
try:
|
||||
cmd.run(self, LoadedConfig.get(), args)
|
||||
result = cmd.run(self, LoadedConfig.get(), args)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print()
|
||||
logging.warning(f"'{cmd}' aborted, inputs may have been discarded.")
|
||||
result = False
|
||||
|
||||
return True
|
||||
return result
|
||||
|
||||
# command not found
|
||||
logging.error(f"kiwi command '{command}' unknown")
|
||||
|
|
|
@ -23,3 +23,5 @@ class CmdCommand(ProjectCommand):
|
|||
|
||||
# run with split compose_cmd argument
|
||||
DockerCommand('docker-compose').run(config, args, shlex.split(args.compose_cmd))
|
||||
|
||||
return True
|
||||
|
|
|
@ -24,9 +24,10 @@ class DownCommand(ServiceCommand):
|
|||
for project_name in list_projects(config):
|
||||
args.projects = project_name
|
||||
runner.run('down')
|
||||
return
|
||||
else:
|
||||
return False
|
||||
|
||||
if 'services' in args and args.services:
|
||||
elif 'services' in args and args.services:
|
||||
# "down" for service(s) inside project
|
||||
logging.info(f"Bringing down services {args.services} in project '{get_project_name(args)}'")
|
||||
|
||||
|
@ -44,3 +45,5 @@ class DownCommand(ServiceCommand):
|
|||
DockerCommand('docker-compose').run(
|
||||
config, args, ['down']
|
||||
)
|
||||
|
||||
return True
|
||||
|
|
|
@ -65,3 +65,4 @@ class InitCommand(SubCommand):
|
|||
user_input(config, 'network:cidr', "Enter CIDR block for local docker network")
|
||||
|
||||
config.save()
|
||||
return True
|
||||
|
|
|
@ -35,3 +35,5 @@ class LogsCommand(ServiceCommand):
|
|||
DockerCommand('docker-compose').run(config, args, compose_cmd)
|
||||
else:
|
||||
DockerCommand('docker-compose').run_less(config, args, compose_cmd)
|
||||
|
||||
return True
|
||||
|
|
|
@ -31,7 +31,7 @@ class NetUpCommand(SubCommand):
|
|||
def run(self, runner, config, args):
|
||||
if _find_net(config, args):
|
||||
logging.info(f"Network '{config['network:name']}' already exists")
|
||||
return
|
||||
return True
|
||||
|
||||
try:
|
||||
DockerCommand('docker').run(
|
||||
|
@ -49,6 +49,9 @@ class NetUpCommand(SubCommand):
|
|||
|
||||
except subprocess.CalledProcessError:
|
||||
logging.error(f"Error creating network '{config['network:name']}'")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class NetDownCommand(SubCommand):
|
||||
|
@ -63,18 +66,22 @@ class NetDownCommand(SubCommand):
|
|||
def run(self, runner, config, args):
|
||||
if not _find_net(config, args):
|
||||
logging.info(f"Network '{config['network:name']}' already removed")
|
||||
return
|
||||
return True
|
||||
|
||||
try:
|
||||
if are_you_sure("This will bring down this instance's hub network!"):
|
||||
runner.run('down')
|
||||
|
||||
DockerCommand('docker').run(
|
||||
config, args,
|
||||
['network', 'rm', config['network:name']],
|
||||
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
||||
)
|
||||
logging.info(f"Network '{config['network:name']}' removed")
|
||||
if runner.run('down'):
|
||||
DockerCommand('docker').run(
|
||||
config, args,
|
||||
['network', 'rm', config['network:name']],
|
||||
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
||||
)
|
||||
logging.info(f"Network '{config['network:name']}' removed")
|
||||
else:
|
||||
return False
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
logging.error(f"Error removing network '{config['network:name']}'")
|
||||
logging.error(f"Error removing network '{config['network:name']}'")
|
||||
return False
|
||||
|
||||
return True
|
|
@ -91,3 +91,6 @@ class ShCommand(ServiceCommand):
|
|||
DockerCommand('docker-compose').run(
|
||||
config, args, [*compose_cmd, shell]
|
||||
)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
|
@ -13,3 +13,4 @@ class ShowCommand(SubCommand):
|
|||
|
||||
def run(self, runner, config, args):
|
||||
print(config)
|
||||
return True
|
||||
|
|
|
@ -30,7 +30,10 @@ class UpCommand(ServiceCommand):
|
|||
else:
|
||||
logging.info(f"Bringing up project '{get_project_name(args)}'")
|
||||
|
||||
runner.run('net-up')
|
||||
DockerCommand('docker-compose').run(
|
||||
config, args, ['up', '-d', *args.services]
|
||||
)
|
||||
if runner.run('net-up'):
|
||||
DockerCommand('docker-compose').run(
|
||||
config, args, ['up', '-d', *args.services]
|
||||
)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue