From 53a4134379196601d9ad85e8488426f860f8c20d Mon Sep 17 00:00:00 2001 From: koba1t Date: Thu, 9 Feb 2023 04:01:30 +0900 Subject: [PATCH] fix error handling and test --- kustomize/commands/internal/util/util.go | 2 +- kustomize/commands/internal/util/util_test.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kustomize/commands/internal/util/util.go b/kustomize/commands/internal/util/util.go index 8e60a5f6e..d68a6edca 100644 --- a/kustomize/commands/internal/util/util.go +++ b/kustomize/commands/internal/util/util.go @@ -42,7 +42,7 @@ func GlobPatternsWithLoader(fSys filesys.FileSystem, ldr ifc.Loader, patterns [] if len(files) == 0 { loader, err := ldr.New(pattern) if err != nil { - return nil, fmt.Errorf("%s has no match", pattern) + return nil, fmt.Errorf("%s has no match: %w", pattern, err) } else { result = append(result, pattern) if loader != nil { diff --git a/kustomize/commands/internal/util/util_test.go b/kustomize/commands/internal/util/util_test.go index b08b7cf7b..20d0b030a 100644 --- a/kustomize/commands/internal/util/util_test.go +++ b/kustomize/commands/internal/util/util_test.go @@ -89,8 +89,9 @@ func TestGlobPatternsWithLoaderRemoteFile(t *testing.T) { } // test load invalid file - resources, err = GlobPatternsWithLoader(fSys, ldr, []string{"http://invalid"}) - if err == nil { + invalidURL := "http://invalid" + resources, err = GlobPatternsWithLoader(fSys, ldr, []string{invalidURL}) + if err != nil && err.Error() != invalidURL+" has no match: "+invalidURL+" not exist" { t.Fatalf("unexpected load error: %v", err) } if len(resources) > 0 {