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
This commit is contained in:
Borne Mace 2018-05-01 14:22:58 -07:00
parent a0441f7455
commit e7eedc1afe
1 changed files with 10 additions and 0 deletions

View File

@ -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'),