diff --git a/grafana_dashboards/builder.py b/grafana_dashboards/builder.py index 3db6998..66b9655 100644 --- a/grafana_dashboards/builder.py +++ b/grafana_dashboards/builder.py @@ -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) diff --git a/tests/cmd/test_validate.py b/tests/cmd/test_validate.py index 1d5f133..a76af05 100644 --- a/tests/cmd/test_validate.py +++ b/tests/cmd/test_validate.py @@ -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__') diff --git a/tests/fixtures/cmd/validate/test0002/good-dashboard-0002.yaml b/tests/fixtures/cmd/validate/test0002/good-dashboard-0002.yaml new file mode 100644 index 0000000..dcc11de --- /dev/null +++ b/tests/fixtures/cmd/validate/test0002/good-dashboard-0002.yaml @@ -0,0 +1,2 @@ +dashboard: + title: New dashboard (2)