From 4885b0d35795b7dd8f84cafe4139fa71fe253fb8 Mon Sep 17 00:00:00 2001 From: Christoph Barbian Date: Mon, 9 Mar 2026 20:38:06 +0100 Subject: [PATCH] fix 'no such directory' error in case of empty kustoimization --- internal/kustomize/kustomization.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/internal/kustomize/kustomization.go b/internal/kustomize/kustomization.go index 12e8002..ec85c0e 100644 --- a/internal/kustomize/kustomization.go +++ b/internal/kustomize/kustomization.go @@ -392,20 +392,22 @@ func makeFuncData(data any) any { func generateKustomization(fsys kustfsys.FileSystem, kustomizationPath string) ([]byte, error) { var resources []string - f := func(path string, info fs.FileInfo, err error) error { - if err != nil { - return err - } - // TODO: IsDir() is false if it is a symlink; is that wanted to be this way? - if !info.IsDir() && !strings.HasPrefix(filepath.Base(path), ".") && (strings.HasSuffix(path, ".yaml") || strings.HasSuffix(path, ".yml")) { - resources = append(resources, path) + if fsys.IsDir(kustomizationPath) { + f := func(path string, info fs.FileInfo, err error) error { + if err != nil { + return err + } + // TODO: IsDir() is false if it is a symlink; is that wanted to be this way? + if !info.IsDir() && !strings.HasPrefix(filepath.Base(path), ".") && (strings.HasSuffix(path, ".yaml") || strings.HasSuffix(path, ".yml")) { + resources = append(resources, path) + } + return nil } - return nil - } - // TODO: does this work correctly with symlinks? - if err := fsys.Walk(kustomizationPath, f); err != nil { - return nil, err + // TODO: does this work correctly with symlinks? + if err := fsys.Walk(kustomizationPath, f); err != nil { + return nil, err + } } kustomization := kustypes.Kustomization{