mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
Compare commits
1 Commits
v4.0.3
...
fix/issue_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cf70398a4 |
@@ -1,6 +1,8 @@
|
|||||||
package cautils
|
package cautils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -24,7 +26,27 @@ func IsHelmDirectory(path string) (bool, error) {
|
|||||||
return helmchartutil.IsChartDir(path)
|
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) {
|
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)
|
chart, err := helmloader.Load(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user