From 58b3220a2e2185faaa0659a857fafa3beed05e75 Mon Sep 17 00:00:00 2001
From: Einar Forselv <eforselv@gmail.com>
Date: Thu, 18 Apr 2019 04:43:42 +0200
Subject: [PATCH] Support generating volume list in create/run format

---
 restic_volume_backup/containers.py | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py
index 4cad45d..126bdbd 100644
--- a/restic_volume_backup/containers.py
+++ b/restic_volume_backup/containers.py
@@ -41,7 +41,25 @@ class Container:
     @property
     def environment(self):
         """All configured env vars for the container"""
-        return self.get_config('Env', default={})
+        return self.get_config('Env', default=[])
+
+    @property
+    def volumes(self):
+        """
+        Return volumes for the container in the following format:
+            {'/home/user1/': {'bind': '/mnt/vol2', 'mode': 'rw'},}
+        """
+        # {'Type': 'bind', 
+        #  'Source': '/Users/einarforselv/Documents/projects/contraz/restic-volume-backup',
+        #  'Destination': '/restic-volume-backup',
+        #  'Mode': 'rw',
+        #  'RW': True,
+        #  'Propagation': 'rprivate'}
+        volumes = {}
+        for mount in self._mounts:
+            volumes[mount.source] = {'bind': mount.destination, 'mode': 'ro'}
+
+        return volumes
 
     @property
     def backup_enabled(self) -> bool: