From 0f67d336a4fa8101ed00beb00ad683df84976fe4 Mon Sep 17 00:00:00 2001 From: sandanilenko Date: Mon, 21 May 2018 18:04:24 +0700 Subject: [PATCH 1/2] Fix bug where environment variable contain space. For example "ES_JAVA_OPTS=-Xms512m -Xmx512m" --- fabricio/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fabricio/utils.py b/fabricio/utils.py index 202ff05..c9b2b1f 100644 --- a/fabricio/utils.py +++ b/fabricio/utils.py @@ -47,9 +47,15 @@ def __call__(self, func): class Options(collections.OrderedDict): def make_option(self, option, value=None): - option = '--' + option + option = ''.join(['--', option]) if value is not None: - option += '=' + shlex_quote(six.text_type(value)) + if isinstance(value, str) and '=' in value: + param = value.split('=', 1) + option = ''.join([ + option, '=', shlex_quote(six.text_type(param[0])), '=', + shlex_quote(six.text_type(param[1]))]) + else: + option = ''.join([option, '=', shlex_quote(six.text_type(value))]) return option def make_options(self): From 97343df412cbdedf1b7ed23b099df430c0a308b2 Mon Sep 17 00:00:00 2001 From: sandanilenko Date: Tue, 22 May 2018 00:06:57 +0700 Subject: [PATCH 2/2] fix bug with using ulimit --- fabricio/docker/container.py | 1 + fabricio/utils.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fabricio/docker/container.py b/fabricio/docker/container.py index 84f4d75..701369b 100644 --- a/fabricio/docker/container.py +++ b/fabricio/docker/container.py @@ -32,6 +32,7 @@ class Container(BaseService): network = Option(name='net', safe=True) restart = Option() stop_signal = Option(name='stop-signal', safe=True) + ulimit = Option(safe=True) @utils.default_property def info(self): diff --git a/fabricio/utils.py b/fabricio/utils.py index c9b2b1f..a2e80c6 100644 --- a/fabricio/utils.py +++ b/fabricio/utils.py @@ -49,11 +49,16 @@ class Options(collections.OrderedDict): def make_option(self, option, value=None): option = ''.join(['--', option]) if value is not None: - if isinstance(value, str) and '=' in value: + if isinstance(value, str) and option == '--env': param = value.split('=', 1) option = ''.join([ option, '=', shlex_quote(six.text_type(param[0])), '=', shlex_quote(six.text_type(param[1]))]) + elif isinstance(value, str) and option == '--ulimit': + param = value.split('=', 1) + option = '{} {}={}'.format( + option, shlex_quote(six.text_type(param[0])), + shlex_quote(six.text_type(param[1]))) else: option = ''.join([option, '=', shlex_quote(six.text_type(value))]) return option