mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Merge pull request #40168 from fungus/patch-1
Support for default item in match.filter_by
This commit is contained in:
commit
233e0e8cfc
@ -309,7 +309,8 @@ def glob(tgt, minion_id=None):
|
||||
def filter_by(lookup,
|
||||
tgt_type='compound',
|
||||
minion_id=None,
|
||||
expr_form=None):
|
||||
expr_form=None,
|
||||
default='default'):
|
||||
'''
|
||||
Return the first match in a dictionary of target patterns
|
||||
|
||||
@ -329,7 +330,7 @@ def filter_by(lookup,
|
||||
{% set roles = salt['match.filter_by']({
|
||||
'web*': ['app', 'caching'],
|
||||
'db*': ['db'],
|
||||
}) %}
|
||||
}, default='web*') %}
|
||||
|
||||
# Make the filtered data available to Pillar:
|
||||
roles: {{ roles | yaml() }}
|
||||
@ -353,7 +354,7 @@ def filter_by(lookup,
|
||||
if expr_funcs[tgt_type](*params):
|
||||
return lookup[key]
|
||||
|
||||
return None
|
||||
return lookup.get(default, None)
|
||||
|
||||
|
||||
def search_by(lookup, tgt_type='compound', minion_id=None):
|
||||
|
Loading…
Reference in New Issue
Block a user