mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 10:15:22 +00:00
Merge pull request #5865 from milkshake308/feat_helm_devel_arg
feat(helm): allow the use of devel alias for helmcharts
This commit is contained in:
@@ -337,6 +337,9 @@ func (p *HelmChartInflationGeneratorPlugin) pullCommand() []string {
|
||||
if p.Version != "" {
|
||||
args = append(args, "--version", p.Version)
|
||||
}
|
||||
if p.Devel {
|
||||
args = append(args, "--devel")
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,9 @@ type HelmChart struct {
|
||||
|
||||
// debug enables debug output from the Helm chart inflator generator.
|
||||
Debug bool `json:"debug,omitempty" yaml:"debug,omitempty"`
|
||||
|
||||
// allow for devel release to be used.
|
||||
Devel bool `json:"devel,omitempty" yaml:"devel,omitempty"`
|
||||
}
|
||||
|
||||
// HelmChartArgs contains arguments to helm.
|
||||
@@ -194,5 +197,8 @@ func (h HelmChart) AsHelmArgs(absChartHome string) []string {
|
||||
if h.Debug {
|
||||
args = append(args, "--debug")
|
||||
}
|
||||
if h.Devel {
|
||||
args = append(args, "--devel")
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
@@ -77,4 +77,28 @@ func TestAsHelmArgs(t *testing.T) {
|
||||
"-f", "values2",
|
||||
"--debug"})
|
||||
})
|
||||
|
||||
t.Run("use helm-devel", func(t *testing.T) {
|
||||
// We first test that the devel flag is only appended when specified
|
||||
p := types.HelmChart{
|
||||
Name: "chart-name",
|
||||
Version: "1.0.0",
|
||||
Repo: "https://helm.releases.hashicorp.com",
|
||||
ValuesFile: "values",
|
||||
AdditionalValuesFiles: []string{"values1", "values2"},
|
||||
}
|
||||
require.Equal(t, p.AsHelmArgs("/home/charts"),
|
||||
[]string{"template", "--generate-name", "/home/charts/chart-name",
|
||||
"-f", "values",
|
||||
"-f", "values1",
|
||||
"-f", "values2"})
|
||||
|
||||
p.Devel = true
|
||||
require.Equal(t, p.AsHelmArgs("/home/charts"),
|
||||
[]string{"template", "--generate-name", "/home/charts/chart-name",
|
||||
"-f", "values",
|
||||
"-f", "values1",
|
||||
"-f", "values2",
|
||||
"--devel"})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -343,6 +343,9 @@ func (p *plugin) pullCommand() []string {
|
||||
if p.Version != "" {
|
||||
args = append(args, "--version", p.Version)
|
||||
}
|
||||
if p.Devel {
|
||||
args = append(args, "--devel")
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
|
||||
@@ -993,3 +993,37 @@ debug: true
|
||||
assert.Contains(t, string(chartYamlContent), "name: test-chart")
|
||||
assert.Contains(t, string(chartYamlContent), "version: 1.0.0")
|
||||
}
|
||||
|
||||
func TestHelmChartInflationGeneratorWithDevel(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t).
|
||||
PrepBuiltin("HelmChartInflationGenerator")
|
||||
defer th.Reset()
|
||||
if err := th.ErrIfNoHelm(); err != nil {
|
||||
t.Skip("skipping: " + err.Error())
|
||||
}
|
||||
copyTestChartsIntoHarness(t, th)
|
||||
|
||||
rm := th.LoadAndRunGenerator(`
|
||||
apiVersion: builtin
|
||||
kind: HelmChartInflationGenerator
|
||||
metadata:
|
||||
name: sm-operator
|
||||
name: sm-operator
|
||||
version: 0.1.0-Beta
|
||||
repo: https://charts.bitwarden.com/
|
||||
releaseName: sm-operator
|
||||
chartHome: ./charts
|
||||
devel: true
|
||||
`)
|
||||
cm, err := rm.Resources()[0].GetFieldValue("metadata.name")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "sm-operator-controller-manager", cm)
|
||||
|
||||
chartDir := filepath.Join(th.GetRoot(), "charts/sm-operator-0.1.0-Beta/sm-operator")
|
||||
assert.True(t, th.GetFSys().Exists(chartDir))
|
||||
|
||||
chartYamlContent, err := th.GetFSys().ReadFile(filepath.Join(chartDir, "Chart.yaml"))
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, string(chartYamlContent), "name: sm-operator")
|
||||
assert.Contains(t, string(chartYamlContent), "version: 0.1.0-Beta")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user