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:
Isar_NS
2024-09-13 01:43:12 +03:00
committed by GitHub
parent c3872ce3d9
commit 4034e36ee1
8 changed files with 83 additions and 2 deletions

View File

@@ -96,6 +96,9 @@ type HelmChart struct {
// SkipTests skips tests from templated output.
SkipTests bool `json:"skipTests,omitempty" yaml:"skipTests,omitempty"`
// debug enables debug output from the Helm chart inflator generator.
Debug bool `json:"debug,omitempty" yaml:"debug,omitempty"`
}
// HelmChartArgs contains arguments to helm.
@@ -188,5 +191,8 @@ func (h HelmChart) AsHelmArgs(absChartHome string) []string {
if h.SkipHooks {
args = append(args, "--no-hooks")
}
if h.Debug {
args = append(args, "--debug")
}
return args
}

View File

@@ -60,4 +60,21 @@ func TestAsHelmArgs(t *testing.T) {
"-f", "values1", "-f", "values2",
"--api-versions", "foo", "--api-versions", "bar"})
})
t.Run("use helm-debug", func(t *testing.T) {
p := types.HelmChart{
Name: "chart-name",
Version: "1.0.0",
Repo: "https://helm.releases.hashicorp.com",
ValuesFile: "values",
AdditionalValuesFiles: []string{"values1", "values2"},
Debug: true,
}
require.Equal(t, p.AsHelmArgs("/home/charts"),
[]string{"template", "--generate-name", "/home/charts/chart-name",
"-f", "values",
"-f", "values1",
"-f", "values2",
"--debug"})
})
}

View File

@@ -8,6 +8,7 @@ type HelmConfig struct {
Command string
ApiVersions []string
KubeVersion string
Debug bool
}
// PluginConfig holds plugin configuration.