Instantiate Config instance instead of using class namespace
This commit is contained in:
parent
2884fc1eec
commit
167fc4e214
|
@ -7,9 +7,7 @@ from restic_volume_backup.containers import RunningContainers
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
config = Config()
|
||||||
Config.check()
|
|
||||||
|
|
||||||
containers = RunningContainers()
|
containers = RunningContainers()
|
||||||
|
|
||||||
if args.action == 'status':
|
if args.action == 'status':
|
||||||
|
@ -33,7 +31,7 @@ def main():
|
||||||
# restic.backup_volume(Config.repository, vol)
|
# restic.backup_volume(Config.repository, vol)
|
||||||
|
|
||||||
elif args.mode == 'snapshots':
|
elif args.mode == 'snapshots':
|
||||||
restic.snapshots(Config.repository)
|
restic.snapshots(config.repository)
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
|
|
|
@ -2,14 +2,15 @@ import os
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
repository = os.environ['RESTIC_REPOSITORY']
|
def __init__(self):
|
||||||
password = os.environ['RESTIC_PASSWORD']
|
self.repository = os.environ['RESTIC_REPOSITORY']
|
||||||
docker_base_url = os.environ.get('DOCKER_BASE_URL') or "unix://tmp/docker.sock"
|
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(self):
|
||||||
def check(cls):
|
if not self.repository:
|
||||||
if not cls.repository:
|
|
||||||
raise ValueError("CONTAINER env var not set")
|
raise ValueError("CONTAINER env var not set")
|
||||||
|
|
||||||
if not cls.password:
|
if not self.password:
|
||||||
raise ValueError("PASSWORD env var not set")
|
raise ValueError("PASSWORD env var not set")
|
||||||
|
|
Loading…
Reference in New Issue