Split cli commands into functions
This commit is contained in:
parent
15c91d5970
commit
c37435ea34
|
@ -13,6 +13,25 @@ def main():
|
|||
containers = RunningContainers()
|
||||
|
||||
if args.action == 'status':
|
||||
status(config, containers)
|
||||
|
||||
elif args.action == 'backup':
|
||||
backup(config, containers)
|
||||
|
||||
# Separate command to avoid spawning infinite containers :)
|
||||
elif args.action == 'start-backup-process':
|
||||
start_backup_process(config, containers)
|
||||
|
||||
|
||||
def start_backup_process(config, containers):
|
||||
"""Start the backup process container"""
|
||||
print("start-backup-process")
|
||||
import os
|
||||
print(os.environ)
|
||||
|
||||
|
||||
def status(config, containers):
|
||||
"""Outputs the backup config for the compse setup"""
|
||||
print()
|
||||
print("Backup config for compose project '{}'".format(containers.this_container.project_name))
|
||||
print()
|
||||
|
@ -24,7 +43,9 @@ def main():
|
|||
|
||||
print()
|
||||
|
||||
elif args.action == 'backup':
|
||||
|
||||
def backup(config, containers):
|
||||
"""Start backup"""
|
||||
# Make sure we don't spawn multiple backup processes
|
||||
if containers.backup_process_running:
|
||||
raise ValueError("Backup process already running")
|
||||
|
@ -43,12 +64,6 @@ def main():
|
|||
labels={"restic-volume-backup.backup_process": 'True'},
|
||||
)
|
||||
|
||||
# Separate command to avoid spawning infinite containers :)
|
||||
elif args.action == 'start-backup-process':
|
||||
print("start-backup-process")
|
||||
import os
|
||||
print(os.environ)
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(prog='restic_volume_backup')
|
||||
|
|
Loading…
Reference in New Issue