diff --git a/restic_volume_backup/cli.py b/restic_volume_backup/cli.py index 0cc2a73..d9be495 100644 --- a/restic_volume_backup/cli.py +++ b/restic_volume_backup/cli.py @@ -7,9 +7,7 @@ from restic_volume_backup.containers import RunningContainers def main(): args = parse_args() - - Config.check() - + config = Config() containers = RunningContainers() if args.action == 'status': @@ -33,7 +31,7 @@ def main(): # restic.backup_volume(Config.repository, vol) elif args.mode == 'snapshots': - restic.snapshots(Config.repository) + restic.snapshots(config.repository) def parse_args(): diff --git a/restic_volume_backup/config.py b/restic_volume_backup/config.py index e26ed6c..8ef4214 100644 --- a/restic_volume_backup/config.py +++ b/restic_volume_backup/config.py @@ -2,14 +2,15 @@ import os class Config: - repository = os.environ['RESTIC_REPOSITORY'] - password = os.environ['RESTIC_PASSWORD'] - docker_base_url = os.environ.get('DOCKER_BASE_URL') or "unix://tmp/docker.sock" + def __init__(self): + self.repository = os.environ['RESTIC_REPOSITORY'] + self.password = os.environ['RESTIC_PASSWORD'] + self.docker_base_url = os.environ.get('DOCKER_BASE_URL') or "unix://tmp/docker.sock" + self.check() - @classmethod - def check(cls): - if not cls.repository: + def check(self): + if not self.repository: raise ValueError("CONTAINER env var not set") - if not cls.password: + if not self.password: raise ValueError("PASSWORD env var not set")