Support getting configured container env vars

This commit is contained in:
Einar Forselv 2019-04-18 04:26:30 +02:00
parent f67e9968f5
commit ce50a1ff0e
1 changed files with 7 additions and 2 deletions

View File

@ -38,6 +38,11 @@ class Container:
"""Image name""" """Image name"""
return self.get_config('Image') return self.get_config('Image')
@property
def environment(self):
"""All configured env vars for the container"""
return self.get_config('Env', default={})
@property @property
def backup_enabled(self) -> bool: def backup_enabled(self) -> bool:
"""Is backup enabled for this container?""" """Is backup enabled for this container?"""
@ -68,9 +73,9 @@ class Container:
"""Was this container started with run command?""" """Was this container started with run command?"""
return self.get_label('com.docker.compose.oneoff', default='False') == 'True' 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""" """Get value from config dict"""
return self._config.get(name) return self._config.get(name, default)
def get_label(self, name, default=None): def get_label(self, name, default=None):
"""Get a label by name""" """Get a label by name"""