diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py index b792ad8..16c3e65 100644 --- a/restic_volume_backup/containers.py +++ b/restic_volume_backup/containers.py @@ -13,7 +13,6 @@ class Container: def __init__(self, data: dict): self._data = data self.id = data['Id'] - self.name = data['Name'].replace('/', '') self._state = data.get('State') self._config = data.get('Config') @@ -87,6 +86,11 @@ class Container: """Is the container running?""" return self._state.get('Running', False) + @property + def name(self) -> str: + """Container name""" + return self._data['Name'].replace('/', '') + @property def service_name(self) -> str: """Name of the container/service""" @@ -169,6 +173,12 @@ class Container: return self.id == other.id + def __repr__(self): + return str(self) + + def __str__(self): + return "".format(self.name) + class Mount: """Represents a volume mount (volume or bind)"""