Repository: pantsbuild/pants

Issue:
Allow to skip linting on specific `helm_chart` targets
**Is your feature request related to a problem? Please describe.**
At the moment end users have the choice of enabling strict or lenient linting in `helm_chart` targets either globally or a per-chart basis, but there is no option to mark a specific `helm_chart` as not run any kind of linting on it.

**Describe the solution you'd like**
Have an optional boolean `skip_lint` field in the `helm_chart` target which would not run any linting process on the given target when set to `True`. Default value of the field would be `False`.

**Describe alternatives you've considered**
N/A

**Additional context**
N/A



Discussion:

Resolving patch:
diff --git a/src/python/pants/backend/helm/goals/lint.py b/src/python/pants/backend/helm/goals/lint.py
--- a/src/python/pants/backend/helm/goals/lint.py
+++ b/src/python/pants/backend/helm/goals/lint.py
@@ -7,7 +7,11 @@
 from dataclasses import dataclass
 
 from pants.backend.helm.subsystems.helm import HelmSubsystem
-from pants.backend.helm.target_types import HelmChartFieldSet, HelmChartLintStrictField
+from pants.backend.helm.target_types import (
+    HelmChartFieldSet,
+    HelmChartLintStrictField,
+    HelmSkipLintField,
+)
 from pants.backend.helm.util_rules.chart import HelmChart, HelmChartRequest
 from pants.backend.helm.util_rules.tool import HelmProcess
 from pants.core.goals.lint import LintResult, LintResults, LintTargetsRequest
@@ -23,6 +27,7 @@
 @dataclass(frozen=True)
 class HelmLintFieldSet(HelmChartFieldSet):
     lint_strict: HelmChartLintStrictField
+    skip_lint: HelmSkipLintField
 
 
 class HelmLintRequest(LintTargetsRequest):
@@ -33,7 +38,9 @@ class HelmLintRequest(LintTargetsRequest):
 @rule(desc="Lint Helm charts", level=LogLevel.DEBUG)
 async def run_helm_lint(request: HelmLintRequest, helm_subsystem: HelmSubsystem) -> LintResults:
     charts = await MultiGet(
-        Get(HelmChart, HelmChartRequest(field_set)) for field_set in request.field_sets
+        Get(HelmChart, HelmChartRequest(field_set))
+        for field_set in request.field_sets
+        if not field_set.skip_lint.value
     )
     logger.debug(f"Linting {pluralize(len(charts), 'chart')}...")
 
diff --git a/src/python/pants/backend/helm/target_types.py b/src/python/pants/backend/helm/target_types.py
--- a/src/python/pants/backend/helm/target_types.py
+++ b/src/python/pants/backend/helm/target_types.py
@@ -67,12 +67,23 @@ class HelmRegistriesField(StringSequenceField):
     )
 
 
+class HelmSkipLintField(BoolField):
+    alias = "skip_lint"
+    default = False
+    help = softwrap(
+        f"""
+        If set to true, do not run any linting in this Helm chart when running `{bin_name()}
+        lint`.
+        """
+    )
+
+
 class HelmSkipPushField(BoolField):
     alias = "skip_push"
     default = False
     help = softwrap(
         f"""
-        If set to true, do not push this helm chart to registries when running `{bin_name()}
+        If set to true, do not push this Helm chart to registries when running `{bin_name()}
         publish`.
         """
     )
@@ -167,6 +178,7 @@ class HelmChartTarget(Target):
         HelmChartRepositoryField,
         HelmRegistriesField,
         HelmSkipPushField,
+        HelmSkipLintField,
     )
     help = "A Helm chart."
 


Test patch:
diff --git a/src/python/pants/backend/helm/goals/lint_test.py b/src/python/pants/backend/helm/goals/lint_test.py
--- a/src/python/pants/backend/helm/goals/lint_test.py
+++ b/src/python/pants/backend/helm/goals/lint_test.py
@@ -185,3 +185,23 @@ def test_one_lint_result_per_chart(rule_runner: RuleRunner) -> None:
     assert lint_results[0].partition_description == "chart1"
     assert lint_results[1].exit_code == 0
     assert lint_results[1].partition_description == "chart2"
+
+
+def test_skip_lint(rule_runner: RuleRunner) -> None:
+    rule_runner.write_files(
+        {
+            "src/chart/BUILD": "helm_chart(skip_lint=True)",
+            "src/chart/Chart.yaml": gen_chart_file("chart", version="0.1.0"),
+            "src/chart/values.yaml": HELM_VALUES_FILE,
+            "src/chart/templates/_helpers.tpl": HELM_TEMPLATE_HELPERS_FILE,
+            "src/chart/templates/service.yaml": K8S_SERVICE_FILE,
+        }
+    )
+
+    source_root_patterns = ("src/*",)
+
+    chart_target = rule_runner.get_target(Address("src/chart", target_name="chart"))
+    lint_results = run_helm_lint(
+        rule_runner, [chart_target], source_root_patterns=source_root_patterns
+    )
+    assert len(lint_results) == 0