From f0e7b3e1ff903ad58a9815c254ddd51f95d7a03e Mon Sep 17 00:00:00 2001 From: Priyanshi Khetwani Date: Mon, 3 Feb 2025 00:25:27 +0530 Subject: [PATCH] replace walk with walkdir --- config/tests/lint/config_lint_test.go | 5 ++++- experiment/bumpmonitoring/main.go | 5 ++++- kubetest/dump_test.go | 2 +- kubetest/e2e/runner.go | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config/tests/lint/config_lint_test.go b/config/tests/lint/config_lint_test.go index 218c5f23b7d4..eee9d34492dc 100644 --- a/config/tests/lint/config_lint_test.go +++ b/config/tests/lint/config_lint_test.go @@ -33,7 +33,10 @@ func Test_ForbidYmlExtension(t *testing.T) { for _, path := range exemptPaths { exempt[filepath.Join(configPath, path)] = true } - err := filepath.Walk(configPath, func(path string, info os.FileInfo, err error) error { + err := filepath.WalkDir(configPath, func(path string, info os.DirEntry, err error) error { + if err != nil { + return err + } if _, ok := exempt[path]; ok { return filepath.SkipDir } diff --git a/experiment/bumpmonitoring/main.go b/experiment/bumpmonitoring/main.go index e5fdca0762b6..4686c5307392 100644 --- a/experiment/bumpmonitoring/main.go +++ b/experiment/bumpmonitoring/main.go @@ -147,7 +147,10 @@ func (c *client) findConfigToUpdate() error { } // No error is expected - filepath.Walk(fullPath, func(leafPath string, info os.FileInfo, err error) error { + filepath.WalkDir(fullPath, func(leafPath string, info os.DirEntry, err error) error { + if err != nil { + return err + } if !re.MatchString(leafPath) { return nil } diff --git a/kubetest/dump_test.go b/kubetest/dump_test.go index 581b5517f708..9fe07b720cf3 100644 --- a/kubetest/dump_test.go +++ b/kubetest/dump_test.go @@ -268,7 +268,7 @@ func Test_logDumperNode_dump(t *testing.T) { } actual := []string{} - err = filepath.Walk(tmpdir, func(path string, info os.FileInfo, err error) error { + err = filepath.WalkDir(tmpdir, func(path string, info os.DirEntry, err error) error { if err != nil { return err } diff --git a/kubetest/e2e/runner.go b/kubetest/e2e/runner.go index 7f72eb928f76..e2a759e1447c 100644 --- a/kubetest/e2e/runner.go +++ b/kubetest/e2e/runner.go @@ -223,7 +223,7 @@ func (t *GinkgoTester) findBinary(name string) (string, error) { } if bazelBinExists { - err := filepath.Walk(bazelBin, func(path string, info os.FileInfo, err error) error { + err := filepath.WalkDir(bazelBin, func(path string, info os.DirEntry, err error) error { if err != nil { return fmt.Errorf("error from walk: %w", err) }