From bb26682b6e37c487aa00494b0a1e824ea620c002 Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Tue, 2 Dec 2025 07:06:08 +0000 Subject: [PATCH] Add HELM_EXPERIMENTAL_CHART_V3 feature gate to create command Signed-off-by: Evans Mungai --- pkg/cmd/create.go | 4 ++++ pkg/cmd/create_test.go | 8 ++++++++ pkg/gates/gates.go | 3 +++ 3 files changed, 15 insertions(+) diff --git a/pkg/cmd/create.go b/pkg/cmd/create.go index 3eddd7f10..c3c2e3c2d 100644 --- a/pkg/cmd/create.go +++ b/pkg/cmd/create.go @@ -28,6 +28,7 @@ import ( chart "helm.sh/helm/v4/pkg/chart/v2" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cmd/require" + "helm.sh/helm/v4/pkg/gates" "helm.sh/helm/v4/pkg/helmpath" ) @@ -96,6 +97,9 @@ func (o *createOptions) run(out io.Writer) error { case chart.APIVersionV2, "": return o.createV2Chart(out) case chartv3.APIVersionV3: + if !gates.ChartV3.IsEnabled() { + return gates.ChartV3.Error() + } return o.createV3Chart(out) default: return fmt.Errorf("unsupported chart API version: %s (supported: v2, v3)", o.chartAPIVersion) diff --git a/pkg/cmd/create_test.go b/pkg/cmd/create_test.go index 9f1c6e5c8..554d5f1af 100644 --- a/pkg/cmd/create_test.go +++ b/pkg/cmd/create_test.go @@ -29,6 +29,7 @@ import ( chart "helm.sh/helm/v4/pkg/chart/v2" "helm.sh/helm/v4/pkg/chart/v2/loader" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" + "helm.sh/helm/v4/pkg/gates" "helm.sh/helm/v4/pkg/helmpath" ) @@ -94,6 +95,12 @@ func TestCreateStarterCmd(t *testing.T) { t.Chdir(t.TempDir()) ensure.HelmHome(t) defer resetEnv()() + + // Enable feature gate for v3 charts + if tt.chartAPIVersion == "v3" { + t.Setenv(string(gates.ChartV3), "1") + } + cname := "testchart" // Create a starter using the appropriate chartutil @@ -224,6 +231,7 @@ func TestCreateCmdChartAPIVersionV2(t *testing.T) { func TestCreateCmdChartAPIVersionV3(t *testing.T) { t.Chdir(t.TempDir()) ensure.HelmHome(t) + t.Setenv(string(gates.ChartV3), "1") cname := "testchart" // Run a create with v3 diff --git a/pkg/gates/gates.go b/pkg/gates/gates.go index 69559219e..a6787c789 100644 --- a/pkg/gates/gates.go +++ b/pkg/gates/gates.go @@ -36,3 +36,6 @@ func (g Gate) IsEnabled() bool { func (g Gate) Error() error { return fmt.Errorf("this feature has been marked as experimental and is not enabled by default. Please set %s=1 in your environment to use this feature", g.String()) } + +// ChartV3 is the feature gate for chart API version v3. +const ChartV3 Gate = "HELM_EXPERIMENTAL_CHART_V3"