From eb5b6d50474842db17330b11e0db70077e1c4510 Mon Sep 17 00:00:00 2001 From: Feng Cao <24779889+shfc@users.noreply.github.com> Date: Tue, 13 May 2025 17:51:49 +0930 Subject: [PATCH] fix: move warning to top of block Emit the warning first to ensure it's always logged. This clarifies that any following errors are due to using a local chart instead of a remote repository. Signed-off-by: Feng Cao <24779889+shfc@users.noreply.github.com> --- pkg/action/install.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 7cc8dcd3a..e040c15e4 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -751,6 +751,12 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) ( version := strings.TrimSpace(c.Version) if _, err := os.Stat(name); err == nil { + // Issue #7862: Helm prioritizes local charts over --repo flag. + // This behavior is maintained for backwards compatibility but with a warning. + if c.RepoURL != "" { + slog.Warn("local chart found in current working directory. --repo flag ignored", "chart", name) + } + abs, err := filepath.Abs(name) if err != nil { return abs, err @@ -760,11 +766,6 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) ( return "", err } } - // Issue #7862: Helm prioritizes local charts over --repo flag. - // This behavior is maintained for backwards compatibility but with a warning. - if c.RepoURL != "" { - slog.Warn("local chart found in current working directory. --repo flag ignored", "chart", name) - } return abs, nil } if filepath.IsAbs(name) || strings.HasPrefix(name, ".") {