Skip to content

Commit

Permalink
[feat] Resolve ancestor of cloud, account and region (#1802)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias authored Oct 12, 2023
1 parent f098ac5 commit 925604e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions resotocore/resotocore/model/resolve_in_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,32 @@ class GraphResolver:
ResolveAncestor(
"cloud",
[
ResolveProp(NodePath.reported_name, ["ancestors", "cloud", "reported", "name"]),
ResolveProp(NodePath.reported_id, ["ancestors", "cloud", "reported", "id"]),
ResolveProp(NodePath.reported_name, ["ancestors", "cloud", "reported", "name"], apply_on_self=True),
ResolveProp(NodePath.reported_id, ["ancestors", "cloud", "reported", "id"], apply_on_self=True),
ResolveProp(NodePath.node_id, ["refs", "cloud_id"], apply_on_self=True),
],
),
ResolveAncestor(
"account",
[
ResolveProp(NodePath.reported_name, ["ancestors", "account", "reported", "name"]),
ResolveProp(NodePath.reported_id, ["ancestors", "account", "reported", "id"]),
ResolveProp(NodePath.reported_name, ["ancestors", "account", "reported", "name"], apply_on_self=True),
ResolveProp(NodePath.reported_id, ["ancestors", "account", "reported", "id"], apply_on_self=True),
ResolveProp(NodePath.node_id, ["refs", "account_id"], apply_on_self=True),
],
),
ResolveAncestor(
"region",
[
ResolveProp(NodePath.reported_name, ["ancestors", "region", "reported", "name"]),
ResolveProp(NodePath.reported_id, ["ancestors", "region", "reported", "id"]),
ResolveProp(NodePath.reported_name, ["ancestors", "region", "reported", "name"], apply_on_self=True),
ResolveProp(NodePath.reported_id, ["ancestors", "region", "reported", "id"], apply_on_self=True),
ResolveProp(NodePath.node_id, ["refs", "region_id"], apply_on_self=True),
],
),
ResolveAncestor(
"zone",
[
ResolveProp(NodePath.reported_name, ["ancestors", "zone", "reported", "name"]),
ResolveProp(NodePath.reported_id, ["ancestors", "zone", "reported", "id"]),
ResolveProp(NodePath.reported_name, ["ancestors", "zone", "reported", "name"], apply_on_self=True),
ResolveProp(NodePath.reported_id, ["ancestors", "zone", "reported", "id"], apply_on_self=True),
ResolveProp(NodePath.node_id, ["refs", "zone_id"], apply_on_self=True),
],
),
Expand Down
1 change: 1 addition & 0 deletions resotocore/tests/resotocore/model/graph_access_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ def test_ancestor_of() -> None:
assert graph.ancestor_of(nid1, EdgeTypes.default, "foo") is None
assert graph.ancestor_of(nid1, EdgeTypes.default, "foo") is None
assert graph.ancestor_of(nid1, EdgeTypes.default, "account")["id"] == acc1 # type: ignore
assert graph.ancestor_of(acc1, EdgeTypes.default, "account")["id"] == acc1 # type: ignore

# add another "shorter" edge from acc2 -> nid1, so it is shorter that from acc1 -> nid1
key = GraphAccess.edge_key(acc2, nid1, EdgeTypes.default)
Expand Down

0 comments on commit 925604e

Please sign in to comment.