diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2e25b18c..26f579cf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -59,7 +59,6 @@ jobs: plugin-secrets-version: 3.15.0 plugin-diff-version: 3.8.1 extra-helmfile-flags: '' - v1mode: '' - helm-version: v3.16.4 kustomize-version: v5.4.3 # We assume that the helm-secrets plugin is supposed to @@ -70,26 +69,16 @@ jobs: plugin-secrets-version: 4.6.0 plugin-diff-version: 3.9.14 extra-helmfile-flags: '' - v1mode: '' - helm-version: v3.17.0 kustomize-version: v5.2.1 plugin-secrets-version: 3.15.0 plugin-diff-version: 3.8.1 extra-helmfile-flags: '' - v1mode: '' - helm-version: v3.17.0 kustomize-version: v5.4.3 plugin-secrets-version: 4.6.0 plugin-diff-version: 3.9.14 extra-helmfile-flags: '' - v1mode: '' - # Helmfile v1 - - helm-version: v3.17.0 - kustomize-version: v5.4.3 - plugin-secrets-version: 4.6.0 - plugin-diff-version: 3.9.14 - extra-helmfile-flags: '' - v1mode: 'true' # In case you need to test some optional helmfile features, # enable it via extra-helmfile-flags below. - helm-version: v3.17.0 @@ -97,7 +86,6 @@ jobs: plugin-secrets-version: 4.6.0 plugin-diff-version: 3.9.14 extra-helmfile-flags: '--enable-live-output' - v1mode: '' steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -127,7 +115,6 @@ jobs: HELMFILE_HELM3: 1 TERM: xterm EXTRA_HELMFILE_FLAGS: ${{ matrix.extra-helmfile-flags }} - HELMFILE_V1MODE: ${{ matrix.v1mode }} e2e_tests: needs: tests diff --git a/.github/workflows/releaser.yaml b/.github/workflows/releaser.yaml index ee2f0dc9..fc98bd7c 100644 --- a/.github/workflows/releaser.yaml +++ b/.github/workflows/releaser.yaml @@ -16,7 +16,6 @@ permissions: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - HELMFILE_V1MODE: ${{ startsWith(github.ref, 'refs/tags/v1') }} SNAPSHOT: ${{ !startsWith(github.ref, 'refs/tags/v') && '--snapshot' || '' }} jobs: diff --git a/.goreleaser.yml b/.goreleaser.yml index 6d515513..aba37be9 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,8 +1,5 @@ version: 2 project_name: helmfile -env: - # We default to non-v1 mode (=helmfile v0.x behavior) when HELMFILE_V1MODE is not set - - HELMFILE_V1MODE={{ if index .Env "HELMFILE_V1MODE" }}{{ .Env.HELMFILE_V1MODE }}{{ else }}false{{ end }} builds: - id: helmfile main: . @@ -15,7 +12,6 @@ builds: - -X go.szostok.io/version.commit={{.FullCommit}} - -X go.szostok.io/version.commitDate={{.CommitDate}} - -X go.szostok.io/version.dirtyBuild=false - - -X github.com/helmfile/helmfile/pkg/runtime.v1Mode={{.Env.HELMFILE_V1MODE}} goos: - darwin - linux diff --git a/Makefile b/Makefile index 0500bd33..5e009ca0 100644 --- a/Makefile +++ b/Makefile @@ -25,10 +25,6 @@ build: go build -ldflags="$(GO_BUILD_VERSION_LDFLAGS)" ${TARGETS} .PHONY: build -build-v1: - go build -ldflags="$(GO_BUILD_VERSION_LDFLAGS) -X github.com/helmfile/helmfile/pkg/runtime.v1Mode=true" ${TARGETS} -.PHONY: build-v1 - generate: go generate ${PKGS} .PHONY: generate diff --git a/cmd/apply.go b/cmd/apply.go index 9e6cfa47..8cbe4ad9 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -5,7 +5,6 @@ import ( "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/helmfile/helmfile/pkg/runtime" ) // NewApplyCmd returns apply subcmd @@ -44,12 +43,6 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.StringVar(&applyOptions.DiffArgs, "diff-args", "", `pass args to helm helm-diff`) f.StringVar(&applyOptions.SyncArgs, "sync-args", "", `pass args to helm upgrade`) f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec") - if !runtime.V1Mode { - // TODO: Remove this function once Helmfile v0.x - f.BoolVar(&applyOptions.RetainValuesFiles, "retain-values-files", false, "DEPRECATED: Use skip-cleanup instead") - _ = f.MarkDeprecated("retain-values-files", "Use skip-cleanup instead") - } - f.BoolVar(&applyOptions.SkipCleanup, "skip-cleanup", false, "Stop cleaning up temporary values generated by helmfile and helm-secrets. Useful for debugging. Don't use in production for security") f.BoolVar(&applyOptions.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed on sync. By default, CRDs are installed if not already present") f.BoolVar(&applyOptions.SkipNeeds, "skip-needs", true, `do not automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when --selector/-l flag is not provided. Defaults to true when --include-needs or --include-transitive-needs is not provided`) diff --git a/cmd/charts.go b/cmd/charts.go deleted file mode 100644 index cae9d168..00000000 --- a/cmd/charts.go +++ /dev/null @@ -1,41 +0,0 @@ -// TODO: Remove this function once Helmfile v0.x -package cmd - -import ( - "github.com/spf13/cobra" - - "github.com/helmfile/helmfile/pkg/app" - "github.com/helmfile/helmfile/pkg/config" -) - -// NewChartsCmd returns charts subcmd -func NewChartsCmd(globalCfg *config.GlobalImpl) *cobra.Command { - chartsOptions := config.NewChartsOptions() - - cmd := &cobra.Command{ - Use: "charts", - Short: "DEPRECATED: sync releases from state file (helm upgrade --install)", - RunE: func(cmd *cobra.Command, args []string) error { - chartsImpl := config.NewChartsImpl(globalCfg, chartsOptions) - err := config.NewCLIConfigImpl(chartsImpl.GlobalImpl) - if err != nil { - return err - } - - if err := chartsImpl.ValidateConfig(); err != nil { - return err - } - - a := app.New(chartsImpl) - return toCLIError(chartsImpl.GlobalImpl, a.DeprecatedSyncCharts(chartsImpl)) - }, - } - - f := cmd.Flags() - f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec") - f.StringArrayVar(&chartsOptions.Set, "set", nil, "additional values to be merged into the helm command --set flag") - f.StringArrayVar(&chartsOptions.Values, "values", nil, "additional value files to be merged into the helm command --values flag") - f.IntVar(&chartsOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") - - return cmd -} diff --git a/cmd/delete.go b/cmd/delete.go deleted file mode 100644 index 1c89c147..00000000 --- a/cmd/delete.go +++ /dev/null @@ -1,44 +0,0 @@ -// TODO: Remove this function once Helmfile v0.x -package cmd - -import ( - "github.com/spf13/cobra" - - "github.com/helmfile/helmfile/pkg/app" - "github.com/helmfile/helmfile/pkg/config" -) - -// NewDeleteCmd returns delete subcmd -func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command { - deleteOptions := config.NewDeleteOptions() - - cmd := &cobra.Command{ - Use: "delete", - Short: "DEPRECATED: delete releases from state file (helm delete)", - RunE: func(cmd *cobra.Command, args []string) error { - deleteImpl := config.NewDeleteImpl(globalCfg, deleteOptions) - err := config.NewCLIConfigImpl(deleteImpl.GlobalImpl) - if err != nil { - return err - } - - if err := deleteImpl.ValidateConfig(); err != nil { - return err - } - - a := app.New(deleteImpl) - return toCLIError(deleteImpl.GlobalImpl, a.Delete(deleteImpl)) - }, - } - - f := cmd.Flags() - f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec") - f.StringVar(&deleteOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background") - f.IntVar(&deleteOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") - f.BoolVar(&deleteOptions.Purge, "purge", false, "purge releases i.e. free release names and histories") - f.BoolVar(&deleteOptions.SkipCharts, "skip-charts", false, "don't prepare charts when deleting releases") - f.BoolVar(&deleteOptions.DeleteWait, "deleteWait", false, `override helmDefaults.wait setting "helm uninstall --wait"`) - f.IntVar(&deleteOptions.DeleteTimeout, "deleteTimeout", 300, `time in seconds to wait for helm uninstall, default: 300`) - - return cmd -} diff --git a/cmd/root.go b/cmd/root.go index f94cd9be..ed629d12 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -109,14 +109,6 @@ func NewRootCmd(globalConfig *config.GlobalOptions) (*cobra.Command, error) { ), ) - // TODO: Remove this function once Helmfile v0.x - if !runtime.V1Mode { - cmd.AddCommand( - NewChartsCmd(globalImpl), - NewDeleteCmd(globalImpl), - ) - } - return cmd, nil } diff --git a/docs/index.md b/docs/index.md index 88c819b7..db460ca9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -557,7 +557,6 @@ Helmfile uses some OS environment variables to override default behaviour: * `HELMFILE_ENVIRONMENT` - specify [Helmfile environment](https://helmfile.readthedocs.io/en/latest/#environment), it has lower priority than CLI argument `--environment` * `HELMFILE_TEMPDIR` - specify directory to store temporary files * `HELMFILE_UPGRADE_NOTICE_DISABLED` - expecting any non-empty value to skip the check for the latest version of Helmfile in [helmfile version](https://helmfile.readthedocs.io/en/latest/#version) -* `HELMFILE_V1MODE` - Helmfile v0.x behaves like v1.x with `true`, Helmfile v1.x behaves like v0.x with `false` as value * `HELMFILE_GOCCY_GOYAML` - use *goccy/go-yaml* instead of *gopkg.in/yaml.v2*. It's `false` by default in Helmfile v0.x and `true` by default for Helmfile v1.x. * `HELMFILE_CACHE_HOME` - specify directory to store cached files for remote operations * `HELMFILE_FILE_PATH` - specify the path to the helmfile.yaml file diff --git a/pkg/app/app.go b/pkg/app/app.go index 91beba57..3a44b252 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -20,7 +20,6 @@ import ( "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/plugins" "github.com/helmfile/helmfile/pkg/remote" - "github.com/helmfile/helmfile/pkg/runtime" "github.com/helmfile/helmfile/pkg/state" ) @@ -139,25 +138,6 @@ func (a *App) Repos(c ReposConfigProvider) error { }, c.IncludeTransitiveNeeds(), SetFilter(true)) } -// TODO: Remove this function once Helmfile v0.x -func (a *App) DeprecatedSyncCharts(c DeprecatedChartsConfigProvider) error { - return a.ForEachState(func(run *Run) (_ bool, errs []error) { - err := run.withPreparedCharts("charts", state.ChartPrepareOptions{ - SkipRepos: true, - SkipDeps: true, - Concurrency: 2, - }, func() { - errs = run.DeprecatedSyncCharts(c) - }) - - if err != nil { - errs = append(errs, err) - } - - return - }, c.IncludeTransitiveNeeds(), SetFilter(true)) -} - func (a *App) Diff(c DiffConfigProvider) error { var allDiffDetectedErrs []error @@ -409,7 +389,7 @@ func (a *App) Apply(c ApplyConfigProvider) error { var opts []LoadOption - opts = append(opts, SetRetainValuesFiles(c.RetainValuesFiles() || c.SkipCleanup())) + opts = append(opts, SetRetainValuesFiles(c.SkipCleanup())) err := a.ForEachState(func(run *Run) (ok bool, errs []error) { includeCRDs := !c.SkipCRDs() @@ -421,7 +401,7 @@ func (a *App) Apply(c ApplyConfigProvider) error { Wait: c.Wait(), WaitForJobs: c.WaitForJobs(), IncludeCRDs: &includeCRDs, - SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(), + SkipCleanup: c.SkipCleanup(), Validate: c.Validate(), Concurrency: c.Concurrency(), IncludeTransitiveNeeds: c.IncludeNeeds(), @@ -473,31 +453,6 @@ func (a *App) Status(c StatusesConfigProvider) error { }, false, SetFilter(true)) } -// TODO: Remove this function once Helmfile v0.x -func (a *App) Delete(c DeleteConfigProvider) error { - return a.ForEachState(func(run *Run) (ok bool, errs []error) { - if !c.SkipCharts() { - err := run.withPreparedCharts("delete", state.ChartPrepareOptions{ - SkipRepos: c.SkipRefresh() || c.SkipDeps(), - SkipRefresh: c.SkipRefresh(), - SkipDeps: c.SkipDeps(), - Concurrency: c.Concurrency(), - DeleteWait: c.DeleteWait(), - DeleteTimeout: c.DeleteTimeout(), - }, func() { - ok, errs = a.delete(run, c.Purge(), c) - }) - - if err != nil { - errs = append(errs, err) - } - } else { - ok, errs = a.delete(run, c.Purge(), c) - } - return - }, false, SetReverse(true)) -} - func (a *App) Destroy(c DestroyConfigProvider) error { return a.ForEachState(func(run *Run) (ok bool, errs []error) { if !c.SkipCharts() { @@ -1258,16 +1213,6 @@ func (a *App) findDesiredStateFiles(specifiedPath string, opts LoadOpts) ([]stri case a.fs.FileExistsAt(DefaultGotmplHelmfile): defaultFile = DefaultGotmplHelmfile - - // TODO: Remove this block when we remove v0 code - case !runtime.V1Mode && a.fs.FileExistsAt(DeprecatedHelmfile): - a.Logger.Warnf( - "warn: %s is being loaded: %s is deprecated in favor of %s. See https://github.com/roboll/helmfile/issues/25 for more information", - DeprecatedHelmfile, - DeprecatedHelmfile, - DefaultHelmfile, - ) - defaultFile = DeprecatedHelmfile } switch { @@ -1432,7 +1377,7 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) { Context: c.Context(), Output: c.DiffOutput(), Set: c.Set(), - SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(), + SkipCleanup: c.SkipCleanup(), SkipDiffOnInstall: c.SkipDiffOnInstall(), ReuseValues: c.ReuseValues(), ResetValues: c.ResetValues(), @@ -1543,7 +1488,7 @@ Do you really want to apply? syncOpts := &state.SyncOpts{ Set: c.Set(), - SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(), + SkipCleanup: c.SkipCleanup(), SkipCRDs: c.SkipCRDs(), Wait: c.Wait(), WaitForJobs: c.WaitForJobs(), diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index df79ee51..d3dc6cf9 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -2213,9 +2213,6 @@ type applyConfig struct { cascade string values []string - // TODO: Remove this function once Helmfile v0.x - retainValuesFiles bool - set []string validate bool skipCleanup bool @@ -2376,11 +2373,6 @@ func (a applyConfig) Logger() *zap.SugaredLogger { return a.logger } -// TODO: Remove this function once Helmfile v0.x -func (a applyConfig) RetainValuesFiles() bool { - return a.retainValuesFiles -} - func (a applyConfig) SkipDiffOnInstall() bool { return a.skipDiffOnInstall } diff --git a/pkg/app/config.go b/pkg/app/config.go index b6e3a064..1a46c4cc 100644 --- a/pkg/app/config.go +++ b/pkg/app/config.go @@ -25,15 +25,6 @@ type ConfigProvider interface { loggingConfig } -// TODO: Remove this function once Helmfile v0.x -type DeprecatedChartsConfigProvider interface { - Values() []string - - concurrencyConfig - loggingConfig - IncludeTransitiveNeeds() bool -} - type DepsConfigProvider interface { Args() string SkipRepos() bool @@ -81,9 +72,6 @@ type ApplyConfigProvider interface { Context() int DiffOutput() string - // TODO: Remove this function once Helmfile v0.x - RetainValuesFiles() bool - Validate() bool SkipCleanup() bool SkipDiffOnInstall() bool @@ -166,23 +154,6 @@ type DiffConfigProvider interface { valuesControlMode } -// TODO: Remove this function once Helmfile v0.x -type DeleteConfigProvider interface { - Args() string - Cascade() string - - Purge() bool - SkipDeps() bool - SkipRefresh() bool - SkipCharts() bool - DeleteWait() bool - DeleteTimeout() int - - interactive - loggingConfig - concurrencyConfig -} - type DestroyConfigProvider interface { Args() string Cascade() string diff --git a/pkg/app/constants.go b/pkg/app/constants.go index 63fd3af7..38d06ce0 100644 --- a/pkg/app/constants.go +++ b/pkg/app/constants.go @@ -8,10 +8,7 @@ import ( ) const ( - DefaultHelmfile = "helmfile.yaml" - // TODO: Remove this function once Helmfile v0.x - DeprecatedHelmfile = "charts.yaml" - + DefaultHelmfile = "helmfile.yaml" DefaultHelmfileDirectory = "helmfile.d" ExperimentalSelectorExplicit = "explicit-selector-inheritance" // value to remove default selector inheritance to sub-helmfiles and use the explicit one ) diff --git a/pkg/app/desired_state_file_loader.go b/pkg/app/desired_state_file_loader.go index 76fa81f5..90986023 100644 --- a/pkg/app/desired_state_file_loader.go +++ b/pkg/app/desired_state_file_loader.go @@ -15,7 +15,6 @@ import ( "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/policy" "github.com/helmfile/helmfile/pkg/remote" - "github.com/helmfile/helmfile/pkg/runtime" "github.com/helmfile/helmfile/pkg/state" ) @@ -162,21 +161,14 @@ func (a *desiredStateLoader) underlying() *state.StateCreator { func (a *desiredStateLoader) rawLoad(yaml []byte, baseDir, file string, evaluateBases bool, env, overrodeEnv *environment.Environment) (*state.HelmState, error) { var st *state.HelmState var err error - if runtime.V1Mode { - st, err = a.underlying().ParseAndLoad(yaml, baseDir, file, a.env, false, evaluateBases, env, overrodeEnv) - if err != nil { - return nil, err - } - } else { - merged, err := env.Merge(overrodeEnv) - if err != nil { - return nil, err - } + merged, err := env.Merge(overrodeEnv) + if err != nil { + return nil, err + } - st, err = a.underlying().ParseAndLoad(yaml, baseDir, file, a.env, false, evaluateBases, merged, nil) - if err != nil { - return nil, err - } + st, err = a.underlying().ParseAndLoad(yaml, baseDir, file, a.env, false, evaluateBases, merged, nil) + if err != nil { + return nil, err } helmfiles, err := st.ExpandedHelmfiles() if err != nil { @@ -207,7 +199,7 @@ func (ld *desiredStateLoader) load(env, overrodeEnv *environment.Environment, ba var rawContent []byte - if filepath.Ext(filename) == ".gotmpl" || !runtime.V1Mode { + if filepath.Ext(filename) == ".gotmpl" { var yamlBuf *bytes.Buffer var err error diff --git a/pkg/app/run.go b/pkg/app/run.go index e29fce2a..f01c2d4d 100644 --- a/pkg/app/run.go +++ b/pkg/app/run.go @@ -135,17 +135,6 @@ func (r *Run) Repos(c ReposConfigProvider) error { return r.ctx.SyncReposOnce(r.state, r.helm) } -// TODO: Remove this function once Helmfile v0.x -func (r *Run) DeprecatedSyncCharts(c DeprecatedChartsConfigProvider) []error { - st := r.state - helm := r.helm - - affectedReleases := state.AffectedReleases{} - errs := st.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency()) - affectedReleases.DisplayAffectedReleases(c.Logger()) - return errs -} - func (r *Run) diff(triggerCleanupEvent bool, detailedExitCode bool, c DiffConfigProvider, diffOpts *state.DiffOpts) (*string, map[string]state.ReleaseSpec, map[string]state.ReleaseSpec, []error) { st := r.state helm := r.helm diff --git a/pkg/app/two_pass_renderer.go b/pkg/app/two_pass_renderer.go index 221af0c2..e950a7cb 100644 --- a/pkg/app/two_pass_renderer.go +++ b/pkg/app/two_pass_renderer.go @@ -8,7 +8,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/helmfile/helmfile/pkg/environment" - "github.com/helmfile/helmfile/pkg/runtime" "github.com/helmfile/helmfile/pkg/state" "github.com/helmfile/helmfile/pkg/tmpl" ) @@ -84,9 +83,6 @@ func (r *desiredStateLoader) renderTemplatesToYamlWithEnv(baseDir, filename stri func (r *desiredStateLoader) twoPassRenderTemplateToYaml(inherited, overrode *environment.Environment, baseDir, filename string, content []byte) (*bytes.Buffer, error) { // try a first pass render. This will always succeed, but can produce a limited env var phase string - if !runtime.V1Mode { - phase = "first-pass " - } r.logger.Debugf("%srendering starting for \"%s\": inherited=%v, overrode=%v", phase, filename, inherited, overrode) initEnv, err := inherited.Merge(nil) @@ -100,53 +96,14 @@ func (r *desiredStateLoader) twoPassRenderTemplateToYaml(inherited, overrode *en vals map[string]any ) - if runtime.V1Mode { - var err error + finalEnv, err = initEnv.Merge(overrode) + if err != nil { + return nil, err + } - finalEnv, err = initEnv.Merge(overrode) - if err != nil { - return nil, err - } - - vals, err = finalEnv.GetMergedValues() - if err != nil { - return nil, err - } - } else { - r.logger.Debugf("first-pass uses: %v", initEnv) - firstPassEnv, err := initEnv.Merge(nil) - if err != nil { - return nil, err - } - renderedEnv, prestate := r.renderPrestate(firstPassEnv, overrode, baseDir, filename, content) - - r.logger.Debugf("first-pass produced: %v", renderedEnv) - - mergedEnv, err := inherited.Merge(renderedEnv) - if err != nil { - return nil, err - } - - mergedEnv, err = mergedEnv.Merge(overrode) - if err != nil { - return nil, err - } - - r.logger.Debugf("first-pass rendering result of \"%s\": %v", filename, *mergedEnv) - - renderingPhase = "second-pass " - - finalEnv = mergedEnv - - vals, err = finalEnv.GetMergedValues() - if err != nil { - return nil, err - } - - if prestate != nil { - prestate.Env = *mergedEnv - r.logger.Debugf("vals:\n%v\ndefaultVals:%v", vals, prestate.DefaultValues) - } + vals, err = finalEnv.GetMergedValues() + if err != nil { + return nil, err } tmplData := state.NewEnvironmentTemplateData(*finalEnv, r.namespace, vals) diff --git a/pkg/app/two_pass_renderer_test.go b/pkg/app/two_pass_renderer_test.go index fde1630f..c209c78a 100644 --- a/pkg/app/two_pass_renderer_test.go +++ b/pkg/app/two_pass_renderer_test.go @@ -7,7 +7,6 @@ import ( "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/remote" - "github.com/helmfile/helmfile/pkg/runtime" "github.com/helmfile/helmfile/pkg/state" "github.com/helmfile/helmfile/pkg/testhelper" "github.com/helmfile/helmfile/pkg/yaml" @@ -165,20 +164,7 @@ releases: } func TestReadFromYaml_RenderTemplateLog(t *testing.T) { - v := runtime.V1Mode - t.Cleanup(func() { - runtime.V1Mode = v - }) - - t.Run("v0mode", func(t *testing.T) { - runtime.V1Mode = false - testReadFromYaml_RenderTemplateLog(t) - }) - - t.Run("v1mode", func(t *testing.T) { - runtime.V1Mode = true - testReadFromYaml_RenderTemplateLog(t) - }) + testReadFromYaml_RenderTemplateLog(t) } func TestReadFromYaml_RenderTemplateWithValuesReferenceError(t *testing.T) { diff --git a/pkg/config/apply.go b/pkg/config/apply.go index 4d67aa61..f3f0946f 100644 --- a/pkg/config/apply.go +++ b/pkg/config/apply.go @@ -18,10 +18,6 @@ type ApplyOptions struct { DetailedExitcode bool // StripTrailingCR is true if trailing carriage returns should be stripped during diffing StripTrailingCR bool - // TODO: Remove this function once Helmfile v0.x - // DEPRECATED: Use skip-cleanup instead - RetainValuesFiles bool - // SkipCleanup is true if the cleanup of temporary values files should be skipped SkipCleanup bool // SkipCRDs is true if the CRDs should be skipped @@ -139,12 +135,6 @@ func (a *ApplyImpl) IncludeTransitiveNeeds() bool { return a.ApplyOptions.IncludeTransitiveNeeds } -// TODO: Remove this function once Helmfile v0.x -// RetainValuesFiles returns the retain values files. -func (a *ApplyImpl) RetainValuesFiles() bool { - return a.ApplyOptions.RetainValuesFiles -} - // ShowSecrets returns the show secrets. func (a *ApplyImpl) ShowSecrets() bool { return a.ApplyOptions.ShowSecrets diff --git a/pkg/config/charts.go b/pkg/config/charts.go deleted file mode 100644 index 859894bc..00000000 --- a/pkg/config/charts.go +++ /dev/null @@ -1,46 +0,0 @@ -// TODO: Remove this function once Helmfile v0.x -package config - -// ChartsOptions is the options for the build command -type ChartsOptions struct { - // Set is the additional values to be merged into the helm command --set flag - Set []string - // Values is the additional value files to be merged into the helm command --values flag - Values []string - // Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited - Concurrency int -} - -// NewChartsOptions creates a new Apply -func NewChartsOptions() *ChartsOptions { - return &ChartsOptions{} -} - -// ChartsImpl is impl for applyOptions -type ChartsImpl struct { - *GlobalImpl - *ChartsOptions -} - -// NewChartsImpl creates a new ChartsImpl -func NewChartsImpl(g *GlobalImpl, b *ChartsOptions) *ChartsImpl { - return &ChartsImpl{ - GlobalImpl: g, - ChartsOptions: b, - } -} - -// Concurrency returns the concurrency -func (c *ChartsImpl) Concurrency() int { - return c.ChartsOptions.Concurrency -} - -// IncludeTransitiveNeeds returns the includeTransitiveNeeds -func (c *ChartsImpl) IncludeTransitiveNeeds() bool { - return false -} - -// Values returns the values -func (c *ChartsImpl) Values() []string { - return c.ChartsOptions.Values -} diff --git a/pkg/config/delete.go b/pkg/config/delete.go deleted file mode 100644 index f688e94f..00000000 --- a/pkg/config/delete.go +++ /dev/null @@ -1,67 +0,0 @@ -// TODO: Remove this function once Helmfile v0.x -package config - -// DeleteOptions is the options for the build command -type DeleteOptions struct { - // Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited - Concurrency int - // Purge is the purge flag - Purge bool - // SkipCharts makes Delete skip `withPreparedCharts` - SkipCharts bool - // Cascade '--cascade' to helmv3 delete, available values: background, foreground, or orphan, default: background - Cascade string - // Wait '--wait' if set, will wait until all the resources are deleted before returning. It will wait for as long as --timeout - DeleteWait bool - // Timeout '--timeout', to wait for helm delete operation (default 5m0s) - DeleteTimeout int -} - -// NewDeleteOptions creates a new Apply -func NewDeleteOptions() *DeleteOptions { - return &DeleteOptions{} -} - -// DeleteImpl is impl for applyOptions -type DeleteImpl struct { - *GlobalImpl - *DeleteOptions -} - -// NewDeleteImpl creates a new DeleteImpl -func NewDeleteImpl(g *GlobalImpl, b *DeleteOptions) *DeleteImpl { - return &DeleteImpl{ - GlobalImpl: g, - DeleteOptions: b, - } -} - -// Concurrency returns the concurrency -func (c *DeleteImpl) Concurrency() int { - return c.DeleteOptions.Concurrency -} - -// Purge returns the purge -func (c *DeleteImpl) Purge() bool { - return c.DeleteOptions.Purge -} - -// SkipCharts returns skipCharts flag -func (c *DeleteImpl) SkipCharts() bool { - return c.DeleteOptions.SkipCharts -} - -// Cascade returns cascade flag -func (c *DeleteImpl) Cascade() string { - return c.DeleteOptions.Cascade -} - -// DeleteWait returns the wait flag -func (c *DeleteImpl) DeleteWait() bool { - return c.DeleteOptions.DeleteWait -} - -// DeleteTimeout returns the timeout flag -func (c *DeleteImpl) DeleteTimeout() int { - return c.DeleteOptions.DeleteTimeout -} diff --git a/pkg/envvar/const.go b/pkg/envvar/const.go index 94df7381..0235af17 100644 --- a/pkg/envvar/const.go +++ b/pkg/envvar/const.go @@ -6,16 +6,12 @@ const ( // use helm status to check if a release exists before installing it UseHelmStatusToCheckReleaseExistence = "HELMFILE_USE_HELM_STATUS_TO_CHECK_RELEASE_EXISTENCE" - // TODO: Remove this function once Helmfile v0.x - SkipInsecureTemplateFunctions = "HELMFILE_SKIP_INSECURE_TEMPLATE_FUNCTIONS" - DisableRunnerUniqueID = "HELMFILE_DISABLE_RUNNER_UNIQUE_ID" Experimental = "HELMFILE_EXPERIMENTAL" // environment variable for experimental features, expecting "true" lower case Environment = "HELMFILE_ENVIRONMENT" FilePath = "HELMFILE_FILE_PATH" TempDir = "HELMFILE_TEMPDIR" UpgradeNoticeDisabled = "HELMFILE_UPGRADE_NOTICE_DISABLED" - V1Mode = "HELMFILE_V1MODE" GoccyGoYaml = "HELMFILE_GOCCY_GOYAML" CacheHome = "HELMFILE_CACHE_HOME" Interactive = "HELMFILE_INTERACTIVE" diff --git a/pkg/policy/checker.go b/pkg/policy/checker.go index b493d513..28db5d70 100644 --- a/pkg/policy/checker.go +++ b/pkg/policy/checker.go @@ -9,8 +9,6 @@ import ( "slices" "strings" "unicode" - - "github.com/helmfile/helmfile/pkg/runtime" ) var ( @@ -51,7 +49,7 @@ func forbidEnvironmentsWithReleases(filePath string, content []byte) (bool, erro } for i := 0; i < len(result)-1; i++ { if result[i] != "---" && result[i+1] != "---" { - return runtime.V1Mode, EnvironmentsAndReleasesWithinSameYamlPartErr + return true, EnvironmentsAndReleasesWithinSameYamlPartErr } } return false, nil @@ -123,7 +121,7 @@ func TopConfigKeysVerifier(filePath string, helmfileContent []byte) (bool, error preKey := orderKeys[i-1] currentKey := orderKeys[i] if topkeysPriority[preKey] > topkeysPriority[currentKey] { - return runtime.V1Mode, fmt.Errorf("top-level config key %s must be defined before %s in %s", currentKey, preKey, filePath) + return true, fmt.Errorf("top-level config key %s must be defined before %s in %s", currentKey, preKey, filePath) } } return false, nil diff --git a/pkg/policy/checker_test.go b/pkg/policy/checker_test.go index 7c28555c..e7e41811 100644 --- a/pkg/policy/checker_test.go +++ b/pkg/policy/checker_test.go @@ -4,15 +4,12 @@ import ( "testing" "github.com/stretchr/testify/require" - - "github.com/helmfile/helmfile/pkg/runtime" ) func TestForbidEnvironmentsWithReleases(t *testing.T) { testCases := []struct { name string filePath string - v1mode bool content []byte expectedErr bool isStrict bool @@ -21,7 +18,6 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) { name: "no error when only releases", filePath: "helmfile.yaml", content: []byte("releases:\n"), - v1mode: false, expectedErr: false, isStrict: false, }, @@ -29,7 +25,6 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) { name: "no error when only environments", filePath: "helmfile.yaml", content: []byte("environments:\n"), - v1mode: false, expectedErr: false, isStrict: false, }, @@ -37,7 +32,6 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) { name: "no error when has --- between releases and environments", filePath: "helmfile.yaml", content: []byte("environments:\n---\nreleases:\n"), - v1mode: false, expectedErr: false, isStrict: false, }, @@ -45,7 +39,6 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) { name: "no error when has --- between releases and environments, and --- on top of helmfile.yaml.gotmpl", filePath: "helmfile.yaml", content: []byte("---\nenvironments:\n---\nreleases:\n"), - v1mode: false, expectedErr: false, isStrict: false, }, @@ -53,7 +46,6 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) { name: "error when both releases and environments", filePath: "helmfile.yaml", content: []byte("environments:\nreleases:\n"), - v1mode: false, expectedErr: true, isStrict: false, }, @@ -61,20 +53,13 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) { name: "error when both releases and environments for plain yaml on v1", filePath: "helmfile.yaml", content: []byte("environments:\nreleases:\n"), - v1mode: true, expectedErr: true, isStrict: true, }, } - v1mode := runtime.V1Mode - t.Cleanup(func() { - runtime.V1Mode = v1mode - }) - for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - runtime.V1Mode = tc.v1mode isStrict, err := forbidEnvironmentsWithReleases(tc.filePath, tc.content) require.Equal(t, tc.isStrict, isStrict, "expected isStrict=%v, got=%v", tc.isStrict, isStrict) if tc.expectedErr { diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index e2e407b5..7c1e1d14 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -3,24 +3,15 @@ package runtime import ( "fmt" "os" - "strconv" "github.com/helmfile/helmfile/pkg/envvar" ) -// V1Mode is false by default for Helmfile v0.x and -// true by default for Helmfile v1.x var ( - V1Mode bool - // GoccyGoYaml is set to true in order to let Helmfile use // goccy/go-yaml instead of gopkg.in/yaml.v2. // It's false by default in Helmfile v0.x and true by default for Helmfile v1.x. GoccyGoYaml bool - - // We set this via ldflags at build-time so that we can use the - // value specified at the build time as the runtime default. - v1Mode string ) func Info() string { @@ -29,22 +20,10 @@ func Info() string { yamlLib = "goccy/go-yaml" } - return fmt.Sprintf("V1 mode = %v\nYAML library = %v", V1Mode, yamlLib) + return fmt.Sprintf("YAML library = %v", yamlLib) } func init() { - // You can toggle the V1 mode at runtime via an envvar: - // - Helmfile v1.x behaves like v0.x by running it with HELMFILE_V1MODE=false - // - Helmfile v0.x behaves like v1.x by with HELMFILE_V1MODE=true - switch os.Getenv(envvar.V1Mode) { - case "true": - V1Mode = true - case "false": - V1Mode = false - default: - V1Mode, _ = strconv.ParseBool(v1Mode) - } - // You can switch the YAML library at runtime via an envvar: switch os.Getenv(envvar.GoccyGoYaml) { case "true": @@ -52,6 +31,6 @@ func init() { case "false": GoccyGoYaml = false default: - GoccyGoYaml = V1Mode + GoccyGoYaml = true } } diff --git a/pkg/state/create.go b/pkg/state/create.go index c08086d4..248a3c85 100644 --- a/pkg/state/create.go +++ b/pkg/state/create.go @@ -117,20 +117,6 @@ func (c *StateCreator) Parse(content []byte, baseDir, file string) (*HelmState, } } - // TODO: Remove this function once Helmfile v0.x - if len(state.DeprecatedReleases) > 0 { - if len(state.Releases) > 0 { - return nil, fmt.Errorf("failed to parse %s: you can't specify both `charts` and `releases` sections", file) - } - state.Releases = state.DeprecatedReleases - state.DeprecatedReleases = []ReleaseSpec{} - } - - // TODO: Remove this function once Helmfile v0.x - if state.DeprecatedContext != "" && state.HelmDefaults.KubeContext == "" { - state.HelmDefaults.KubeContext = state.DeprecatedContext - } - if c.overrideHelmBinary != "" && c.overrideHelmBinary != DefaultHelmBinary { state.DefaultHelmBinary = c.overrideHelmBinary } else if state.DefaultHelmBinary == "" { diff --git a/pkg/state/create_test.go b/pkg/state/create_test.go index 46b1e072..4cc282be 100644 --- a/pkg/state/create_test.go +++ b/pkg/state/create_test.go @@ -280,26 +280,6 @@ func TestReadFromYaml_StrictUnmarshalling(t *testing.T) { } } -// TODO: Remove this function once Helmfile v0.x -func TestReadFromYaml_DeprecatedReleaseReferences(t *testing.T) { - yamlFile := "example/path/to/yaml/file" - yamlContent := []byte(`charts: -- name: myrelease - chart: mychart -`) - state, err := createFromYaml(yamlContent, yamlFile, DefaultEnv, logger) - if err != nil { - t.Errorf("unxpected error: %v", err) - } - - if state.Releases[0].Name != "myrelease" { - t.Errorf("unexpected release name: expected=myrelease actual=%s", state.Releases[0].Name) - } - if state.Releases[0].Chart != "mychart" { - t.Errorf("unexpected chart name: expected=mychart actual=%s", state.Releases[0].Chart) - } -} - func TestReadFromYaml_ConflictingReleasesConfig(t *testing.T) { yamlFile := "example/path/to/yaml/file" yamlContent := []byte(`charts: diff --git a/pkg/state/state.go b/pkg/state/state.go index a28c05d9..4d9e43e1 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -60,10 +60,6 @@ type ReleaseSetSpec struct { HelmDefaults HelmSpec `yaml:"helmDefaults,omitempty"` Helmfiles []SubHelmfileSpec `yaml:"helmfiles,omitempty"` - // TODO: Remove this function once Helmfile v0.x - DeprecatedContext string `yaml:"context,omitempty"` - DeprecatedReleases []ReleaseSpec `yaml:"charts,omitempty"` - OverrideKubeContext string `yaml:"kubeContext,omitempty"` OverrideNamespace string `yaml:"namespace,omitempty"` OverrideChart string `yaml:"chart,omitempty"` diff --git a/pkg/state/state_test.go b/pkg/state/state_test.go index 9072ea56..59210312 100644 --- a/pkg/state/state_test.go +++ b/pkg/state/state_test.go @@ -58,13 +58,9 @@ func TestHelmState_applyDefaultsTo(t *testing.T) { type fields struct { BaseChartPath string Context string - - // TODO: Remove this function once Helmfile v0.x - DeprecatedReleases []ReleaseSpec - - Namespace string - Repositories []RepositorySpec - Releases []ReleaseSpec + Namespace string + Repositories []RepositorySpec + Releases []ReleaseSpec } type args struct { spec ReleaseSpec @@ -89,12 +85,8 @@ func TestHelmState_applyDefaultsTo(t *testing.T) { fieldsWithNamespace := fields{ BaseChartPath: ".", Context: "test_context", - - // TODO: Remove this function once Helmfile v0.x - DeprecatedReleases: nil, - - Namespace: specWithNamespaceFromFields.Namespace, - Repositories: nil, + Namespace: specWithNamespaceFromFields.Namespace, + Repositories: nil, Releases: []ReleaseSpec{ specWithNamespace, }, @@ -148,10 +140,6 @@ func TestHelmState_applyDefaultsTo(t *testing.T) { state := &HelmState{ basePath: tt.fields.BaseChartPath, ReleaseSetSpec: ReleaseSetSpec{ - // TODO: Remove this function once Helmfile v0.x - DeprecatedContext: tt.fields.Context, - DeprecatedReleases: tt.fields.DeprecatedReleases, - OverrideNamespace: tt.fields.Namespace, Repositories: tt.fields.Repositories, Releases: tt.fields.Releases, @@ -740,9 +728,6 @@ func TestHelmState_flagsForUpgrade(t *testing.T) { state := &HelmState{ basePath: "./", ReleaseSetSpec: ReleaseSetSpec{ - // TODO: Remove this function once Helmfile v0.x - DeprecatedContext: "default", - Releases: []ReleaseSpec{*tt.release}, HelmDefaults: tt.defaults, }, @@ -904,9 +889,8 @@ func TestHelmState_flagsForTemplate(t *testing.T) { state := &HelmState{ basePath: "./", ReleaseSetSpec: ReleaseSetSpec{ - DeprecatedContext: "default", - Releases: []ReleaseSpec{*tt.release}, - HelmDefaults: tt.defaults, + Releases: []ReleaseSpec{*tt.release}, + HelmDefaults: tt.defaults, }, valsRuntime: valsRuntime, } diff --git a/pkg/tmpl/context_funcs.go b/pkg/tmpl/context_funcs.go index 12888a91..dac6be4a 100644 --- a/pkg/tmpl/context_funcs.go +++ b/pkg/tmpl/context_funcs.go @@ -19,7 +19,6 @@ import ( "github.com/helmfile/helmfile/pkg/envvar" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/maputil" - "github.com/helmfile/helmfile/pkg/runtime" "github.com/helmfile/helmfile/pkg/yaml" ) @@ -37,23 +36,10 @@ func (e DisableInsecureFeaturesError) Error() string { var ( disableInsecureFeatures bool - - // TODO: Remove this function once Helmfile v0.x - skipInsecureTemplateFunctions bool ) func init() { disableInsecureFeatures, _ = strconv.ParseBool(os.Getenv(envvar.DisableInsecureFeatures)) - - // TODO: Remove this function once Helmfile v0.x - skipInsecureTemplateFunctions, _ = strconv.ParseBool(os.Getenv(envvar.SkipInsecureTemplateFunctions)) - skipInsecureTemplateFunctions = func() bool { - if runtime.V1Mode { - return false - } - b, _ := strconv.ParseBool(os.Getenv(envvar.SkipInsecureTemplateFunctions)) - return b - }() } func (c *Context) createFuncMap() template.FuncMap { @@ -76,7 +62,7 @@ func (c *Context) createFuncMap() template.FuncMap { "fetchSecretValue": fetchSecretValue, "expandSecretRefs": fetchSecretValues, } - if c.preRender || skipInsecureTemplateFunctions { + if c.preRender { // disable potential side-effect template calls funcMap["exec"] = func(string, []any, ...string) (string, error) { return "", nil diff --git a/pkg/tmpl/context_funcs_test.go b/pkg/tmpl/context_funcs_test.go index e9e67e04..d1141d8e 100644 --- a/pkg/tmpl/context_funcs_test.go +++ b/pkg/tmpl/context_funcs_test.go @@ -46,30 +46,6 @@ func TestCreateFuncMap_DisabledInsecureFeatures(t *testing.T) { disableInsecureFeatures = currentVal } -// TODO: Remove this function once Helmfile v0.x -func TestCreateFuncMap_SkipInsecureTemplateFunctions(t *testing.T) { - if runtime.V1Mode { - t.Logf("SkipInsecureTemplateFunctions is not supported in V1 mode") - return - } - currentVal := skipInsecureTemplateFunctions - - { - skipInsecureTemplateFunctions = true - ctx := &Context{basePath: "."} - funcMaps := ctx.createFuncMap() - args := make([]any, 0) - actual1, err1 := funcMaps["exec"].(func(command string, args []any, inputs ...string) (string, error))("ls", args) - require.Equal(t, "", actual1) - require.ErrorIs(t, err1, nil) - actual2, err2 := funcMaps["readFile"].(func(filename string) (string, error))("context_funcs_test.go") - require.Equal(t, "", actual2) - require.ErrorIs(t, err2, nil) - } - - skipInsecureTemplateFunctions = currentVal -} - func newFSExpecting(expectedFilename string, expected string) *filesystem.FileSystem { return filesystem.FromFileSystem(filesystem.FileSystem{ ReadFile: func(filename string) ([]byte, error) { diff --git a/test/integration/test-cases/chart-needs.sh b/test/integration/test-cases/chart-needs.sh index 76cc3814..2ce8e63d 100644 --- a/test/integration/test-cases/chart-needs.sh +++ b/test/integration/test-cases/chart-needs.sh @@ -1,14 +1,7 @@ chart_need_case_input_dir="${cases_dir}/chart-needs/input" chart_need_case_output_dir="${cases_dir}/chart-needs/output" -config_file="helmfile.yaml" -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${chart_need_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi - +config_file="helmfile.yaml.gotmpl" chart_needs_tmp=$(mktemp -d) chart_needs_template_reverse=${chart_needs_tmp}/chart.needs.template.log chart_needs_lint_reverse=${chart_needs_tmp}/chart.needs.lint.log diff --git a/test/integration/test-cases/chart-needs/input/helmfile.yaml b/test/integration/test-cases/chart-needs/input/helmfile.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/chart-needs/input/helmfile.yaml rename to test/integration/test-cases/chart-needs/input/helmfile.yaml.gotmpl diff --git a/test/integration/test-cases/chartify-jsonPatches-and-strategicMergePatches.sh b/test/integration/test-cases/chartify-jsonPatches-and-strategicMergePatches.sh index 2fd4e5d3..ea5d4a22 100644 --- a/test/integration/test-cases/chartify-jsonPatches-and-strategicMergePatches.sh +++ b/test/integration/test-cases/chartify-jsonPatches-and-strategicMergePatches.sh @@ -1,14 +1,7 @@ chartify_jsonPatches_and_strategicMergePatches_case_input_dir="${cases_dir}/chartify-jsonPatches-and-strategicMergePatches/input" chartify_jsonPatches_and_strategicMergePatches_case_output_dir="${cases_dir}/chartify-jsonPatches-and-strategicMergePatches/output" -config_file="helmfile.yaml" -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${chartify_jsonPatches_and_strategicMergePatches_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi - +config_file="helmfile.yaml.gotmpl" chartify_jsonPatches_and_strategicMergePatches_tmp=$(mktemp -d) chartify_jsonPatches_and_strategicMergePatches_template_reverse=${chartify_jsonPatches_and_strategicMergePatches_tmp}/chartify_jsonPatches_and_strategicMergePatches.template.log diff --git a/test/integration/test-cases/chartify-jsonPatches-and-strategicMergePatches/input/helmfile.yaml b/test/integration/test-cases/chartify-jsonPatches-and-strategicMergePatches/input/helmfile.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/chartify-jsonPatches-and-strategicMergePatches/input/helmfile.yaml rename to test/integration/test-cases/chartify-jsonPatches-and-strategicMergePatches/input/helmfile.yaml.gotmpl diff --git a/test/integration/test-cases/chartify.sh b/test/integration/test-cases/chartify.sh index 963fbbd6..8c6e2d3a 100644 --- a/test/integration/test-cases/chartify.sh +++ b/test/integration/test-cases/chartify.sh @@ -1,14 +1,7 @@ chartify_case_input_dir="${cases_dir}/chartify/input" chartify_case_output_dir="${cases_dir}/chartify/output" -config_file="helmfile.yaml" -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${chartify_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi - +config_file="helmfile.yaml.gotmpl" chartify_tmp=$(mktemp -d) chartify_template_reverse=${chartify_tmp}/chartify.template.log diff --git a/test/integration/test-cases/chartify/input/helmfile.yaml b/test/integration/test-cases/chartify/input/helmfile.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/chartify/input/helmfile.yaml rename to test/integration/test-cases/chartify/input/helmfile.yaml.gotmpl diff --git a/test/integration/test-cases/cli-overwrite-environment-values.sh b/test/integration/test-cases/cli-overwrite-environment-values.sh index 48d9f2de..8e51e159 100644 --- a/test/integration/test-cases/cli-overwrite-environment-values.sh +++ b/test/integration/test-cases/cli-overwrite-environment-values.sh @@ -6,24 +6,12 @@ cli_overwrite_environment_values_reverse=${cli_overwrite_environment_values_tmp} case_title="cli overwrite environment values" -if [[ ${HELMFILE_V1MODE} = true ]]; then - test_start "$case_title for v1" - info "Comparing ${case_title} for v1 output ${cli_overwrite_environment_values_reverse} with ${cli_overwrite_environment_values_output_dir}/overwritten.yaml" - for i in $(seq 10); do - info "Comparing build/cli-overwrite-environment-values #$i" - ${helmfile} -f ${cli_overwrite_environment_values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 --state-values-set-string imageTag=1.23.3,zone="zone1,zone2" > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail" - diff -u ${cli_overwrite_environment_values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent" - echo code=$? - done - test_pass "cli overwrite environment values for v1" -else - test_start "${case_title}" - info "Comparing ${case_title} output ${cli_overwrite_environment_values_reverse} with ${cli_overwrite_environment_values_output_dir}/overwritten.yaml" - for i in $(seq 10); do - info "Comparing build/cli-overwrite-environment-values #$i" - ${helmfile} -f ${cli_overwrite_environment_values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 --state-values-set-string imageTag=1.23.3,zone="zone1,zone2" > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail" - diff -u ${cli_overwrite_environment_values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent" - echo code=$? - done - test_pass "${case_title}" -fi +test_start "$case_title" +info "Comparing ${case_title} for output ${cli_overwrite_environment_values_reverse} with ${cli_overwrite_environment_values_output_dir}/overwritten.yaml" +for i in $(seq 10); do + info "Comparing build/cli-overwrite-environment-values #$i" + ${helmfile} -f ${cli_overwrite_environment_values_input_dir}/input.yaml.gotmpl template --state-values-set ns=test3 --state-values-set-string imageTag=1.23.3,zone="zone1,zone2" > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail" + diff -u ${cli_overwrite_environment_values_output_dir}/output.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent" + echo code=$? +done +test_pass "cli overwrite environment values for v1" \ No newline at end of file diff --git a/test/integration/test-cases/cli-overwrite-environment-values/input/input.yaml b/test/integration/test-cases/cli-overwrite-environment-values/input/input.yaml deleted file mode 100644 index 28706d92..00000000 --- a/test/integration/test-cases/cli-overwrite-environment-values/input/input.yaml +++ /dev/null @@ -1,17 +0,0 @@ -environments: - default: - values: - - base.yaml - - override.yaml - -repositories: - - name: bitnami - url: https://charts.bitnami.com/bitnami - -releases: - - name: test - chart: bitnami/nginx - namespace: {{ .Values.ns }} - version: 13.2.27 - values: - - values.yaml.gotmpl diff --git a/test/integration/test-cases/cli-overwrite-environment-values/input/input_v1.yaml.gotmpl b/test/integration/test-cases/cli-overwrite-environment-values/input/input.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/cli-overwrite-environment-values/input/input_v1.yaml.gotmpl rename to test/integration/test-cases/cli-overwrite-environment-values/input/input.yaml.gotmpl diff --git a/test/integration/test-cases/cli-overwrite-environment-values/output/output.yaml b/test/integration/test-cases/cli-overwrite-environment-values/output/output.yaml index ae8f779c..ba0f5cd7 100644 --- a/test/integration/test-cases/cli-overwrite-environment-values/output/output.yaml +++ b/test/integration/test-cases/cli-overwrite-environment-values/output/output.yaml @@ -1,9 +1,3 @@ -Warning: environments and releases cannot be defined within the same YAML part. Use --- to extract the environments into a dedicated part -Warning: environments and releases cannot be defined within the same YAML part. Use --- to extract the environments into a dedicated part -Adding repo bitnami https://charts.bitnami.com/bitnami -"bitnami" has been added to your repositories - -Templating release=test, chart=bitnami/nginx --- # Source: nginx/templates/svc.yaml apiVersion: v1 @@ -57,6 +51,7 @@ spec: app.kubernetes.io/instance: test app.kubernetes.io/managed-by: Helm annotations: + zone: "zone1,zone2" spec: automountServiceAccountToken: false @@ -81,7 +76,7 @@ spec: initContainers: containers: - name: nginx - image: docker.io/bitnami/nginx:test3 + image: docker.io/bitnami/nginx:1.23.3 imagePullPolicy: "IfNotPresent" env: - name: BITNAMI_DEBUG diff --git a/test/integration/test-cases/cli-overwrite-environment-values/output/output_v1.yaml b/test/integration/test-cases/cli-overwrite-environment-values/output/output_v1.yaml deleted file mode 100644 index ba0f5cd7..00000000 --- a/test/integration/test-cases/cli-overwrite-environment-values/output/output_v1.yaml +++ /dev/null @@ -1,111 +0,0 @@ ---- -# Source: nginx/templates/svc.yaml -apiVersion: v1 -kind: Service -metadata: - name: test-nginx - namespace: "test3" - labels: - app.kubernetes.io/name: nginx - helm.sh/chart: nginx-13.2.27 - app.kubernetes.io/instance: test - app.kubernetes.io/managed-by: Helm - annotations: -spec: - type: LoadBalancer - sessionAffinity: None - externalTrafficPolicy: "Cluster" - ports: - - name: http - port: 80 - targetPort: http - selector: - app.kubernetes.io/name: nginx - app.kubernetes.io/instance: test ---- -# Source: nginx/templates/deployment.yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - name: test-nginx - namespace: "test3" - labels: - app.kubernetes.io/name: nginx - helm.sh/chart: nginx-13.2.27 - app.kubernetes.io/instance: test - app.kubernetes.io/managed-by: Helm -spec: - replicas: 1 - strategy: - rollingUpdate: {} - type: RollingUpdate - selector: - matchLabels: - app.kubernetes.io/name: nginx - app.kubernetes.io/instance: test - template: - metadata: - labels: - app.kubernetes.io/name: nginx - helm.sh/chart: nginx-13.2.27 - app.kubernetes.io/instance: test - app.kubernetes.io/managed-by: Helm - annotations: - zone: "zone1,zone2" - spec: - - automountServiceAccountToken: false - shareProcessNamespace: false - serviceAccountName: default - affinity: - podAffinity: - - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchLabels: - app.kubernetes.io/name: nginx - app.kubernetes.io/instance: test - topologyKey: kubernetes.io/hostname - weight: 1 - nodeAffinity: - - hostNetwork: false - hostIPC: false - initContainers: - containers: - - name: nginx - image: docker.io/bitnami/nginx:1.23.3 - imagePullPolicy: "IfNotPresent" - env: - - name: BITNAMI_DEBUG - value: "false" - - name: NGINX_HTTP_PORT_NUMBER - value: "8080" - envFrom: - ports: - - name: http - containerPort: 8080 - livenessProbe: - failureThreshold: 6 - initialDelaySeconds: 30 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 5 - tcpSocket: - port: http - readinessProbe: - failureThreshold: 3 - initialDelaySeconds: 5 - periodSeconds: 5 - successThreshold: 1 - timeoutSeconds: 3 - tcpSocket: - port: http - resources: - limits: {} - requests: {} - volumeMounts: - volumes: - diff --git a/test/integration/test-cases/happypath.sh b/test/integration/test-cases/happypath.sh index a9778a1d..2968a554 100644 --- a/test/integration/test-cases/happypath.sh +++ b/test/integration/test-cases/happypath.sh @@ -2,14 +2,7 @@ test_start "happypath - simple rollout of httpbin chart" happypath_case_input_dir="${cases_dir}/happypath/input" happypath_case_output_dir="${cases_dir}/happypath/output" -config_file="happypath.yaml" - -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${happypath_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi +config_file="happypath.yaml.gotmpl" info "Diffing ${happypath_case_input_dir}/${config_file}" bash -c "${helmfile} -f ${happypath_case_input_dir}/${config_file} diff --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff" diff --git a/test/integration/test-cases/happypath/input/happypath.yaml b/test/integration/test-cases/happypath/input/happypath.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/happypath/input/happypath.yaml rename to test/integration/test-cases/happypath/input/happypath.yaml.gotmpl diff --git a/test/integration/test-cases/postrender.sh b/test/integration/test-cases/postrender.sh index 5a1a2aee..dfeab508 100644 --- a/test/integration/test-cases/postrender.sh +++ b/test/integration/test-cases/postrender.sh @@ -1,14 +1,7 @@ postrender_case_input_dir="${cases_dir}/postrender/input" postrender_case_output_dir="${cases_dir}/postrender/output" -config_file="helmfile.yaml" -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${postrender_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi - +config_file="helmfile.yaml.gotmpl" postrender_diff_out_file=${postrender_case_output_dir}/diff-result if [[ $EXTRA_HELMFILE_FLAGS == *--enable-live-output* ]]; then postrender_diff_out_file=${postrender_case_output_dir}/diff-result-live diff --git a/test/integration/test-cases/postrender/input/helmfile.yaml b/test/integration/test-cases/postrender/input/helmfile.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/postrender/input/helmfile.yaml rename to test/integration/test-cases/postrender/input/helmfile.yaml.gotmpl diff --git a/test/integration/test-cases/regression.sh b/test/integration/test-cases/regression.sh index 8a68d491..bc2ea412 100644 --- a/test/integration/test-cases/regression.sh +++ b/test/integration/test-cases/regression.sh @@ -4,44 +4,20 @@ test_start "regression tests" regression_case_input_dir="${cases_dir}/regression/input" info "https://github.com/roboll/helmfile/issues/1857" -config_file="issue.1857.yaml" -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${regression_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi +config_file="issue.1857.yaml.gotmpl" (${helmfile} -f ${regression_case_input_dir}/${config_file} --state-values-set grafanaEnabled=true template | grep grafana 1>/dev/null) || fail "\"helmfile template\" shouldn't include grafana" ! (${helmfile} -f ${regression_case_input_dir}/${config_file} --state-values-set grafanaEnabled=false template | grep grafana) || fail "\"helmfile template\" shouldn't include grafana" info "https://github.com/roboll/helmfile/issues/1867" -config_file="issue.1867.yaml" -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${regression_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi +config_file="issue.1867.yaml.gotmpl" (${helmfile} -f ${regression_case_input_dir}/${config_file} template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail" info "https://github.com/roboll/helmfile/issues/2118" -config_file="issue.2118.yaml" -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${regression_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi +config_file="issue.2118.yaml.gotmpl" (${helmfile} -f ${regression_case_input_dir}/${config_file} template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail" info "https://github.com/helmfile/helmfile/issues/1682" -config_file="issue.1682.yaml" -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${regression_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi +config_file="issue.1682.yaml.gotmpl" (${helmfile} -f ${regression_case_input_dir}/${config_file} deps 1>/dev/null) || fail "\"helmfile deps\" shouldn't fail" test_pass "regression tests" \ No newline at end of file diff --git a/test/integration/test-cases/regression/input/issue.1682.yaml b/test/integration/test-cases/regression/input/issue.1682.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/regression/input/issue.1682.yaml rename to test/integration/test-cases/regression/input/issue.1682.yaml.gotmpl diff --git a/test/integration/test-cases/regression/input/issue.1857.yaml b/test/integration/test-cases/regression/input/issue.1857.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/regression/input/issue.1857.yaml rename to test/integration/test-cases/regression/input/issue.1857.yaml.gotmpl diff --git a/test/integration/test-cases/regression/input/issue.1867.yaml b/test/integration/test-cases/regression/input/issue.1867.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/regression/input/issue.1867.yaml rename to test/integration/test-cases/regression/input/issue.1867.yaml.gotmpl diff --git a/test/integration/test-cases/regression/input/issue.2118.yaml b/test/integration/test-cases/regression/input/issue.2118.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/regression/input/issue.2118.yaml rename to test/integration/test-cases/regression/input/issue.2118.yaml.gotmpl diff --git a/test/integration/test-cases/secretssops.sh b/test/integration/test-cases/secretssops.sh index b4c53f79..b5085275 100644 --- a/test/integration/test-cases/secretssops.sh +++ b/test/integration/test-cases/secretssops.sh @@ -4,13 +4,7 @@ sops="sops --hc-vault-transit $VAULT_ADDR/v1/sops/keys/key" secretssops_case_input_dir="${cases_dir}/secretssops/input" secretssops_case_output_dir="${cases_dir}/secretssops/output" -config_file="secretssops.yaml" -if [[ ${HELMFILE_V1MODE} = true ]]; then - pushd "${secretssops_case_input_dir}" - mv "${config_file}" "${config_file}.gotmpl" - config_file="${config_file}.gotmpl" - popd -fi +config_file="secretssops.yaml.gotmpl" mkdir -p ${secretssops_case_input_dir}/tmp diff --git a/test/integration/test-cases/secretssops/input/secretssops.yaml b/test/integration/test-cases/secretssops/input/secretssops.yaml.gotmpl similarity index 100% rename from test/integration/test-cases/secretssops/input/secretssops.yaml rename to test/integration/test-cases/secretssops/input/secretssops.yaml.gotmpl diff --git a/test/integration/test-cases/v1-subhelmfile-multi-bases-with-array-values.sh b/test/integration/test-cases/v1-subhelmfile-multi-bases-with-array-values.sh index a234fb19..ed69e186 100644 --- a/test/integration/test-cases/v1-subhelmfile-multi-bases-with-array-values.sh +++ b/test/integration/test-cases/v1-subhelmfile-multi-bases-with-array-values.sh @@ -1,19 +1,15 @@ -if [[ ${HELMFILE_V1MODE} = true ]]; then - v1_subhelmfile_multi_bases_with_array_values_input_dir="${cases_dir}/v1-subhelmfile-multi-bases-with-array-values/input" - v1_subhelmfile_multi_bases_with_array_values_output_dir="${cases_dir}/v1-subhelmfile-multi-bases-with-array-values/output" +v1_subhelmfile_multi_bases_with_array_values_input_dir="${cases_dir}/v1-subhelmfile-multi-bases-with-array-values/input" +v1_subhelmfile_multi_bases_with_array_values_output_dir="${cases_dir}/v1-subhelmfile-multi-bases-with-array-values/output" - yaml_overwrite_tmp=$(mktemp -d) - yaml_overwrite_reverse=${yaml_overwrite_tmp}/helmfile_template_result +yaml_overwrite_tmp=$(mktemp -d) +yaml_overwrite_reverse=${yaml_overwrite_tmp}/helmfile_template_result - test_start "v1 subhelmfile multi bases with array values" - info "Comparing v1 subhelmfile multi bases with array values output ${yaml_overwrite_reverse} with ${v1_subhelmfile_multi_bases_with_array_values_output_dir}/result" - for i in $(seq 10); do - info "Comparing build/v1-subhelmfile-multi-bases-with-array-values #$i" - ${helmfile} -f ${v1_subhelmfile_multi_bases_with_array_values_input_dir}/helmfile.yaml.gotmpl template -e dev &> ${yaml_overwrite_reverse} || fail "\"helmfile template\" shouldn't fail" - diff -u ${v1_subhelmfile_multi_bases_with_array_values_output_dir}/result ${yaml_overwrite_reverse} || fail "\"helmfile template\" should be consistent" - echo code=$? - done - test_pass "v1 subhelmfile multi bases with array values" -else - test_pass "[skipped] v1 subhelmfile multi bases with array values" -fi \ No newline at end of file +test_start "v1 subhelmfile multi bases with array values" +info "Comparing v1 subhelmfile multi bases with array values output ${yaml_overwrite_reverse} with ${v1_subhelmfile_multi_bases_with_array_values_output_dir}/result" +for i in $(seq 10); do + info "Comparing build/v1-subhelmfile-multi-bases-with-array-values #$i" + ${helmfile} -f ${v1_subhelmfile_multi_bases_with_array_values_input_dir}/helmfile.yaml.gotmpl template -e dev &> ${yaml_overwrite_reverse} || fail "\"helmfile template\" shouldn't fail" + diff -u ${v1_subhelmfile_multi_bases_with_array_values_output_dir}/result ${yaml_overwrite_reverse} || fail "\"helmfile template\" should be consistent" + echo code=$? +done +test_pass "v1 subhelmfile multi bases with array values" \ No newline at end of file diff --git a/test/integration/test-cases/yaml-overwrite.sh b/test/integration/test-cases/yaml-overwrite.sh index a4a45825..617d8f97 100644 --- a/test/integration/test-cases/yaml-overwrite.sh +++ b/test/integration/test-cases/yaml-overwrite.sh @@ -1,19 +1,15 @@ -if [[ ${HELMFILE_V1MODE} = true ]]; then - yaml_overwrite_case_input_dir="${cases_dir}/yaml-overwrite/input" - yaml_overwrite_case_output_dir="${cases_dir}/yaml-overwrite/output" +yaml_overwrite_case_input_dir="${cases_dir}/yaml-overwrite/input" +yaml_overwrite_case_output_dir="${cases_dir}/yaml-overwrite/output" - yaml_overwrite_tmp=$(mktemp -d) - yaml_overwrite_reverse=${yaml_overwrite_tmp}/yaml.override.build.yaml +yaml_overwrite_tmp=$(mktemp -d) +yaml_overwrite_reverse=${yaml_overwrite_tmp}/yaml.override.build.yaml - test_start "yaml overwrite feature" - info "Comparing yaml overwrite feature output ${yaml_overwrite_reverse} with ${yaml_overwrite_case_output_dir}/overwritten.yaml" - for i in $(seq 10); do - info "Comparing build/yaml-overwrite #$i" - ${helmfile} -f ${yaml_overwrite_case_input_dir}/issue.657.yaml.gotmpl template --skip-deps > ${yaml_overwrite_reverse} || fail "\"helmfile template\" shouldn't fail" - ./dyff between -bs ${yaml_overwrite_case_output_dir}/overwritten.yaml ${yaml_overwrite_reverse} || fail "\"helmfile template\" should be consistent" - echo code=$? - done - test_pass "yaml overwrite feature" -else - test_pass "[skipped] yaml overwrite feature" -fi \ No newline at end of file +test_start "yaml overwrite feature" +info "Comparing yaml overwrite feature output ${yaml_overwrite_reverse} with ${yaml_overwrite_case_output_dir}/overwritten.yaml" +for i in $(seq 10); do + info "Comparing build/yaml-overwrite #$i" + ${helmfile} -f ${yaml_overwrite_case_input_dir}/issue.657.yaml.gotmpl template --skip-deps > ${yaml_overwrite_reverse} || fail "\"helmfile template\" shouldn't fail" + ./dyff between -bs ${yaml_overwrite_case_output_dir}/overwritten.yaml ${yaml_overwrite_reverse} || fail "\"helmfile template\" should be consistent" + echo code=$? +done +test_pass "yaml overwrite feature" \ No newline at end of file