generated from coulomb/repo-seed
feat: add deployment zone overlays
This commit is contained in:
@@ -7,6 +7,7 @@ from typing import Any
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from .canon import edge_canon_mapping
|
||||
from .deployment_overlay import graph_explorer_overlay_fields, normalize_deployment_overlay
|
||||
|
||||
|
||||
DISPLAY_STATES = ("show", "blur", "hide", "highlight", "remove")
|
||||
@@ -134,6 +135,12 @@ def fabric_graph_explorer_manifest(base_url: str = "") -> dict[str, Any]:
|
||||
"layer",
|
||||
"kind",
|
||||
"environment",
|
||||
"deploymentEnvironment",
|
||||
"deploymentScenario",
|
||||
"routingAuthority",
|
||||
"accessZone",
|
||||
"policyAuthority",
|
||||
"exposureClass",
|
||||
"serverHost",
|
||||
"lifecycle",
|
||||
"unresolved",
|
||||
@@ -147,7 +154,17 @@ def fabric_graph_explorer_manifest(base_url: str = "") -> dict[str, Any]:
|
||||
"repo",
|
||||
"domain",
|
||||
"environment",
|
||||
"deploymentEnvironment",
|
||||
"deploymentScenario",
|
||||
"routingAuthority",
|
||||
"accessZone",
|
||||
"policyAuthority",
|
||||
"exposureClass",
|
||||
"serverHost",
|
||||
"routeHost",
|
||||
"routeHostname",
|
||||
"routePort",
|
||||
"routeProtocol",
|
||||
"kind",
|
||||
"layer",
|
||||
"edgeType",
|
||||
@@ -163,7 +180,15 @@ def fabric_graph_explorer_manifest(base_url: str = "") -> dict[str, Any]:
|
||||
{"id": "repo", "label": "Repo", "type": "string"},
|
||||
{"id": "domain", "label": "Domain", "type": "string"},
|
||||
{"id": "environment", "label": "Environment", "type": "string"},
|
||||
{"id": "deploymentEnvironment", "label": "Deployment Environment", "type": "string"},
|
||||
{"id": "deploymentScenario", "label": "Deployment Scenario", "type": "string"},
|
||||
{"id": "routingAuthority", "label": "Routing Authority", "type": "string"},
|
||||
{"id": "accessZone", "label": "Access Zone", "type": "string"},
|
||||
{"id": "policyAuthority", "label": "Policy Authority", "type": "string"},
|
||||
{"id": "exposureClass", "label": "Exposure Class", "type": "string"},
|
||||
{"id": "serverHost", "label": "Server Host", "type": "string"},
|
||||
{"id": "routeHost", "label": "Route Host", "type": "string"},
|
||||
{"id": "routePort", "label": "Route Port", "type": "number"},
|
||||
{"id": "lifecycle", "label": "Lifecycle", "type": "string"},
|
||||
{"id": "reviewState", "label": "Review State", "type": "string"},
|
||||
{"id": "unresolved", "label": "Unresolved", "type": "boolean"},
|
||||
@@ -193,6 +218,14 @@ def fabric_graph_explorer_manifest(base_url: str = "") -> dict[str, Any]:
|
||||
"repo",
|
||||
"domain",
|
||||
"lifecycle",
|
||||
"deploymentEnvironment",
|
||||
"deploymentScenario",
|
||||
"routingAuthority",
|
||||
"accessZone",
|
||||
"policyAuthority",
|
||||
"exposureClass",
|
||||
"routeHost",
|
||||
"routePort",
|
||||
"canonCategory",
|
||||
"evidenceState",
|
||||
"unresolved",
|
||||
@@ -215,6 +248,31 @@ def fabric_graph_explorer_manifest(base_url: str = "") -> dict[str, Any]:
|
||||
],
|
||||
},
|
||||
"modes": [
|
||||
{
|
||||
"id": "by-fabric",
|
||||
"label": "Fabric",
|
||||
"description": "Group and filter by fabric/accountability fields.",
|
||||
},
|
||||
{
|
||||
"id": "by-deployment-environment",
|
||||
"label": "Environment",
|
||||
"description": "Group and filter by deployment environment.",
|
||||
},
|
||||
{
|
||||
"id": "by-deployment-scenario",
|
||||
"label": "Scenario",
|
||||
"description": "Group and filter by deployment scenario.",
|
||||
},
|
||||
{
|
||||
"id": "by-routing-authority",
|
||||
"label": "Routing",
|
||||
"description": "Group and filter by routing authority.",
|
||||
},
|
||||
{
|
||||
"id": "by-access-zone",
|
||||
"label": "Access Zone",
|
||||
"description": "Group and filter by intended access zone.",
|
||||
},
|
||||
{
|
||||
"id": "full",
|
||||
"label": "Full",
|
||||
@@ -335,6 +393,10 @@ def fabric_graph_explorer_payload(
|
||||
if source_kind == "Repository":
|
||||
continue
|
||||
attributes = node.get("attributes") if isinstance(node.get("attributes"), dict) else {}
|
||||
overlay_data = _overlay_data(
|
||||
node.get("deployment_overlay") if isinstance(node.get("deployment_overlay"), dict) else {},
|
||||
attributes,
|
||||
)
|
||||
kind = _presentation_kind(source_kind, attributes)
|
||||
layer = _layer_for_kind(kind)
|
||||
is_unresolved = node_id in unresolved
|
||||
@@ -353,6 +415,8 @@ def fabric_graph_explorer_payload(
|
||||
"repo": str(node.get("repo", "")),
|
||||
"domain": str(node.get("domain", "")),
|
||||
"lifecycle": str(node.get("lifecycle", "")),
|
||||
"environment": overlay_data["deploymentEnvironment"],
|
||||
**overlay_data,
|
||||
"canonCategory": str(
|
||||
node.get("canon_category") or attributes.get("canon_category") or ""
|
||||
),
|
||||
@@ -522,12 +586,17 @@ def _presentation_edge_type(edge_type: str, source: str, target: str, node_kinds
|
||||
|
||||
def _edge_metadata(edge: dict[str, Any], edge_type: str) -> dict[str, Any]:
|
||||
canon_mapping = edge_canon_mapping(edge_type)
|
||||
attributes = edge.get("attributes") if isinstance(edge.get("attributes"), dict) else {}
|
||||
return {
|
||||
"canonical_type": str(edge.get("canonical_type") or canon_mapping.canonical_type),
|
||||
"canon_anchor": str(edge.get("canon_anchor") or canon_mapping.canon_anchor),
|
||||
"mapping_fit": str(edge.get("mapping_fit") or canon_mapping.fit),
|
||||
"display_only": bool(edge.get("display_only", canon_mapping.display_only)),
|
||||
"evidence_state": str(edge.get("evidence_state") or "declared"),
|
||||
"deployment_overlay": normalize_deployment_overlay(
|
||||
edge.get("deployment_overlay") if isinstance(edge.get("deployment_overlay"), dict) else {},
|
||||
attributes,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -630,6 +699,12 @@ def _append_infrastructure_elements(
|
||||
for endpoint in service_endpoints
|
||||
if _environment_matches(environment, endpoint["environments"])
|
||||
]
|
||||
deployment_overlay = normalize_deployment_overlay(
|
||||
attributes,
|
||||
{"deployment_environment": environment},
|
||||
*[endpoint["deployment_overlay"] for endpoint in matching_endpoints],
|
||||
)
|
||||
overlay_data = _overlay_data(deployment_overlay)
|
||||
server_hosts = sorted({endpoint["host"] for endpoint in matching_endpoints})
|
||||
deployment_data = {
|
||||
"id": deployment_id,
|
||||
@@ -643,6 +718,7 @@ def _append_infrastructure_elements(
|
||||
"domain": str(service.get("domain") or ""),
|
||||
"lifecycle": str(service.get("lifecycle") or ""),
|
||||
"environment": environment,
|
||||
**overlay_data,
|
||||
"serviceId": service_id,
|
||||
"serverHosts": server_hosts,
|
||||
"reviewState": "accepted",
|
||||
@@ -676,6 +752,10 @@ def _append_infrastructure_elements(
|
||||
host = endpoint["host"]
|
||||
port = endpoint["port"]
|
||||
protocol = endpoint["protocol"]
|
||||
endpoint_overlay_data = _overlay_data(
|
||||
endpoint["deployment_overlay"],
|
||||
{"deployment_environment": environment},
|
||||
)
|
||||
server_id = server_ids_by_host.get(host)
|
||||
endpoint_key = _endpoint_key(host, port, protocol)
|
||||
port_id = port_ids_by_endpoint.get(endpoint_key)
|
||||
@@ -695,6 +775,7 @@ def _append_infrastructure_elements(
|
||||
"domain": str(service.get("domain") or ""),
|
||||
"lifecycle": "active",
|
||||
"environment": environment,
|
||||
**endpoint_overlay_data,
|
||||
"serverHost": host,
|
||||
"reviewState": "accepted",
|
||||
"freshnessState": "current",
|
||||
@@ -706,6 +787,7 @@ def _append_infrastructure_elements(
|
||||
"host": host,
|
||||
"source_interface_id": endpoint["interface_id"],
|
||||
"endpoint_url": endpoint["url"],
|
||||
"deployment_overlay": endpoint_overlay_data["deploymentOverlay"],
|
||||
},
|
||||
"displayState": "show",
|
||||
"visibilitySource": "default",
|
||||
@@ -731,6 +813,7 @@ def _append_infrastructure_elements(
|
||||
"domain": str(service.get("domain") or ""),
|
||||
"lifecycle": "active",
|
||||
"environment": environment,
|
||||
**endpoint_overlay_data,
|
||||
"serverHost": host,
|
||||
"reviewState": "accepted",
|
||||
"freshnessState": "current",
|
||||
@@ -744,6 +827,7 @@ def _append_infrastructure_elements(
|
||||
"protocol": protocol,
|
||||
"source_interface_id": endpoint["interface_id"],
|
||||
"endpoint_url": endpoint["url"],
|
||||
"deployment_overlay": endpoint_overlay_data["deploymentOverlay"],
|
||||
},
|
||||
"displayState": "show",
|
||||
"visibilitySource": "default",
|
||||
@@ -783,6 +867,16 @@ def _endpoints_by_service(source_nodes: list[dict[str, Any]]) -> dict[str, list[
|
||||
"url": url,
|
||||
"interface_id": str(node.get("id") or ""),
|
||||
"environments": _environments(attributes),
|
||||
"deployment_overlay": normalize_deployment_overlay(
|
||||
attributes,
|
||||
endpoint,
|
||||
{
|
||||
"host": host,
|
||||
"port": port,
|
||||
"protocol": protocol,
|
||||
"route": url,
|
||||
},
|
||||
),
|
||||
}
|
||||
)
|
||||
return endpoints
|
||||
@@ -895,6 +989,7 @@ def _edge_element(
|
||||
mapping_fit: str = "",
|
||||
display_only: bool = False,
|
||||
evidence_state: str = "",
|
||||
deployment_overlay: dict[str, Any] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
source_layer = node_layers.get(source, "unknown")
|
||||
target_layer = node_layers.get(target, "unknown")
|
||||
@@ -910,6 +1005,7 @@ def _edge_element(
|
||||
strength = _edge_strength(edge_type)
|
||||
layout = _layout_hints(edge_type, source_layer, target_layer, same_repo)
|
||||
edge_id = f"edge:{edge_index}:{source}:{edge_type}:{target}"
|
||||
overlay_data = _overlay_data(deployment_overlay or {})
|
||||
return {
|
||||
"data": {
|
||||
"id": edge_id,
|
||||
@@ -930,6 +1026,7 @@ def _edge_element(
|
||||
"mappingFit": mapping_fit,
|
||||
"displayOnly": display_only,
|
||||
"evidenceState": evidence_state,
|
||||
**overlay_data,
|
||||
"strength": strength,
|
||||
"edgeWidth": _edge_width(strength),
|
||||
"sameLayer": source_layer == target_layer,
|
||||
@@ -959,6 +1056,10 @@ def _edge_element(
|
||||
}
|
||||
|
||||
|
||||
def _overlay_data(*sources: object) -> dict[str, Any]:
|
||||
return graph_explorer_overlay_fields(normalize_deployment_overlay(*sources))
|
||||
|
||||
|
||||
def _layout_hints(
|
||||
edge_type: str,
|
||||
source_layer: str,
|
||||
|
||||
Reference in New Issue
Block a user