Repository: pantsbuild/pants

Issue:
Helm backend is not inferring Helm chart dependencies
**Describe the bug**
After loading the Helm backend in `pants.toml` and having a chart that declares a dependency on another one (either first or third party), the command `./pants dependencies path/to/chart` does not list any dependencies.

**Pants version**
2.14.0.dev3

**OS**
MacOS

**Additional info**
What is happening is that the dependency inference rules for the `helm_chart` target type are not being loaded by the `register.py` hook.



Discussion:

Resolving patch:
diff --git a/src/python/pants/backend/helm/util_rules/chart.py b/src/python/pants/backend/helm/util_rules/chart.py
--- a/src/python/pants/backend/helm/util_rules/chart.py
+++ b/src/python/pants/backend/helm/util_rules/chart.py
@@ -7,6 +7,7 @@
 import logging
 from dataclasses import dataclass
 
+from pants.backend.helm.dependency_inference import chart as chart_inference
 from pants.backend.helm.resolve import fetch
 from pants.backend.helm.resolve.artifacts import ResolvedHelmArtifact
 from pants.backend.helm.resolve.fetch import (
@@ -195,4 +196,10 @@ async def get_helm_chart(request: HelmChartRequest, subsystem: HelmSubsystem) ->
 
 
 def rules():
-    return [*collect_rules(), *sources.rules(), *chart_metadata.rules(), *fetch.rules()]
+    return [
+        *collect_rules(),
+        *sources.rules(),
+        *chart_metadata.rules(),
+        *chart_inference.rules(),
+        *fetch.rules(),
+    ]


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
@@ -11,6 +11,7 @@
 from pants.backend.helm.goals.lint import rules as helm_lint_rules
 from pants.backend.helm.subsystems.helm import HelmSubsystem
 from pants.backend.helm.target_types import HelmChartTarget
+from pants.backend.helm.target_types import rules as target_types_rules
 from pants.backend.helm.testutil import (
     HELM_TEMPLATE_HELPERS_FILE,
     HELM_VALUES_FILE,
@@ -41,6 +42,7 @@ def rule_runner() -> RuleRunner:
             *stripped_source_files.rules(),
             *source_root_rules(),
             *sources.rules(),
+            *target_types_rules(),
             SubsystemRule(HelmSubsystem),
             QueryRule(LintResults, (HelmLintRequest,)),
         ],
diff --git a/src/python/pants/backend/helm/goals/package_test.py b/src/python/pants/backend/helm/goals/package_test.py
--- a/src/python/pants/backend/helm/goals/package_test.py
+++ b/src/python/pants/backend/helm/goals/package_test.py
@@ -11,6 +11,7 @@
 from pants.backend.helm.goals.package import BuiltHelmArtifact, HelmPackageFieldSet
 from pants.backend.helm.subsystems.helm import HelmSubsystem
 from pants.backend.helm.target_types import HelmChartTarget
+from pants.backend.helm.target_types import rules as target_types_rules
 from pants.backend.helm.testutil import (
     HELM_TEMPLATE_HELPERS_FILE,
     HELM_VALUES_FILE,
@@ -39,6 +40,7 @@ def rule_runner() -> RuleRunner:
             *stripped_source_files.rules(),
             *source_root_rules(),
             *sources.rules(),
+            *target_types_rules(),
             SubsystemRule(HelmSubsystem),
             QueryRule(BuiltPackage, [HelmPackageFieldSet]),
         ],
diff --git a/src/python/pants/backend/helm/util_rules/chart_test.py b/src/python/pants/backend/helm/util_rules/chart_test.py
--- a/src/python/pants/backend/helm/util_rules/chart_test.py
+++ b/src/python/pants/backend/helm/util_rules/chart_test.py
@@ -7,7 +7,6 @@
 
 import pytest
 
-from pants.backend.helm.dependency_inference.chart import rules as chart_infer_rules
 from pants.backend.helm.target_types import HelmArtifactTarget, HelmChartTarget
 from pants.backend.helm.target_types import rules as target_types_rules
 from pants.backend.helm.testutil import (
@@ -39,7 +38,6 @@ def rule_runner() -> RuleRunner:
             *config_files.rules(),
             *external_tool.rules(),
             *chart.rules(),
-            *chart_infer_rules(),
             *sources.rules(),
             *tool.rules(),
             *process.rules(),