Add HELM_EXPERIMENTAL_CHART_V3 feature gate to create command

Signed-off-by: Evans Mungai <mbuevans@gmail.com>
pull/31592/head
Evans Mungai 4 weeks ago
parent 0b5649614d
commit bb26682b6e
No known key found for this signature in database
GPG Key ID: BBEB812143DD14E1

@ -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)

@ -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

@ -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"

Loading…
Cancel
Save