From e7eedc1afec38615c1e28fda6a9eae6f85fc166e Mon Sep 17 00:00:00 2001 From: Borne Mace Date: Tue, 1 May 2018 14:22:58 -0700 Subject: [PATCH] Support updates of None type properties There was an issue where None type properties could not be changed to empty string type properties because safe_load would turn an empty string into a None. Change-Id: I64b031c8aa1423ed0d23218832e4dcb391fd3ab5 --- kolla_cli/api/properties.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kolla_cli/api/properties.py b/kolla_cli/api/properties.py index 1a480f9..2bebb61 100644 --- a/kolla_cli/api/properties.py +++ b/kolla_cli/api/properties.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. import logging +import six import yaml import kolla_cli.i18n as u @@ -52,7 +53,16 @@ class PropertyApi(object): if current_property is not None: current_property_type = current_property.value_type if current_property_type is not str: + original_value = value value = yaml.safe_load(value) + + # this check is to make sure that we can assign an empty + # string to a property. without this safe_load will turn + # an empty string into a None which is different than an + # empty string. + if isinstance(original_value, six.string_types)\ + and value is None: + value = '' if current_property.value is None: current_property_type = None check_arg(value, u._('Property Value'),