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