diff options
| author | Aanand Prasad <aanand.prasad@gmail.com> | 2015-06-05 12:55:03 +0100 |
|---|---|---|
| committer | Aanand Prasad <aanand.prasad@gmail.com> | 2015-06-05 13:25:59 +0100 |
| commit | 7dd762539196eaade8da183d7588627c51d5a479 (patch) | |
| tree | 77aa3f6faf15e1a2c884383a823ad7f63d804d63 /docker/utils/utils.py | |
| parent | be73aaf5401faf5ca64911fb6664036c7b7ec61b (diff) | |
| download | docker-py-7dd762539196eaade8da183d7588627c51d5a479.tar.gz | |
Allow any mode string to be passed into a volume bind
Volume binds now take a "mode" key, whose value can be any string.
"ro" is still supported. It is an error to specify both "ro" and "mode".
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
Diffstat (limited to 'docker/utils/utils.py')
| -rw-r--r-- | docker/utils/utils.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py index e4a3c9e..54b01ce 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -177,8 +177,21 @@ def convert_volume_binds(binds): result = [] for k, v in binds.items(): if isinstance(v, dict): + if 'ro' in v and 'mode' in v: + raise ValueError( + 'Binding cannot contain both "ro" and "mode": {}' + .format(repr(v)) + ) + + if 'ro' in v: + mode = 'ro' if v['ro'] else 'rw' + elif 'mode' in v: + mode = v['mode'] + else: + mode = 'rw' + result.append('{0}:{1}:{2}'.format( - k, v['bind'], 'ro' if v.get('ro', False) else 'rw' + k, v['bind'], mode )) else: result.append('{0}:{1}:rw'.format(k, v)) |
