From ecb8480a513f98f202e47e91091d7fecc5bb20b2 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Mon, 22 Apr 2024 13:50:32 +0300 Subject: [PATCH] Modify CRD cached path directory logging --- pkg/helmutil/crds.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/helmutil/crds.go b/pkg/helmutil/crds.go index 947a56a..9705b27 100644 --- a/pkg/helmutil/crds.go +++ b/pkg/helmutil/crds.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "context" + "fmt" "io" "os" "path/filepath" @@ -46,7 +47,7 @@ func (u *Upgrader) Upgrade(ctx context.Context, chartVersion string) ([]unstruct return nil, err } - if _, err := os.Stat(chartDir); os.IsNotExist(err) { + if fs, err := os.Stat(chartDir); os.IsNotExist(err) { log.Info("Downloading chart release from remote repository", "repoURL", u.repoURL, "chartName", u.chartName, "chartVersion", chartVersion) downloadDir, err := DownloadChartRelease(u.repoName, u.repoURL, u.chartName, chartVersion) if err != nil { @@ -58,6 +59,13 @@ func (u *Upgrader) Upgrade(ctx context.Context, chartVersion string) ([]unstruct return nil, err } chartDir = extractDir + } else if err != nil { + log.Error("Failed to check chart release directory", "error", err) + return nil, err + } else if !fs.IsDir() { + err := fmt.Errorf("chart release is not a directory: %s", chartDir) + log.Error("Target chart release path is not a directory", "directory", chartDir, "error", err) + return nil, err } else { log.Info("Using cached chart release", "directory", chartDir) }