Repository: helm/chart-testing (go)

Issue:
[feature request] option to skip linting/testing on deprecated charts.
Often older charts fail testing due to old reasons, deprecated charts often fall under this category.  Sometimes a minor change is needed to be made to a deprecated chart ( such as fixing or removing an icon/logo with a broken link )  which triggers CI to lint/test the chart ...  It would be nice to be able to set an argument to /not/ test them.

Pull request description:
Add option to exclude deprecated charts
**What this PR does / why we need it**:
Adds a new configuration option that allows a user to exclude deprecated charts from testing.

**Which issue this PR fixes**
fixes #261

**Special notes for your reviewer**:
I was able to validate some of the behavior manually by linting a deprecated chart, unsure about the best approach to automate that testing, perhaps in the integration_test.go tests.
Decided to hold off on implementing for now, as I realize this flag might need to be discussed.

Patch:
diff --git a/Dockerfile b/Dockerfile
index c2b6c57..ac35d82 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -29,7 +29,7 @@ RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/$kubectl
     mv kubectl /usr/local/bin/
 
 # Install Helm
-ARG helm_version=v3.3.4
+ARG helm_version=v3.4.0
 LABEL helm_version=$helm_version
 RUN curl -LO "https://get.helm.sh/helm-$helm_version-linux-amd64.tar.gz" && \
     mkdir -p "/usr/local/helm-$helm_version" && \
diff --git a/ct/cmd/root.go b/ct/cmd/root.go
index 76c96f9..56c8609 100644
--- a/ct/cmd/root.go
+++ b/ct/cmd/root.go
@@ -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) {
diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go
index 3ed7b14..856540d 100644
--- a/pkg/chart/chart.go
+++ b/pkg/chart/chart.go
@@ -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()
diff --git a/pkg/config/config.go b/pkg/config/config.go
index a88d402..eaf3a03 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -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) {


Test patch:
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 0386280..b5c47bb 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -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)
 }
diff --git a/pkg/config/test_config.json b/pkg/config/test_config.json
index a46d1de..83bf157 100644
--- a/pkg/config/test_config.json
+++ b/pkg/config/test_config.json
@@ -28,5 +28,6 @@
     "upgrade": true,
     "skip-missing-values": true,
     "namespace": "default",
-    "release-label": "release"
+    "release-label": "release",
+    "exclude-deprecated": true
 }
diff --git a/pkg/config/test_config.yaml b/pkg/config/test_config.yaml
index b294234..0b70465 100644
--- a/pkg/config/test_config.yaml
+++ b/pkg/config/test_config.yaml
@@ -24,3 +24,4 @@ upgrade: true
 skip-missing-values: true
 namespace: default
 release-label: release
+exclude-deprecated: true