Skip to content

Commit 338b026

Browse files
authored
fix 'no such directory' error in case of empty kustoimization (#406)
1 parent f3f33dd commit 338b026

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

internal/kustomize/kustomization.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -392,20 +392,22 @@ func makeFuncData(data any) any {
392392
func generateKustomization(fsys kustfsys.FileSystem, kustomizationPath string) ([]byte, error) {
393393
var resources []string
394394

395-
f := func(path string, info fs.FileInfo, err error) error {
396-
if err != nil {
397-
return err
398-
}
399-
// TODO: IsDir() is false if it is a symlink; is that wanted to be this way?
400-
if !info.IsDir() && !strings.HasPrefix(filepath.Base(path), ".") && (strings.HasSuffix(path, ".yaml") || strings.HasSuffix(path, ".yml")) {
401-
resources = append(resources, path)
395+
if fsys.IsDir(kustomizationPath) {
396+
f := func(path string, info fs.FileInfo, err error) error {
397+
if err != nil {
398+
return err
399+
}
400+
// TODO: IsDir() is false if it is a symlink; is that wanted to be this way?
401+
if !info.IsDir() && !strings.HasPrefix(filepath.Base(path), ".") && (strings.HasSuffix(path, ".yaml") || strings.HasSuffix(path, ".yml")) {
402+
resources = append(resources, path)
403+
}
404+
return nil
402405
}
403-
return nil
404-
}
405406

406-
// TODO: does this work correctly with symlinks?
407-
if err := fsys.Walk(kustomizationPath, f); err != nil {
408-
return nil, err
407+
// TODO: does this work correctly with symlinks?
408+
if err := fsys.Walk(kustomizationPath, f); err != nil {
409+
return nil, err
410+
}
409411
}
410412

411413
kustomization := kustypes.Kustomization{

0 commit comments

Comments
 (0)