Add support for multiple config paths
Help messages mention support for multiple config paths separated by colons. Yet this feature is not implemented. This change implements it. Change-Id: Ieb99cba98c9cf775765eacd4ebadfbccfa815a65
This commit is contained in:
parent
3b01b4df7d
commit
0941f4e3b0
@ -44,13 +44,15 @@ class Builder(object):
|
||||
|
||||
def load_files(self, path):
|
||||
files_to_process = []
|
||||
if os.path.isdir(path):
|
||||
files_to_process.extend([os.path.join(path, f)
|
||||
for f in os.listdir(path)
|
||||
if (f.endswith('.yaml')
|
||||
or f.endswith('.yml'))])
|
||||
else:
|
||||
files_to_process.append(path)
|
||||
paths = path.split(':')
|
||||
for path in paths:
|
||||
if os.path.isdir(path):
|
||||
files_to_process.extend([os.path.join(path, f)
|
||||
for f in os.listdir(path)
|
||||
if (f.endswith('.yaml')
|
||||
or f.endswith('.yml'))])
|
||||
else:
|
||||
files_to_process.append(path)
|
||||
|
||||
for fn in files_to_process:
|
||||
self.parser.parse(fn)
|
||||
|
@ -71,6 +71,25 @@ class TestCaseValidate(TestCase):
|
||||
(stdout + stderr),
|
||||
matchers.MatchesRegex(r, re.DOTALL | re.MULTILINE))
|
||||
|
||||
def test_validate_mutiple_directories_success(self):
|
||||
paths = [
|
||||
os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
'../fixtures/cmd/validate/test0001'),
|
||||
os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
'../fixtures/cmd/validate/test0002'),
|
||||
]
|
||||
required = [
|
||||
'SUCCESS!',
|
||||
]
|
||||
stdout, stderr = self.shell(
|
||||
'validate %s' % ':'.join(paths), exitcodes=[0])
|
||||
for r in required:
|
||||
self.assertThat(
|
||||
(stdout + stderr),
|
||||
matchers.MatchesRegex(r, re.DOTALL | re.MULTILINE))
|
||||
|
||||
def test_validate_directory_invalid(self):
|
||||
path = os.path.join(
|
||||
os.path.dirname(__file__), '../fixtures/cmd/validate/__invalid__')
|
||||
|
2
tests/fixtures/cmd/validate/test0002/good-dashboard-0002.yaml
vendored
Normal file
2
tests/fixtures/cmd/validate/test0002/good-dashboard-0002.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
dashboard:
|
||||
title: New dashboard (2)
|
Loading…
x
Reference in New Issue
Block a user