From af52c960f4da9ff401d3e9739d4051f91ddc588a Mon Sep 17 00:00:00 2001 From: Viktor Oreshkin Date: Tue, 6 Sep 2022 09:54:51 +0300 Subject: [PATCH] chore: list: withPreparedCharts -> skipCharts Signed-off-by: Viktor Oreshkin --- cmd/list.go | 5 +---- pkg/app/app.go | 2 +- pkg/app/app_list_test.go | 16 ++++++++-------- pkg/app/app_test.go | 6 +++--- pkg/app/config.go | 2 +- pkg/config/list.go | 10 +++++----- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/cmd/list.go b/cmd/list.go index a1fbbb4d..26488d41 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -9,7 +9,6 @@ import ( // NewListCmd returns list subcmd func NewListCmd(globalCfg *config.GlobalImpl) *cobra.Command { - var skipCharts bool listOptions := config.NewListOptions() listImpl := config.NewListImpl(globalCfg, listOptions) @@ -17,8 +16,6 @@ func NewListCmd(globalCfg *config.GlobalImpl) *cobra.Command { Use: "list", Short: "List releases defined in state file", RunE: func(cmd *cobra.Command, args []string) error { - listOptions.WithPreparedCharts = !skipCharts - err := config.NewCLIConfigImpl(listImpl.GlobalImpl) if err != nil { return err @@ -35,7 +32,7 @@ func NewListCmd(globalCfg *config.GlobalImpl) *cobra.Command { f := cmd.Flags() f.BoolVar(&listOptions.KeepTempDir, "keep-temp-dir", false, "Keep temporary directory") - f.BoolVar(&skipCharts, "skip-charts", false, "don't prepare charts when listing releases") + f.BoolVar(&listOptions.SkipCharts, "skip-charts", false, "don't prepare charts when listing releases") f.StringVar(&listOptions.Output, "output", "", "output releases list as a json string") return cmd diff --git a/pkg/app/app.go b/pkg/app/app.go index 4bdf4a39..32ed2b60 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -550,7 +550,7 @@ func (a *App) ListReleases(c ListConfigProvider) error { var stateReleases []*HelmRelease var err error - if c.WithPreparedCharts() { + if !c.SkipCharts() { err = run.withPreparedCharts("list", state.ChartPrepareOptions{ SkipRepos: true, SkipDeps: true, diff --git a/pkg/app/app_list_test.go b/pkg/app/app_list_test.go index 05b6b543..528810ee 100644 --- a/pkg/app/app_list_test.go +++ b/pkg/app/app_list_test.go @@ -249,11 +249,11 @@ database my-app true true bitnami/postg } func TestListWithEnvironment(t *testing.T) { - t.Run("with prepared charts", func(t *testing.T) { - testListWithEnvironment(t, configImpl{withPreparedCharts: true}) + t.Run("with skipCharts=false", func(t *testing.T) { + testListWithEnvironment(t, configImpl{skipCharts: false}) }) - t.Run("without prepared charts", func(t *testing.T) { - testListWithEnvironment(t, configImpl{withPreparedCharts: false}) + t.Run("with skipCharts=true", func(t *testing.T) { + testListWithEnvironment(t, configImpl{skipCharts: true}) }) } @@ -316,10 +316,10 @@ releases: } func TestListWithJSONOutput(t *testing.T) { - t.Run("with prepared charts", func(t *testing.T) { - testListWithJSONOutput(t, configImpl{withPreparedCharts: true}) + t.Run("with skipCharts=false", func(t *testing.T) { + testListWithJSONOutput(t, configImpl{skipCharts: false}) }) - t.Run("without prepared charts", func(t *testing.T) { - testListWithJSONOutput(t, configImpl{withPreparedCharts: false}) + t.Run("with skipCharts=true", func(t *testing.T) { + testListWithJSONOutput(t, configImpl{skipCharts: true}) }) } diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index 15bfe67a..97954f7e 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -2220,7 +2220,7 @@ type configImpl struct { skipNeeds bool includeNeeds bool includeTransitiveNeeds bool - withPreparedCharts bool + skipCharts bool } func (c configImpl) Selectors() []string { @@ -2295,8 +2295,8 @@ func (c configImpl) Output() string { return c.output } -func (c configImpl) WithPreparedCharts() bool { - return c.withPreparedCharts +func (c configImpl) SkipCharts() bool { + return c.skipCharts } type applyConfig struct { diff --git a/pkg/app/config.go b/pkg/app/config.go index 1e268508..a66eff6b 100644 --- a/pkg/app/config.go +++ b/pkg/app/config.go @@ -236,7 +236,7 @@ type interactive interface { type ListConfigProvider interface { Output() string - WithPreparedCharts() bool + SkipCharts() bool } type CacheConfigProvider interface{} diff --git a/pkg/config/list.go b/pkg/config/list.go index 64645847..b4e76f8a 100644 --- a/pkg/config/list.go +++ b/pkg/config/list.go @@ -6,8 +6,8 @@ type ListOptions struct { Output string // KeepTempDir is the keep temp dir flag KeepTempDir bool - // WithPreparedCharts makes list call `withPreparedCharts` when listing - WithPreparedCharts bool + // SkipCharts makes List skip `withPreparedCharts` + SkipCharts bool } // NewListOptions creates a new Apply @@ -39,7 +39,7 @@ func (c *ListImpl) Output() string { return c.ListOptions.Output } -// WithPreparedCharts returns withPreparedCharts flag -func (c *ListImpl) WithPreparedCharts() bool { - return c.ListOptions.WithPreparedCharts +// SkipCharts returns skipCharts flag +func (c *ListImpl) SkipCharts() bool { + return c.ListOptions.SkipCharts }