From ce50a1ff0ee3207ca446219acbab9b42b1e7c170 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Thu, 18 Apr 2019 04:26:30 +0200 Subject: [PATCH] Support getting configured container env vars --- restic_volume_backup/containers.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py index 117cacc..4cad45d 100644 --- a/restic_volume_backup/containers.py +++ b/restic_volume_backup/containers.py @@ -38,6 +38,11 @@ class Container: """Image name""" return self.get_config('Image') + @property + def environment(self): + """All configured env vars for the container""" + return self.get_config('Env', default={}) + @property def backup_enabled(self) -> bool: """Is backup enabled for this container?""" @@ -68,9 +73,9 @@ class Container: """Was this container started with run command?""" return self.get_label('com.docker.compose.oneoff', default='False') == 'True' - def get_config(self, name): + def get_config(self, name, default=None): """Get value from config dict""" - return self._config.get(name) + return self._config.get(name, default) def get_label(self, name, default=None): """Get a label by name"""