None will not be added to grains which generate [none]

This commit is contained in:
Hengyang Hu 2016-08-11 16:20:37 -07:00
parent c032506e6b
commit a23108f795

View File

@ -335,8 +335,9 @@ def append(key, val, convert=False, delimiter=DEFAULT_TARGET_DELIM):
salt '*' grains.append key val
'''
grains = get(key, [], delimiter)
if not isinstance(grains, list) and convert is True:
grains = [grains]
if convert:
if not isinstance(grains, list):
grains = [] if grains is None else [grains]
if not isinstance(grains, list):
return 'The key {0} is not a valid list'.format(key)
if val in grains: