From 2cf70398a4fdda351ea22ba3cf9d4860ddb5e047 Mon Sep 17 00:00:00 2001 From: Yehudah Tor Date: Tue, 12 Aug 2025 12:08:20 +0300 Subject: [PATCH] Fix for issue 1284 Signed-off-by: Yehudah Tor --- core/cautils/helmchart.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/cautils/helmchart.go b/core/cautils/helmchart.go index 81abaa12..7408ec28 100644 --- a/core/cautils/helmchart.go +++ b/core/cautils/helmchart.go @@ -1,6 +1,8 @@ package cautils import ( + "fmt" + "os/exec" "path/filepath" "strconv" "strings" @@ -24,7 +26,27 @@ func IsHelmDirectory(path string) (bool, error) { return helmchartutil.IsChartDir(path) } +func buildDependenciesIfNeeded(chartPath string) error { + logger.L().Info("Building Helm chart dependencies...", helpers.String("chart", chartPath)) + + cmd := exec.Command("helm", "dependency", "build", chartPath) + cmd.Dir = chartPath + + if output, err := cmd.CombinedOutput(); err != nil { + return fmt.Errorf("helm dependency build failed: %w\nOutput: %s", err, string(output)) + } + + logger.L().Success("Helm dependencies built successfully") + return nil +} + func NewHelmChart(path string) (*HelmChart, error) { + // Build dependencies first + if err := buildDependenciesIfNeeded(path); err != nil { + logger.L().Warning("Failed to build dependencies, continuing anyway", helpers.Error(err)) + // Continue with chart loading even if dependency build fails + } + chart, err := helmloader.Load(path) if err != nil { return nil, err