feat: mark deprecated args and cmd for v1 (#628)
* feat: mark deprecated args and cmd for v1 Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
db5c2a52d6
commit
8d96bbb0e4
|
|
@ -42,8 +42,8 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
|
||||||
f.BoolVar(&applyOptions.DetailedExitcode, "detailed-exitcode", false, "return a non-zero exit code 2 instead of 0 when there were changes detected AND the changes are synced successfully")
|
f.BoolVar(&applyOptions.DetailedExitcode, "detailed-exitcode", false, "return a non-zero exit code 2 instead of 0 when there were changes detected AND the changes are synced successfully")
|
||||||
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
|
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
|
||||||
if !runtime.V1Mode {
|
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.BoolVar(&applyOptions.RetainValuesFiles, "retain-values-files", false, "DEPRECATED: Use skip-cleanup instead")
|
||||||
// mark retain-values-files as deprecated, but keep it for backward compatibility, will be removed in the future
|
|
||||||
_ = f.MarkDeprecated("retain-values-files", "Use skip-cleanup instead")
|
_ = f.MarkDeprecated("retain-values-files", "Use skip-cleanup instead")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ func NewRootCmd(globalConfig *config.GlobalOptions) (*cobra.Command, error) {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
if !runtime.V1Mode {
|
if !runtime.V1Mode {
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
NewChartsCmd(globalImpl),
|
NewChartsCmd(globalImpl),
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ func (a *App) Repos(c ReposConfigProvider) error {
|
||||||
}, c.IncludeTransitiveNeeds(), SetFilter(true))
|
}, c.IncludeTransitiveNeeds(), SetFilter(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
func (a *App) DeprecatedSyncCharts(c DeprecatedChartsConfigProvider) error {
|
func (a *App) DeprecatedSyncCharts(c DeprecatedChartsConfigProvider) error {
|
||||||
return a.ForEachState(func(run *Run) (_ bool, errs []error) {
|
return a.ForEachState(func(run *Run) (_ bool, errs []error) {
|
||||||
err := run.withPreparedCharts("charts", state.ChartPrepareOptions{
|
err := run.withPreparedCharts("charts", state.ChartPrepareOptions{
|
||||||
|
|
@ -457,6 +458,7 @@ func (a *App) Status(c StatusesConfigProvider) error {
|
||||||
}, false, SetFilter(true))
|
}, false, SetFilter(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
func (a *App) Delete(c DeleteConfigProvider) error {
|
func (a *App) Delete(c DeleteConfigProvider) error {
|
||||||
return a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
return a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
||||||
err := run.withPreparedCharts("delete", state.ChartPrepareOptions{
|
err := run.withPreparedCharts("delete", state.ChartPrepareOptions{
|
||||||
|
|
@ -1166,6 +1168,8 @@ func (a *App) findDesiredStateFiles(specifiedPath string, opts LoadOpts) ([]stri
|
||||||
var defaultFile string
|
var defaultFile string
|
||||||
if a.fs.FileExistsAt(DefaultHelmfile) {
|
if a.fs.FileExistsAt(DefaultHelmfile) {
|
||||||
defaultFile = DefaultHelmfile
|
defaultFile = DefaultHelmfile
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
} else if a.fs.FileExistsAt(DeprecatedHelmfile) {
|
} else if a.fs.FileExistsAt(DeprecatedHelmfile) {
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"warn: %s is being loaded: %s is deprecated in favor of %s. See https://github.com/roboll/helmfile/issues/25 for more information",
|
"warn: %s is being loaded: %s is deprecated in favor of %s. See https://github.com/roboll/helmfile/issues/25 for more information",
|
||||||
|
|
|
||||||
|
|
@ -2310,9 +2310,12 @@ func (c configImpl) PostRenderer() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type applyConfig struct {
|
type applyConfig struct {
|
||||||
args string
|
args string
|
||||||
values []string
|
values []string
|
||||||
retainValuesFiles bool
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
|
retainValuesFiles bool
|
||||||
|
|
||||||
set []string
|
set []string
|
||||||
validate bool
|
validate bool
|
||||||
skipCleanup bool
|
skipCleanup bool
|
||||||
|
|
@ -2450,6 +2453,7 @@ func (a applyConfig) Logger() *zap.SugaredLogger {
|
||||||
return a.logger
|
return a.logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
func (a applyConfig) RetainValuesFiles() bool {
|
func (a applyConfig) RetainValuesFiles() bool {
|
||||||
return a.retainValuesFiles
|
return a.retainValuesFiles
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ type ConfigProvider interface {
|
||||||
loggingConfig
|
loggingConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
type DeprecatedChartsConfigProvider interface {
|
type DeprecatedChartsConfigProvider interface {
|
||||||
Values() []string
|
Values() []string
|
||||||
|
|
||||||
|
|
@ -66,7 +67,9 @@ type ApplyConfigProvider interface {
|
||||||
Context() int
|
Context() int
|
||||||
DiffOutput() string
|
DiffOutput() string
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
RetainValuesFiles() bool
|
RetainValuesFiles() bool
|
||||||
|
|
||||||
Validate() bool
|
Validate() bool
|
||||||
SkipCleanup() bool
|
SkipCleanup() bool
|
||||||
SkipDiffOnInstall() bool
|
SkipDiffOnInstall() bool
|
||||||
|
|
@ -133,6 +136,7 @@ type DiffConfigProvider interface {
|
||||||
valuesControlMode
|
valuesControlMode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
type DeleteConfigProvider interface {
|
type DeleteConfigProvider interface {
|
||||||
Args() string
|
Args() string
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultHelmfile = "helmfile.yaml"
|
DefaultHelmfile = "helmfile.yaml"
|
||||||
DeprecatedHelmfile = "charts.yaml"
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
|
DeprecatedHelmfile = "charts.yaml"
|
||||||
|
|
||||||
DefaultHelmfileDirectory = "helmfile.d"
|
DefaultHelmfileDirectory = "helmfile.d"
|
||||||
ExperimentalSelectorExplicit = "explicit-selector-inheritance" // value to remove default selector inheritance to sub-helmfiles and use the explicit one
|
ExperimentalSelectorExplicit = "explicit-selector-inheritance" // value to remove default selector inheritance to sub-helmfiles and use the explicit one
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ func (r *Run) Repos(c ReposConfigProvider) error {
|
||||||
return r.ctx.SyncReposOnce(r.state, r.helm)
|
return r.ctx.SyncReposOnce(r.state, r.helm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
func (r *Run) DeprecatedSyncCharts(c DeprecatedChartsConfigProvider) []error {
|
func (r *Run) DeprecatedSyncCharts(c DeprecatedChartsConfigProvider) []error {
|
||||||
st := r.state
|
st := r.state
|
||||||
helm := r.helm
|
helm := r.helm
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,11 @@ type ApplyOptions struct {
|
||||||
Output string
|
Output string
|
||||||
// DetailedExitcode is true if the exit code should be 2 instead of 0 if there were changes detected and the changes were synced successfully
|
// DetailedExitcode is true if the exit code should be 2 instead of 0 if there were changes detected and the changes were synced successfully
|
||||||
DetailedExitcode bool
|
DetailedExitcode bool
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
// DEPRECATED: Use skip-cleanup instead
|
// DEPRECATED: Use skip-cleanup instead
|
||||||
RetainValuesFiles bool
|
RetainValuesFiles bool
|
||||||
|
|
||||||
// SkipCleanup is true if the cleanup of temporary values files should be skipped
|
// SkipCleanup is true if the cleanup of temporary values files should be skipped
|
||||||
SkipCleanup bool
|
SkipCleanup bool
|
||||||
// SkipCRDs is true if the CRDs should be skipped
|
// SkipCRDs is true if the CRDs should be skipped
|
||||||
|
|
@ -113,6 +116,7 @@ func (a *ApplyImpl) IncludeTransitiveNeeds() bool {
|
||||||
return a.ApplyOptions.IncludeTransitiveNeeds
|
return a.ApplyOptions.IncludeTransitiveNeeds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
// RetainValuesFiles returns the retain values files.
|
// RetainValuesFiles returns the retain values files.
|
||||||
func (a *ApplyImpl) RetainValuesFiles() bool {
|
func (a *ApplyImpl) RetainValuesFiles() bool {
|
||||||
return a.ApplyOptions.RetainValuesFiles
|
return a.ApplyOptions.RetainValuesFiles
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
package config
|
package config
|
||||||
|
|
||||||
// ChartsOptions is the options for the build command
|
// ChartsOptions is the options for the build command
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
package config
|
package config
|
||||||
|
|
||||||
// DeleteOptions is the options for the build command
|
// DeleteOptions is the options for the build command
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ 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.DeprecatedReleases) > 0 {
|
||||||
if len(state.Releases) > 0 {
|
if len(state.Releases) > 0 {
|
||||||
return nil, fmt.Errorf("failed to parse %s: you can't specify both `charts` and `releases` sections", file)
|
return nil, fmt.Errorf("failed to parse %s: you can't specify both `charts` and `releases` sections", file)
|
||||||
|
|
@ -116,6 +117,7 @@ func (c *StateCreator) Parse(content []byte, baseDir, file string) (*HelmState,
|
||||||
state.DeprecatedReleases = []ReleaseSpec{}
|
state.DeprecatedReleases = []ReleaseSpec{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
if state.DeprecatedContext != "" && state.HelmDefaults.KubeContext == "" {
|
if state.DeprecatedContext != "" && state.HelmDefaults.KubeContext == "" {
|
||||||
state.HelmDefaults.KubeContext = state.DeprecatedContext
|
state.HelmDefaults.KubeContext = state.DeprecatedContext
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -279,6 +279,7 @@ func TestReadFromYaml_StrictUnmarshalling(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
func TestReadFromYaml_DeprecatedReleaseReferences(t *testing.T) {
|
func TestReadFromYaml_DeprecatedReleaseReferences(t *testing.T) {
|
||||||
yamlFile := "example/path/to/yaml/file"
|
yamlFile := "example/path/to/yaml/file"
|
||||||
yamlContent := []byte(`charts:
|
yamlContent := []byte(`charts:
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,14 @@ type ReleaseSetSpec struct {
|
||||||
|
|
||||||
Environments map[string]EnvironmentSpec `yaml:"environments,omitempty"`
|
Environments map[string]EnvironmentSpec `yaml:"environments,omitempty"`
|
||||||
|
|
||||||
Bases []string `yaml:"bases,omitempty"`
|
Bases []string `yaml:"bases,omitempty"`
|
||||||
HelmDefaults HelmSpec `yaml:"helmDefaults,omitempty"`
|
HelmDefaults HelmSpec `yaml:"helmDefaults,omitempty"`
|
||||||
Helmfiles []SubHelmfileSpec `yaml:"helmfiles,omitempty"`
|
Helmfiles []SubHelmfileSpec `yaml:"helmfiles,omitempty"`
|
||||||
DeprecatedContext string `yaml:"context,omitempty"`
|
|
||||||
DeprecatedReleases []ReleaseSpec `yaml:"charts,omitempty"`
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
|
DeprecatedContext string `yaml:"context,omitempty"`
|
||||||
|
DeprecatedReleases []ReleaseSpec `yaml:"charts,omitempty"`
|
||||||
|
|
||||||
OverrideKubeContext string `yaml:"kubeContext,omitempty"`
|
OverrideKubeContext string `yaml:"kubeContext,omitempty"`
|
||||||
OverrideNamespace string `yaml:"namespace,omitempty"`
|
OverrideNamespace string `yaml:"namespace,omitempty"`
|
||||||
OverrideChart string `yaml:"chart,omitempty"`
|
OverrideChart string `yaml:"chart,omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,15 @@ func TestLabelParsing(t *testing.T) {
|
||||||
|
|
||||||
func TestHelmState_applyDefaultsTo(t *testing.T) {
|
func TestHelmState_applyDefaultsTo(t *testing.T) {
|
||||||
type fields struct {
|
type fields struct {
|
||||||
BaseChartPath string
|
BaseChartPath string
|
||||||
Context string
|
Context string
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
DeprecatedReleases []ReleaseSpec
|
DeprecatedReleases []ReleaseSpec
|
||||||
Namespace string
|
|
||||||
Repositories []RepositorySpec
|
Namespace string
|
||||||
Releases []ReleaseSpec
|
Repositories []RepositorySpec
|
||||||
|
Releases []ReleaseSpec
|
||||||
}
|
}
|
||||||
type args struct {
|
type args struct {
|
||||||
spec ReleaseSpec
|
spec ReleaseSpec
|
||||||
|
|
@ -82,11 +85,14 @@ func TestHelmState_applyDefaultsTo(t *testing.T) {
|
||||||
specWithNamespaceFromFields.Namespace = "test-namespace-field"
|
specWithNamespaceFromFields.Namespace = "test-namespace-field"
|
||||||
|
|
||||||
fieldsWithNamespace := fields{
|
fieldsWithNamespace := fields{
|
||||||
BaseChartPath: ".",
|
BaseChartPath: ".",
|
||||||
Context: "test_context",
|
Context: "test_context",
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
DeprecatedReleases: nil,
|
DeprecatedReleases: nil,
|
||||||
Namespace: specWithNamespaceFromFields.Namespace,
|
|
||||||
Repositories: nil,
|
Namespace: specWithNamespaceFromFields.Namespace,
|
||||||
|
Repositories: nil,
|
||||||
Releases: []ReleaseSpec{
|
Releases: []ReleaseSpec{
|
||||||
specWithNamespace,
|
specWithNamespace,
|
||||||
},
|
},
|
||||||
|
|
@ -140,11 +146,13 @@ func TestHelmState_applyDefaultsTo(t *testing.T) {
|
||||||
state := &HelmState{
|
state := &HelmState{
|
||||||
basePath: tt.fields.BaseChartPath,
|
basePath: tt.fields.BaseChartPath,
|
||||||
ReleaseSetSpec: ReleaseSetSpec{
|
ReleaseSetSpec: ReleaseSetSpec{
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
DeprecatedContext: tt.fields.Context,
|
DeprecatedContext: tt.fields.Context,
|
||||||
DeprecatedReleases: tt.fields.DeprecatedReleases,
|
DeprecatedReleases: tt.fields.DeprecatedReleases,
|
||||||
OverrideNamespace: tt.fields.Namespace,
|
|
||||||
Repositories: tt.fields.Repositories,
|
OverrideNamespace: tt.fields.Namespace,
|
||||||
Releases: tt.fields.Releases,
|
Repositories: tt.fields.Repositories,
|
||||||
|
Releases: tt.fields.Releases,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if state.ApplyOverrides(&tt.args.spec); !reflect.DeepEqual(tt.args.spec, tt.want) {
|
if state.ApplyOverrides(&tt.args.spec); !reflect.DeepEqual(tt.args.spec, tt.want) {
|
||||||
|
|
@ -768,9 +776,11 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||||
state := &HelmState{
|
state := &HelmState{
|
||||||
basePath: "./",
|
basePath: "./",
|
||||||
ReleaseSetSpec: ReleaseSetSpec{
|
ReleaseSetSpec: ReleaseSetSpec{
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
DeprecatedContext: "default",
|
DeprecatedContext: "default",
|
||||||
Releases: []ReleaseSpec{*tt.release},
|
|
||||||
HelmDefaults: tt.defaults,
|
Releases: []ReleaseSpec{*tt.release},
|
||||||
|
HelmDefaults: tt.defaults,
|
||||||
},
|
},
|
||||||
valsRuntime: valsRuntime,
|
valsRuntime: valsRuntime,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue