mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Add --helm-debug Flag to Kustomize for Enhanced Helm Debugging (#5751)
* feat: add helm-debug flag * revert: go.work.sum * test: add helm chart args helm-debug test * test: helm debug flag * refactor: helm debug output * style: linting * revert: go.work.sum
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
@@ -62,6 +63,9 @@ func (p *HelmChartInflationGeneratorPlugin) Config(
|
||||
if len(h.GeneralConfig().HelmConfig.ApiVersions) != 0 {
|
||||
p.HelmChart.ApiVersions = h.GeneralConfig().HelmConfig.ApiVersions
|
||||
}
|
||||
if h.GeneralConfig().HelmConfig.Debug {
|
||||
p.HelmChart.Debug = h.GeneralConfig().HelmConfig.Debug
|
||||
}
|
||||
|
||||
p.h = h
|
||||
if err = yaml.Unmarshal(config, p); err != nil {
|
||||
@@ -168,13 +172,17 @@ func (p *HelmChartInflationGeneratorPlugin) runHelmCommand(
|
||||
fmt.Sprintf("HELM_DATA_HOME=%s/.data", p.ConfigHome)}
|
||||
cmd.Env = append(os.Environ(), env...)
|
||||
err := cmd.Run()
|
||||
errorOutput := stderr.String()
|
||||
if slices.Contains(args, "--debug") {
|
||||
errorOutput = " Helm stack trace:\n" + errorOutput + "\nHelm template:\n" + stdout.String() + "\n"
|
||||
}
|
||||
if err != nil {
|
||||
helm := p.h.GeneralConfig().HelmConfig.Command
|
||||
err = errors.WrapPrefixf(
|
||||
fmt.Errorf(
|
||||
"unable to run: '%s %s' with env=%s (is '%s' installed?): %w",
|
||||
helm, strings.Join(args, " "), env, helm, err),
|
||||
stderr.String(),
|
||||
errorOutput,
|
||||
)
|
||||
}
|
||||
return stdout.Bytes(), err
|
||||
|
||||
Reference in New Issue
Block a user