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:
parent
a0441f7455
commit
e7eedc1afe
|
@ -12,6 +12,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import logging
|
import logging
|
||||||
|
import six
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import kolla_cli.i18n as u
|
import kolla_cli.i18n as u
|
||||||
|
@ -52,7 +53,16 @@ class PropertyApi(object):
|
||||||
if current_property is not None:
|
if current_property is not None:
|
||||||
current_property_type = current_property.value_type
|
current_property_type = current_property.value_type
|
||||||
if current_property_type is not str:
|
if current_property_type is not str:
|
||||||
|
original_value = value
|
||||||
value = yaml.safe_load(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:
|
if current_property.value is None:
|
||||||
current_property_type = None
|
current_property_type = None
|
||||||
check_arg(value, u._('Property Value'),
|
check_arg(value, u._('Property Value'),
|
||||||
|
|
Loading…
Reference in New Issue