mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Allow listing a single module in a top match
This makes the following valid syntax for the top.sls file: base: tommy.example.com: webserver jerry.example.com: dbserver alberon.example.com: mailserver develop: saturn.example.com: webserver
This commit is contained in:
parent
12b4bf1619
commit
7fd85c2963
@ -1829,6 +1829,8 @@ class BaseHighState(object):
|
|||||||
if env != self.opts['environment']:
|
if env != self.opts['environment']:
|
||||||
continue
|
continue
|
||||||
for match, data in body.items():
|
for match, data in body.items():
|
||||||
|
if isinstance(data, string_types):
|
||||||
|
data = [data]
|
||||||
if self.matcher.confirm_top(
|
if self.matcher.confirm_top(
|
||||||
match,
|
match,
|
||||||
data,
|
data,
|
||||||
|
41
tests/unit/highstateconf_test.py
Normal file
41
tests/unit/highstateconf_test.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Import Salt Testing libs
|
||||||
|
from salttesting import TestCase
|
||||||
|
from salttesting.helpers import ensure_in_syspath
|
||||||
|
|
||||||
|
ensure_in_syspath('../')
|
||||||
|
ensure_in_syspath('../../')
|
||||||
|
|
||||||
|
# Import Salt libs
|
||||||
|
import salt.config
|
||||||
|
from salt.state import HighState
|
||||||
|
|
||||||
|
|
||||||
|
OPTS = salt.config.minion_config(None, check_dns=False)
|
||||||
|
OPTS['id'] = 'match'
|
||||||
|
OPTS['file_client'] = 'local'
|
||||||
|
OPTS['file_roots'] = dict(base=['/tmp'])
|
||||||
|
OPTS['test'] = False
|
||||||
|
OPTS['grains'] = salt.loader.grains(OPTS)
|
||||||
|
|
||||||
|
|
||||||
|
class HighStateTestCase(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.highstate = HighState(OPTS)
|
||||||
|
self.highstate.push_active()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.highstate.pop_active()
|
||||||
|
|
||||||
|
def test_top_matches_with_list(self):
|
||||||
|
top = {'env': {'match': ['state1', 'state2'], 'nomatch': ['state3']}}
|
||||||
|
matches = self.highstate.top_matches(top)
|
||||||
|
self.assertEqual(matches, {'env': ['state1', 'state2']})
|
||||||
|
|
||||||
|
def test_top_matches_with_string(self):
|
||||||
|
top = {'env': {'match': 'state1', 'nomatch': 'state2'}}
|
||||||
|
matches = self.highstate.top_matches(top)
|
||||||
|
self.assertEqual(matches, {'env': ['state1']})
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
from integration import run_tests
|
||||||
|
run_tests(HighStateTestCase, needs_daemon=False)
|
Loading…
Reference in New Issue
Block a user