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():
|
||||
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():
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue