Skip to content

Commit

Permalink
Add option to exclude deprecated charts (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLemieux authored Oct 27, 2020
1 parent 285f25e commit ec7b0c7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions ct/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func addCommonFlags(flags *pflag.FlagSet) {
flags.Bool("print-config", false, heredoc.Doc(`
Prints the configuration to stderr (caution: setting this may
expose sensitive data when helm-repo-extra-args contains passwords)`))
flags.Bool("exclude-deprecated", false, "Skip charts that are marked as deprecated")
}

func addCommonLintAndInstallFlags(flags *pflag.FlagSet) {
Expand Down
7 changes: 6 additions & 1 deletion pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ func (t *Testing) processCharts(action func(chart *Chart) TestResult) ([]TestRes
if err != nil {
return nil, err
}
charts = append(charts, chart)

if t.config.ExcludeDeprecated && chart.yaml.Deprecated {
fmt.Printf("Chart '%s' is deprecated and will be ignored because '--exclude-deprecated' is set\n", chart.String())
} else {
charts = append(charts, chart)
}
}

fmt.Println()
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Configuration struct {
SkipMissingValues bool `mapstructure:"skip-missing-values"`
Namespace string `mapstructure:"namespace"`
ReleaseLabel string `mapstructure:"release-label"`
ExcludeDeprecated bool `mapstructure:"exclude-deprecated"`
}

func LoadConfiguration(cfgFile string, cmd *cobra.Command, printConfig bool) (*Configuration, error) {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ func loadAndAssertConfigFromFile(t *testing.T, configFile string) {
require.Equal(t, true, cfg.SkipMissingValues)
require.Equal(t, "default", cfg.Namespace)
require.Equal(t, "release", cfg.ReleaseLabel)
require.Equal(t, true, cfg.ExcludeDeprecated)
}
3 changes: 2 additions & 1 deletion pkg/config/test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"upgrade": true,
"skip-missing-values": true,
"namespace": "default",
"release-label": "release"
"release-label": "release",
"exclude-deprecated": true
}
1 change: 1 addition & 0 deletions pkg/config/test_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ upgrade: true
skip-missing-values: true
namespace: default
release-label: release
exclude-deprecated: true

0 comments on commit ec7b0c7

Please sign in to comment.