Group routes
This commit is contained in:
parent
48d8b5511c
commit
d2e93bdc58
1 changed files with 8 additions and 4 deletions
|
@ -2,10 +2,10 @@ import requests
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import operator
|
|
||||||
import tomllib
|
import tomllib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TypedDict
|
from typing import TypedDict
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
TRAEFIK_HOST_RE = re.compile(r"Host\(`([a-z0-9\.-]+)`\)")
|
TRAEFIK_HOST_RE = re.compile(r"Host\(`([a-z0-9\.-]+)`\)")
|
||||||
|
|
||||||
|
@ -86,10 +86,14 @@ def main():
|
||||||
if len(routes) != len(set(routes)):
|
if len(routes) != len(set(routes)):
|
||||||
raise ValueError("Conflict found!")
|
raise ValueError("Conflict found!")
|
||||||
|
|
||||||
for route in sorted(routes, key=operator.attrgetter("hostname")):
|
grouped_routes = defaultdict(set)
|
||||||
print(f"{route.hostname}\t{route.destination}; # {route.name}")
|
for route in routes:
|
||||||
|
grouped_routes[route.hostname, route.destination].add(route.name)
|
||||||
|
|
||||||
print("Found", len(routes), "routes")
|
for (hostname, destination), names in sorted(grouped_routes.items()):
|
||||||
|
print(f"{hostname}\t{destination}; # {', '.join(names)}")
|
||||||
|
|
||||||
|
print("Found", len(routes), "routes, grouped into", len(grouped_routes), "groups")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Reference in a new issue