d-utils

simple utils to use docker images without docker
git clone https://git.ce9e.org/d-utils.git

commit
08994c5a59559274c37963a967804ed8ae7eb079
parent
2262ab97547b4c3ac71c44d8de9d1786d4345d60
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2022-10-27 18:53
validate volume mode

Diffstat

M d-run 9 ++++++---

1 files changed, 6 insertions, 3 deletions


diff --git a/d-run b/d-run

@@ -13,11 +13,14 @@ def make_volume(path, dir):
   13    13 		os.makedirs(hostpath, exist_ok=True)
   14    14 
   15    15 	if ':' in path:
   16    -1 		path, option = path.rsplit(':', 1)
   -1    16 		path, mode = path.rsplit(':', 1)
   17    17 	else:
   18    -1 		option = 'rw'
   -1    18 		mode = 'rw'
   19    19 
   20    -1 	op = '--ro-bind' if option == 'ro' else '--bind'
   -1    20 	if mode not in ['ro', 'rw']:
   -1    21 		raise ValueError(f'Invalid volume mode: {mode}')
   -1    22 
   -1    23 	op = '--ro-bind' if mode == 'ro' else '--bind'
   21    24 
   22    25 	return [op, hostpath, path]
   23    26