|
1 | 1 | # Copyright (c) 2024 Airbyte, Inc., all rights reserved.
|
2 |
| - |
3 | 2 | from __future__ import annotations
|
4 | 3 |
|
5 | 4 | import datetime
|
|
14 | 13 | from connectors_insights.pylint import get_pylint_output
|
15 | 14 | from connectors_insights.result_backends import FileToPersist, ResultBackend
|
16 | 15 | from connectors_insights.sbom import get_json_sbom
|
| 16 | +from typing_extensions import Mapping |
17 | 17 |
|
18 | 18 | if TYPE_CHECKING:
|
19 | 19 | from typing import Dict, List, Tuple
|
|
23 | 23 | from connector_ops.utils import Connector # type: ignore
|
24 | 24 |
|
25 | 25 |
|
| 26 | +def get_manifest_inferred_insights(connector: Connector) -> dict: |
| 27 | + manifest = connector.manifest_path.read_text() |
| 28 | + |
| 29 | + schemas_directory = connector.code_path / connector.technical_name.replace("-", "_") / "schemas" |
| 30 | + |
| 31 | + return { |
| 32 | + "manifest_uses_parameters": manifest.find("$parameters") != -1, |
| 33 | + "manifest_uses_custom_components": manifest.find("class_name:") != -1, |
| 34 | + "manifest_custom_component_classes": re.findall(r"class_name: (.+)", manifest), |
| 35 | + "has_json_schemas": schemas_directory.is_dir() and any(schemas_directory.iterdir()), |
| 36 | + } |
| 37 | + |
| 38 | + |
26 | 39 | def get_metadata_inferred_insights(connector: Connector) -> Dict:
|
27 | 40 | return {
|
28 | 41 | "connector_technical_name": connector.technical_name,
|
@@ -155,6 +168,7 @@ def generate_insights(connector: Connector, sbom: str | None, pylint_output: str
|
155 | 168 | return ConnectorInsights(
|
156 | 169 | **{
|
157 | 170 | **get_metadata_inferred_insights(connector),
|
| 171 | + **get_manifest_inferred_insights(connector), |
158 | 172 | **get_pylint_inferred_insights(pylint_output),
|
159 | 173 | **get_sbom_inferred_insights(sbom, connector),
|
160 | 174 | "ci_on_master_report": ci_on_master_report,
|
|
0 commit comments