Skip to content

Commit ad5dcd6

Browse files
committed
Fix "cname" generation with non-reversed graph as source
Signed-off-by: Tobias Wolf <[email protected]>
1 parent a290418 commit ad5dcd6

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/gardenlinux/features/__main__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ def main():
108108
elif args.type in ( "cname_base", "cname", "graph" ):
109109
graph = Parser(gardenlinux_root, feature_dir_name).filter(cname_base, additional_filter_func = additional_filter_func)
110110

111-
sorted_features = Parser.sort_reversed_graph_nodes(graph)
112-
111+
sorted_features = Parser.sort_graph_nodes(graph)
113112
minimal_feature_set = get_minimal_feature_set(graph)
114113

115114
sorted_minimal_features = sort_subset(

src/gardenlinux/features/cname_main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ def main():
6767

6868
graph = Parser(gardenlinux_root, feature_dir_name).filter(cname_base)
6969

70-
sorted_features = Parser.sort_reversed_graph_nodes(graph)
71-
70+
sorted_features = Parser.sort_graph_nodes(graph)
7271
minimal_feature_set = get_minimal_feature_set(graph)
7372

7473
sorted_minimal_features = sort_subset(

src/gardenlinux/features/parser.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,16 @@ def _get_graph_node_type(node):
215215
return node.get("content", {}).get("type")
216216

217217
@staticmethod
218-
def sort_reversed_graph_nodes(graph):
218+
def sort_graph_nodes(graph):
219219
def key_function(node):
220220
prefix_map = {"platform": "0", "element": "1", "flag": "2"}
221221
node_type = Parser._get_graph_node_type(graph.nodes.get(node, {}))
222222
prefix = prefix_map[node_type]
223223

224224
return f"{prefix}-{node}"
225225

226-
return list(networkx.lexicographical_topological_sort(graph.reverse(), key = key_function))
226+
return list(networkx.lexicographical_topological_sort(graph, key = key_function))
227+
228+
@staticmethod
229+
def sort_reversed_graph_nodes(graph):
230+
return Parser.sort_graph_nodes(graph.reverse())

0 commit comments

Comments
 (0)