mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #40265 from terminalmage/issue40219
Fix two mod_aggregate bugs in pkg states
This commit is contained in:
commit
57ce474d73
1 changed files with 28 additions and 11 deletions
|
@ -2394,6 +2394,7 @@ def mod_aggregate(low, chunks, running):
|
|||
low chunks and merges them into a single pkgs ref in the present low data
|
||||
'''
|
||||
pkgs = []
|
||||
pkg_type = None
|
||||
agg_enabled = [
|
||||
'installed',
|
||||
'latest',
|
||||
|
@ -2413,18 +2414,34 @@ def mod_aggregate(low, chunks, running):
|
|||
# Check for the same function
|
||||
if chunk.get('fun') != low.get('fun'):
|
||||
continue
|
||||
# Pull out the pkg names!
|
||||
if 'pkgs' in chunk:
|
||||
pkgs.extend(chunk['pkgs'])
|
||||
chunk['__agg__'] = True
|
||||
elif 'name' in chunk:
|
||||
pkgs.append(chunk['name'])
|
||||
chunk['__agg__'] = True
|
||||
if pkgs:
|
||||
if 'pkgs' in low:
|
||||
low['pkgs'].extend(pkgs)
|
||||
# Check first if 'sources' was passed so we don't aggregate pkgs
|
||||
# and sources together.
|
||||
if 'sources' in chunk:
|
||||
if pkg_type is None:
|
||||
pkg_type = 'sources'
|
||||
if pkg_type == 'sources':
|
||||
pkgs.extend(chunk['sources'])
|
||||
chunk['__agg__'] = True
|
||||
else:
|
||||
if pkg_type is None:
|
||||
pkg_type = 'pkgs'
|
||||
if pkg_type == 'pkgs':
|
||||
# Pull out the pkg names!
|
||||
if 'pkgs' in chunk:
|
||||
pkgs.extend(chunk['pkgs'])
|
||||
chunk['__agg__'] = True
|
||||
elif 'name' in chunk:
|
||||
version = chunk.pop('version', None)
|
||||
if version is not None:
|
||||
pkgs.append({chunk['name']: version})
|
||||
else:
|
||||
pkgs.append(chunk['name'])
|
||||
chunk['__agg__'] = True
|
||||
if pkg_type is not None and pkgs:
|
||||
if pkg_type in low:
|
||||
low[pkg_type].extend(pkgs)
|
||||
else:
|
||||
low['pkgs'] = pkgs
|
||||
low[pkg_type] = pkgs
|
||||
return low
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue