From 268a945af8e3102d3b0cb27a6a8483739ec03321 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Wed, 17 Apr 2019 04:40:56 +0200 Subject: [PATCH] Bug: Ensure container properties are fetched safely --- restic_volume_backup/containers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py index 37726c8..09aa501 100644 --- a/restic_volume_backup/containers.py +++ b/restic_volume_backup/containers.py @@ -54,17 +54,17 @@ class Container: @property def service_name(self): """Name of the container/service""" - return self.labels['com.docker.compose.service'] + return self.labels.get('com.docker.compose.service', '') @property def project_name(self): """Name of the compose setup""" - return self.labels['com.docker.compose.project'] + return self.labels.get('com.docker.compose.project', {}) @property def is_oneoff(self): """Was this container started with run command?""" - return self.labels['com.docker.compose.oneoff'] == 'True' + return self.labels.get('com.docker.compose.oneoff', 'False') == 'True' def filter_mounts(self): """Get all mounts for this container matching include/exclude filters"""