From 6a37ae9650d4e1b3e408d57ba8d159568f6da608 Mon Sep 17 00:00:00 2001 From: yxxhero <11087727+yxxhero@users.noreply.github.com> Date: Mon, 8 Aug 2022 09:32:30 +0800 Subject: [PATCH] Add flags about need for lint subcmd (#273) * fix typo Signed-off-by: yxxhero * add flags about needs for lint subcmd Signed-off-by: yxxhero --- cmd/apply.go | 2 +- cmd/build.go | 2 +- cmd/cache.go | 2 +- cmd/charts.go | 2 +- cmd/delete.go | 2 +- cmd/deps.go | 2 +- cmd/destroy.go | 2 +- cmd/diff.go | 2 +- cmd/fetch.go | 2 +- cmd/lint.go | 13 +++++++----- cmd/list.go | 2 +- cmd/repos.go | 2 +- cmd/status.go | 2 +- cmd/sync.go | 2 +- cmd/template.go | 2 +- cmd/test.go | 2 +- cmd/version.go | 2 +- cmd/write-values.go | 2 +- pkg/config/lint.go | 49 +++++++++++++++++++++++++++------------------ 19 files changed, 55 insertions(+), 41 deletions(-) diff --git a/cmd/apply.go b/cmd/apply.go index f3bcd74b..01dc8f67 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewApplyCmd returm apply subcmd +// NewApplyCmd returns apply subcmd func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command { applyOptions := &config.ApplyOptions{} applyImpl := config.NewApplyImpl(globalCfg, applyOptions) diff --git a/cmd/build.go b/cmd/build.go index b21bec48..44e9cd2e 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewBuildCmd returm build subcmd +// NewBuildCmd returns build subcmd func NewBuildCmd(globalCfg *config.GlobalImpl) *cobra.Command { buildOptions := config.NewBuildOptions() buildImpl := config.NewBuildImpl(globalCfg, buildOptions) diff --git a/cmd/cache.go b/cmd/cache.go index 3ccd9234..ab7e3bd6 100644 --- a/cmd/cache.go +++ b/cmd/cache.go @@ -49,7 +49,7 @@ func NewCacheCleanupSubcommand(cacheImpl *config.CacheImpl) *cobra.Command { return cmd } -// NewCacheCmd returm cache subcmd +// NewCacheCmd returns cache subcmd func NewCacheCmd(globalCfg *config.GlobalImpl) *cobra.Command { cacheOptions := config.NewCacheOptions() cacheImpl := config.NewCacheImpl(globalCfg, cacheOptions) diff --git a/cmd/charts.go b/cmd/charts.go index ee88a384..9ad0e08b 100644 --- a/cmd/charts.go +++ b/cmd/charts.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewChartsCmd returm build subcmd +// NewChartsCmd returns charts subcmd func NewChartsCmd(globalCfg *config.GlobalImpl) *cobra.Command { chartsOptions := config.NewChartsOptions() chartsImpl := config.NewChartsImpl(globalCfg, chartsOptions) diff --git a/cmd/delete.go b/cmd/delete.go index 7b22ad23..26cbad75 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewDeleteCmd returm build subcmd +// NewDeleteCmd returns delete subcmd func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command { deleteOptions := config.NewDeleteOptions() deleteImpl := config.NewDeleteImpl(globalCfg, deleteOptions) diff --git a/cmd/deps.go b/cmd/deps.go index ab5f2bc4..6018f1fe 100644 --- a/cmd/deps.go +++ b/cmd/deps.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewDepsCmd returm build subcmd +// NewDepsCmd returns deps subcmd func NewDepsCmd(globalCfg *config.GlobalImpl) *cobra.Command { depsOptions := config.NewDepsOptions() depsImpl := config.NewDepsImpl(globalCfg, depsOptions) diff --git a/cmd/destroy.go b/cmd/destroy.go index a88f36da..50a5a314 100644 --- a/cmd/destroy.go +++ b/cmd/destroy.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewDestroyCmd returm build subcmd +// NewDestroyCmd returns destroy subcmd func NewDestroyCmd(globalCfg *config.GlobalImpl) *cobra.Command { destroyOptions := config.NewDestroyOptions() destroyImpl := config.NewDestroyImpl(globalCfg, destroyOptions) diff --git a/cmd/diff.go b/cmd/diff.go index 3114ee58..9a168e53 100644 --- a/cmd/diff.go +++ b/cmd/diff.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewDiffCmd returm build subcmd +// NewDiffCmd returns diff subcmd func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command { diffOptions := config.NewDiffOptions() diffImpl := config.NewDiffImpl(globalCfg, diffOptions) diff --git a/cmd/fetch.go b/cmd/fetch.go index db2a5eb0..fb21703d 100644 --- a/cmd/fetch.go +++ b/cmd/fetch.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewFetchCmd returm build subcmd +// NewFetchCmd returns diff subcmd func NewFetchCmd(globalCfg *config.GlobalImpl) *cobra.Command { fetchOptions := config.NewFetchOptions() fetchImpl := config.NewFetchImpl(globalCfg, fetchOptions) diff --git a/cmd/lint.go b/cmd/lint.go index 99e252eb..40100a73 100644 --- a/cmd/lint.go +++ b/cmd/lint.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewLintCmd returm build subcmd +// NewLintCmd returns lint subcmd func NewLintCmd(globalCfg *config.GlobalImpl) *cobra.Command { lintOptions := config.NewLintOptions() lintImpl := config.NewLintImpl(globalCfg, lintOptions) @@ -31,10 +31,13 @@ func NewLintCmd(globalCfg *config.GlobalImpl) *cobra.Command { f := cmd.Flags() f.IntVar(&lintOptions.Concurrency, "concurrency", 0, "maximum number of concurrent downloads of release charts") - f.BoolVar(&lintOptions.SkipDeps, "skip-deps", lintOptions.SkipDeps, `skip running "helm repo update" and "helm dependency build"`) - f.StringVar(&lintOptions.Args, "args", lintOptions.Args, "pass args to helm exec") - f.StringArrayVar(&lintOptions.Set, "set", lintOptions.Set, "additional values to be merged into the command") - f.StringArrayVar(&lintOptions.Values, "values", lintOptions.Values, "additional value files to be merged into the command") + f.BoolVar(&lintOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) + f.StringVar(&lintOptions.Args, "args", "", "pass args to helm exec") + f.StringArrayVar(&lintOptions.Set, "set", nil, "additional values to be merged into the command") + f.StringArrayVar(&lintOptions.Values, "values", nil, "additional value files to be merged into the command") + f.BoolVar(&lintOptions.SkipNeeds, "skip-needs", false, `do not automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided. Defaults to true when --include-needs or --include-transitive-needs is not provided`) + f.BoolVar(&lintOptions.IncludeNeeds, "include-needs", false, `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided`) + f.BoolVar(&lintOptions.IncludeTransitiveNeeds, "include-transitive-needs", false, `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`) return cmd } diff --git a/cmd/list.go b/cmd/list.go index 5b2c7997..8ed6248c 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewListCmd returm build subcmd +// NewListCmd returns list subcmd func NewListCmd(globalCfg *config.GlobalImpl) *cobra.Command { listOptions := config.NewListOptions() listImpl := config.NewListImpl(globalCfg, listOptions) diff --git a/cmd/repos.go b/cmd/repos.go index 5cf1fe87..0940f005 100644 --- a/cmd/repos.go +++ b/cmd/repos.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewReposCmd returm build subcmd +// NewReposCmd returns repos subcmd func NewReposCmd(globalCfg *config.GlobalImpl) *cobra.Command { reposOptions := config.NewReposOptions() reposImpl := config.NewReposImpl(globalCfg, reposOptions) diff --git a/cmd/status.go b/cmd/status.go index 8b30a107..d9f5f2c3 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewStatusCmd returm build subcmd +// NewStatusCmd returns status subcmd func NewStatusCmd(globalCfg *config.GlobalImpl) *cobra.Command { statusOptions := config.NewStatusOptions() statusImpl := config.NewStatusImpl(globalCfg, statusOptions) diff --git a/cmd/sync.go b/cmd/sync.go index 7f7a86c3..2fe481b8 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewSyncCmd returm build subcmd +// NewSyncCmd returns sync subcmd func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command { syncOptions := config.NewSyncOptions() syncImpl := config.NewSyncImpl(globalCfg, syncOptions) diff --git a/cmd/template.go b/cmd/template.go index a2d57306..9b821d3b 100644 --- a/cmd/template.go +++ b/cmd/template.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewTemplateCmd returm build subcmd +// NewTemplateCmd returm template subcmd func NewTemplateCmd(globalCfg *config.GlobalImpl) *cobra.Command { templateOptions := config.NewTemplateOptions() templateImpl := config.NewTemplateImpl(globalCfg, templateOptions) diff --git a/cmd/test.go b/cmd/test.go index c4661cc4..0af5cf10 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewTestCmd returm build subcmd +// NewTestCmd returns test subcmd func NewTestCmd(globalCfg *config.GlobalImpl) *cobra.Command { testOptions := config.NewTestOptions() testImpl := config.NewTestImpl(globalCfg, testOptions) diff --git a/cmd/version.go b/cmd/version.go index 3910437b..b2961430 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" ) -// NewVersionCmd returm build subcmd +// NewVersionCmd returns version subcmd func NewVersionCmd() *cobra.Command { cmd := &cobra.Command{ Use: "version", diff --git a/cmd/write-values.go b/cmd/write-values.go index 393f7196..8c918fa9 100644 --- a/cmd/write-values.go +++ b/cmd/write-values.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -// NewWriteValuesCmd returm build subcmd +// NewWriteValuesCmd returns write subcmd func NewWriteValuesCmd(globalCfg *config.GlobalImpl) *cobra.Command { writeValuesOptions := config.NewWriteValuesOptions() writeValuesImpl := config.NewWriteValuesImpl(globalCfg, writeValuesOptions) diff --git a/pkg/config/lint.go b/pkg/config/lint.go index 4017b2ae..17d1c299 100644 --- a/pkg/config/lint.go +++ b/pkg/config/lint.go @@ -12,6 +12,13 @@ type LintOptions struct { Set []string // Values is the values flags to pass to helm lint Values []string + // SkipNeeds is the skip needs flag + SkipNeeds bool + // IncludeNeeds is the include needs flag + IncludeNeeds bool + // IncludeTransitiveNeeds is the include transitive needs flag + IncludeTransitiveNeeds bool + // SkipDeps is the skip deps flag } // NewLintOptions creates a new Apply @@ -34,46 +41,50 @@ func NewLintImpl(g *GlobalImpl, b *LintOptions) *LintImpl { } // Concurrency returns the concurrency -func (c *LintImpl) Concurrency() int { - return c.LintOptions.Concurrency +func (l *LintImpl) Concurrency() int { + return l.LintOptions.Concurrency } // SkipDeps returns the skip deps -func (c *LintImpl) SkipDeps() bool { - return c.LintOptions.SkipDeps +func (l *LintImpl) SkipDeps() bool { + return l.LintOptions.SkipDeps } // Args returns the args -func (c *LintImpl) Args() string { - return c.LintOptions.Args +func (l *LintImpl) Args() string { + return l.LintOptions.Args } // Set returns the Set -func (c *LintImpl) Set() []string { - return c.LintOptions.Set +func (l *LintImpl) Set() []string { + return l.LintOptions.Set } // Values returns the Values -func (c *LintImpl) Values() []string { - return c.LintOptions.Values +func (l *LintImpl) Values() []string { + return l.LintOptions.Values } // SkipCleanUp returns the skip clean up -func (c *LintImpl) SkipCleanup() bool { - return false -} - -// SkipNeeds returns the skip needs -func (c *LintImpl) SkipNeeds() bool { +func (l *LintImpl) SkipCleanup() bool { return false } // IncludeNeeds returns the include needs -func (c *LintImpl) IncludeNeeds() bool { - return false +func (l *LintImpl) IncludeNeeds() bool { + return l.LintOptions.IncludeNeeds || l.LintOptions.IncludeTransitiveNeeds } // IncludeTransitiveNeeds returns the include transitive needs -func (c *LintImpl) IncludeTransitiveNeeds() bool { +func (l *LintImpl) IncludeTransitiveNeeds() bool { + return l.LintOptions.IncludeTransitiveNeeds +} + +// SkipNeeds returns the skip needs +func (l *LintImpl) SkipNeeds() bool { + if !l.LintOptions.IncludeNeeds { + return l.LintOptions.SkipNeeds + } + return false }