mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Merge pull request #4808 from larsks/feature/no-hooks
Add support for helm --no-hooks flag
This commit is contained in:
@@ -282,6 +282,9 @@ func (p *HelmChartInflationGeneratorPlugin) templateCommand() []string {
|
||||
if p.IncludeCRDs {
|
||||
args = append(args, "--include-crds")
|
||||
}
|
||||
if p.SkipHooks {
|
||||
args = append(args, "--no-hooks")
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,10 @@ type HelmChart struct {
|
||||
// IncludeCRDs specifies if Helm should also generate CustomResourceDefinitions.
|
||||
// Defaults to 'false'.
|
||||
IncludeCRDs bool `json:"includeCRDs,omitempty" yaml:"includeCRDs,omitempty"` //nolint: tagliatelle
|
||||
|
||||
// SkipHooks sets the --no-hooks flag when calling helm template. This prevents
|
||||
// helm from erroneously rendering test templates.
|
||||
SkipHooks bool `json:"skipHooks,omitempty" yaml:"skipHooks,omitempty"`
|
||||
}
|
||||
|
||||
// HelmChartArgs contains arguments to helm.
|
||||
|
||||
@@ -287,6 +287,9 @@ func (p *HelmChartInflationGeneratorPlugin) templateCommand() []string {
|
||||
if p.IncludeCRDs {
|
||||
args = append(args, "--include-crds")
|
||||
}
|
||||
if p.SkipHooks {
|
||||
args = append(args, "--no-hooks")
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
|
||||
@@ -526,6 +526,34 @@ valuesInline:
|
||||
th.AssertActualEqualsExpected(rm, "")
|
||||
}
|
||||
|
||||
func TestHelmChartInflationGeneratorWithSkipHooks(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t).
|
||||
PrepBuiltin("HelmChartInflationGenerator")
|
||||
defer th.Reset()
|
||||
if err := th.ErrIfNoHelm(); err != nil {
|
||||
t.Skip("skipping: " + err.Error())
|
||||
}
|
||||
|
||||
// we choose this helm chart as it has the ability to turn
|
||||
// everything off, except CRDs.
|
||||
rm := th.LoadAndRunGenerator(`
|
||||
apiVersion: builtin
|
||||
kind: HelmChartInflationGenerator
|
||||
metadata:
|
||||
name: terraform
|
||||
name: terraform
|
||||
version: 1.0.0
|
||||
repo: https://helm.releases.hashicorp.com
|
||||
releaseName: terraforming-mars
|
||||
includeCRDs: false
|
||||
skipHooks: true
|
||||
valuesInline:
|
||||
global:
|
||||
enabled: false
|
||||
`)
|
||||
th.AssertActualEqualsExpected(rm, "")
|
||||
}
|
||||
|
||||
func TestHelmChartInflationGeneratorWithIncludeCRDsNotSpecified(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t).
|
||||
PrepBuiltin("HelmChartInflationGenerator")
|
||||
|
||||
Reference in New Issue
Block a user