From 061644c5d07c119527f19372d5e7b32cb350bfc7 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Sun, 23 Jan 2022 20:37:46 +0900 Subject: [PATCH] Fix readdir regression while merging (#2061) Ref https://github.com/roboll/helmfile/pull/2058#issuecomment-1019439394 --- pkg/tmpl/context_funcs.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/tmpl/context_funcs.go b/pkg/tmpl/context_funcs.go index 05c40bab..567e4bb9 100644 --- a/pkg/tmpl/context_funcs.go +++ b/pkg/tmpl/context_funcs.go @@ -133,13 +133,16 @@ func (c *Context) ReadFile(filename string) (string, error) { } func (c *Context) ReadDir(path string) ([]string, error) { - if !filepath.IsAbs(path) { - path = filepath.Join(c.basePath, path) + var contextPath string + if filepath.IsAbs(path) { + contextPath = path + } else { + contextPath = filepath.Join(c.basePath, path) } - entries, err := os.ReadDir(path) + entries, err := os.ReadDir(contextPath) if err != nil { - return nil, fmt.Errorf("ReadDir %q: %w", path, err) + return nil, fmt.Errorf("ReadDir %q: %w", contextPath, err) } var filenames []string