Add alternative fix for "!" stomping

Apparently (after watching Jenkins tests fail), what yaml.safe_load returns
depends not on the version of salt, but on some other external dependency.
Because of this, fix both possible return values.
This commit is contained in:
Herbert Buurman 2019-08-16 12:28:02 +02:00
parent c95dd4d70f
commit 93bd30df0e
No known key found for this signature in database
GPG key ID: 0C63558B62EB59BE

View file

@ -200,13 +200,16 @@ def yamlify_arg(arg):
elif arg is None \
or isinstance(arg, (list, float, six.integer_types, six.string_types)):
# yaml.safe_load will load '|' as '', don't let it do that.
# yaml.safe_load will load '|' and '!' as '', don't let it do that.
if arg == '' and original_arg in ('|', '!'):
return original_arg
# yaml.safe_load will treat '#' as a comment, so a value of '#'
# will become None. Keep this value from being stomped as well.
elif arg is None and original_arg.strip().startswith('#'):
return original_arg
# Other times, yaml.safe_load will load '!' as None. Prevent that.
elif arg is None and original_arg == '!':
return original_arg
else:
return arg
else: