Ignore secrets.yaml when using include_dir_named (#22929)

* ignore secrets.yaml in include_dir_named include

* updating test for include_dir_named secrets ignore
This commit is contained in:
choss 2019-04-14 06:24:06 +02:00 committed by Paulus Schoutsen
parent c6bc47b32d
commit c314220167
2 changed files with 3 additions and 1 deletions

View File

@ -157,6 +157,8 @@ def _include_dir_named_yaml(loader: SafeLineLoader,
loc = os.path.join(os.path.dirname(loader.name), node.value)
for fname in _find_files(loc, '*.yaml'):
filename = os.path.splitext(os.path.basename(fname))[0]
if os.path.basename(fname) == SECRET_YAML:
continue
mapping[filename] = load_yaml(fname)
return _add_reference(mapping, loader, node)

View File

@ -134,7 +134,7 @@ class TestYaml(unittest.TestCase):
def test_include_dir_named(self, mock_walk):
"""Test include dir named yaml."""
mock_walk.return_value = [
['/tmp', [], ['first.yaml', 'second.yaml']]
['/tmp', [], ['first.yaml', 'second.yaml', 'secrets.yaml']]
]
with patch_yaml_files({