mirror of
https://github.com/ZettaIO/restic-compose-backup.git
synced 2025-09-28 14:45:23 +00:00
Allow overriding container env vars
This commit is contained in:
@@ -63,7 +63,7 @@ class Container:
|
||||
@property
|
||||
def environment(self) -> list:
|
||||
"""All configured env vars for the container as a list"""
|
||||
return self.get_config('Env', default=[])
|
||||
return self.get_config('Env')
|
||||
|
||||
def get_config_env(self, name) -> str:
|
||||
"""Get a config environment variable by name"""
|
||||
@@ -71,6 +71,17 @@ class Container:
|
||||
data = {i[0:i.find('=')]: i[i.find('=')+1:] for i in self.environment}
|
||||
return data.get(name)
|
||||
|
||||
def set_config_env(self, name, value):
|
||||
"""Set an environment variable"""
|
||||
env = self.environment
|
||||
new_value = f'{name}={value}'
|
||||
for i, entry in enumerate(env):
|
||||
if f'{name}=' in entry:
|
||||
env[i] = new_value
|
||||
break
|
||||
else:
|
||||
env.append(new_value)
|
||||
|
||||
@property
|
||||
def volumes(self) -> dict:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user