From 18d7cd6ab7d387a7f83dc54b35f32c4474703329 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Tue, 23 Apr 2024 05:03:30 +0000 Subject: [PATCH] Support krmignore in diagnostics --- .krmignore | 1 + flux_local/tool/diagnostics.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.krmignore b/.krmignore index 463fc778..a01426f8 100644 --- a/.krmignore +++ b/.krmignore @@ -1,2 +1,3 @@ +.git local-charts tests/testdata/cluster9/local-charts diff --git a/flux_local/tool/diagnostics.py b/flux_local/tool/diagnostics.py index 68f3cee3..eccc7150 100644 --- a/flux_local/tool/diagnostics.py +++ b/flux_local/tool/diagnostics.py @@ -47,8 +47,22 @@ async def run( # type: ignore[no-untyped-def] """Async Action implementation.""" path = kwargs.get("path") or "." + # Parse directories to ignore from `.krmignore` + krmignore = pathlib.Path(path) / ".krmignore" + ignoredirs = [] + if krmignore.exists(): + with krmignore.open() as fd: + ignoredirs = [ + str(pathlib.Path(line.strip())) for line in fd.readlines() + ] + errors = [] for root, dirs, files in os.walk(str(path)): + # Ignore any directories that we should not walk + rootpath = str(pathlib.Path(root)) + if any([rootpath.startswith(i) for i in ignoredirs]): + continue + for file in files: if not (file.endswith(".yaml") or file.endswith(".yml")): continue