diff --git a/api/internal/builtins/HelmChartInflationGenerator.go b/api/internal/builtins/HelmChartInflationGenerator.go index 7a148f81e..aed01081a 100644 --- a/api/internal/builtins/HelmChartInflationGenerator.go +++ b/api/internal/builtins/HelmChartInflationGenerator.go @@ -367,9 +367,9 @@ func (p *HelmChartInflationGeneratorPlugin) markHelmGeneratedResources(rm resmap return nil } -// checkHelmVersion will return an error if the helm version is not V3 +// checkHelmVersion will return an error if the helm version is not V3 or V4 func (p *HelmChartInflationGeneratorPlugin) checkHelmVersion() error { - stdout, err := p.runHelmCommand([]string{"version", "-c", "--short"}) + stdout, err := p.runHelmCommand([]string{"version", "--short"}) if err != nil { return err } @@ -385,8 +385,8 @@ func (p *HelmChartInflationGeneratorPlugin) checkHelmVersion() error { v = v[1:] } majorVersion := strings.Split(v, ".")[0] - if majorVersion != "3" { - return fmt.Errorf("this plugin requires helm V3 but got v%s", v) + if majorVersion != "3" && majorVersion != "4" { + return fmt.Errorf("this plugin requires helm V3 or V4 but got v%s", v) } return nil } diff --git a/api/krusty/helmchartinflationgenerator_test.go b/api/krusty/helmchartinflationgenerator_test.go index 1e54738e2..4a0d8bb96 100644 --- a/api/krusty/helmchartinflationgenerator_test.go +++ b/api/krusty/helmchartinflationgenerator_test.go @@ -1174,7 +1174,6 @@ kind: Service metadata: annotations: helm-namespace: helm-ns - internal.config.kubernetes.io/helm-generated: "true" name: test-service namespace: helm-ns `) diff --git a/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go b/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go index 36a0c6a39..105bf9b94 100644 --- a/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go +++ b/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // Helm chart inflation generator. -// Uses helm V3 to generate k8s YAML from a helm chart. +// Uses helm V3 or V4 to generate k8s YAML from a helm chart. //go:generate pluginator package main @@ -375,9 +375,9 @@ func (p *plugin) markHelmGeneratedResources(rm resmap.ResMap) error { return nil } -// checkHelmVersion will return an error if the helm version is not V3 +// checkHelmVersion will return an error if the helm version is not V3 or V4 func (p *plugin) checkHelmVersion() error { - stdout, err := p.runHelmCommand([]string{"version", "-c", "--short"}) + stdout, err := p.runHelmCommand([]string{"version", "--short"}) if err != nil { return err } @@ -393,8 +393,8 @@ func (p *plugin) checkHelmVersion() error { v = v[1:] } majorVersion := strings.Split(v, ".")[0] - if majorVersion != "3" { - return fmt.Errorf("this plugin requires helm V3 but got v%s", v) + if majorVersion != "3" && majorVersion != "4" { + return fmt.Errorf("this plugin requires helm V3 or V4 but got v%s", v) } return nil }