restic-compose-backup/restic_volume_backup/config.py

20 lines
543 B
Python
Raw Normal View History

2019-04-15 15:25:42 +00:00
import os
class Config:
2019-11-15 13:23:56 +00:00
"""Bag for config values"""
2019-04-16 16:21:42 +00:00
def __init__(self, check=True):
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"
2019-11-12 11:39:49 +00:00
2019-04-16 16:21:42 +00:00
if check:
self.check()
2019-04-15 15:25:42 +00:00
def check(self):
if not self.repository:
2019-04-15 15:25:42 +00:00
raise ValueError("CONTAINER env var not set")
if not self.password:
2019-04-15 15:25:42 +00:00
raise ValueError("PASSWORD env var not set")