mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Only merge when the merge is of requisites
Fix for #24770 This extends functionality is used for both requisites and extending SLSs, so instead of having a hard coded list of requisites we should use the global of all state requisite keywords.
This commit is contained in:
parent
5fe4de8f62
commit
378f6bfc36
1 changed files with 9 additions and 17 deletions
|
@ -1188,32 +1188,24 @@ class State(object):
|
|||
for arg in run:
|
||||
update = False
|
||||
for hind in range(len(high[name][state])):
|
||||
if (isinstance(arg, string_types) and
|
||||
isinstance(high[name][state][hind], string_types)):
|
||||
if isinstance(arg, string_types) and isinstance(high[name][state][hind], string_types):
|
||||
# replacing the function, replace the index
|
||||
high[name][state].pop(hind)
|
||||
high[name][state].insert(hind, arg)
|
||||
update = True
|
||||
continue
|
||||
if (isinstance(arg, dict) and
|
||||
isinstance(high[name][state][hind], dict)):
|
||||
if isinstance(arg, dict) and isinstance(high[name][state][hind], dict):
|
||||
# It is an option, make sure the options match
|
||||
argfirst = next(iter(arg))
|
||||
if (argfirst ==
|
||||
next(iter(high[name][state][hind]))):
|
||||
# They match, check if the option is a
|
||||
# watch or require, append, otherwise
|
||||
# replace
|
||||
if (argfirst == 'require' or
|
||||
argfirst == 'watch'):
|
||||
# Extend the list
|
||||
(high[name][state][hind][argfirst]
|
||||
.extend(arg[argfirst]))
|
||||
update = True
|
||||
if argfirst == next(iter(high[name][state][hind])):
|
||||
# If argfirst is a requisite then we must merge
|
||||
# our requisite with that of the target state
|
||||
if argfirst in STATE_REQUISITE_KEYWORDS:
|
||||
high[name][state][hind][argfirst].extend(arg[argfirst])
|
||||
# otherwise, its not a requisite and we are just extending (replacing)
|
||||
else:
|
||||
# Replace the value
|
||||
high[name][state][hind] = arg
|
||||
update = True
|
||||
update = True
|
||||
if (argfirst == 'name' and
|
||||
next(iter(high[name][state][hind])) == 'names'):
|
||||
# If names are overwritten by name use the name
|
||||
|
|
Loading…
Add table
Reference in a new issue