diff --git a/internal/gates/gates.go b/internal/gates/gates.go new file mode 100644 index 000000000..e071c54ea --- /dev/null +++ b/internal/gates/gates.go @@ -0,0 +1,21 @@ +/* +Copyright The Helm Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package gates + +import "helm.sh/helm/v4/pkg/gates" + +// ChartV3 is the feature gate for chart API version v3. +const ChartV3 gates.Gate = "HELM_EXPERIMENTAL_CHART_V3" diff --git a/pkg/cmd/create.go b/pkg/cmd/create.go index d8a8cd2f9..b38ce6a12 100644 --- a/pkg/cmd/create.go +++ b/pkg/cmd/create.go @@ -25,10 +25,10 @@ import ( chartv3 "helm.sh/helm/v4/internal/chart/v3" chartutilv3 "helm.sh/helm/v4/internal/chart/v3/util" + "helm.sh/helm/v4/internal/gates" 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" ) @@ -60,9 +60,6 @@ type createOptions struct { chartAPIVersion string // --chart-api-version } -// ChartV3 is the feature gate for chart API version v3. -const chartV3 gates.Gate = "HELM_EXPERIMENTAL_CHART_V3" - func newCreateCmd(out io.Writer) *cobra.Command { o := &createOptions{} @@ -90,7 +87,7 @@ func newCreateCmd(out io.Writer) *cobra.Command { cmd.Flags().StringVarP(&o.starter, "starter", "p", "", "the name or absolute path to Helm starter scaffold") cmd.Flags().StringVar(&o.chartAPIVersion, "chart-api-version", chart.APIVersionV2, "chart API version to use (v2 or v3)") - if !chartV3.IsEnabled() { + if !gates.ChartV3.IsEnabled() { cmd.Flags().MarkHidden("chart-api-version") } @@ -104,8 +101,8 @@ func (o *createOptions) run(out io.Writer) error { case chart.APIVersionV2, "": return o.createV2Chart(out) case chartv3.APIVersionV3: - if !chartV3.IsEnabled() { - return chartV3.Error() + if !gates.ChartV3.IsEnabled() { + return gates.ChartV3.Error() } return o.createV3Chart(out) default: diff --git a/pkg/cmd/create_test.go b/pkg/cmd/create_test.go index 3ecbb5387..57e2aaf5f 100644 --- a/pkg/cmd/create_test.go +++ b/pkg/cmd/create_test.go @@ -24,6 +24,7 @@ import ( chartv3 "helm.sh/helm/v4/internal/chart/v3" chartutilv3 "helm.sh/helm/v4/internal/chart/v3/util" + "helm.sh/helm/v4/internal/gates" "helm.sh/helm/v4/internal/test/ensure" chart "helm.sh/helm/v4/pkg/chart" chartloader "helm.sh/helm/v4/pkg/chart/loader" @@ -107,7 +108,7 @@ func TestCreateStarterCmd(t *testing.T) { // Enable feature gate for v3 charts if tt.chartAPIVersion == "v3" { - t.Setenv(string(chartV3), "1") + t.Setenv(string(gates.ChartV3), "1") } cname := "testchart" @@ -249,7 +250,7 @@ func TestCreateCmdChartAPIVersionV2(t *testing.T) { func TestCreateCmdChartAPIVersionV3(t *testing.T) { t.Chdir(t.TempDir()) ensure.HelmHome(t) - t.Setenv(string(chartV3), "1") + t.Setenv(string(gates.ChartV3), "1") cname := "testchart" // Run a create with v3