Remove requests external dependency
This commit is contained in:
parent
d2e93bdc58
commit
8e00d6c918
1 changed files with 7 additions and 3 deletions
|
@ -1,4 +1,3 @@
|
||||||
import requests
|
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -6,6 +5,8 @@ import tomllib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TypedDict
|
from typing import TypedDict
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from urllib.request import urlopen
|
||||||
|
import json
|
||||||
|
|
||||||
TRAEFIK_HOST_RE = re.compile(r"Host\(`([a-z0-9\.-]+)`\)")
|
TRAEFIK_HOST_RE = re.compile(r"Host\(`([a-z0-9\.-]+)`\)")
|
||||||
|
|
||||||
|
@ -35,7 +36,9 @@ def parse_traefik_rule(rule: str) -> list[str]:
|
||||||
|
|
||||||
|
|
||||||
def get_traefik_routes(traefik_host: str, traefik_route: str):
|
def get_traefik_routes(traefik_host: str, traefik_route: str):
|
||||||
api_response = requests.get(f"{traefik_host}/api/http/routers").json()
|
with urlopen(f"{traefik_host}/api/http/routers") as response:
|
||||||
|
api_response = json.load(response)
|
||||||
|
|
||||||
routes = set()
|
routes = set()
|
||||||
|
|
||||||
for router in api_response:
|
for router in api_response:
|
||||||
|
@ -57,7 +60,8 @@ def get_traefik_routes(traefik_host: str, traefik_route: str):
|
||||||
return routes
|
return routes
|
||||||
|
|
||||||
def get_dokku_routes(dokku_exporter_url: str, dokku_route: str):
|
def get_dokku_routes(dokku_exporter_url: str, dokku_route: str):
|
||||||
api_response = requests.get(dokku_exporter_url).json()
|
with urlopen(dokku_exporter_url) as response:
|
||||||
|
api_response = json.load(response)
|
||||||
|
|
||||||
routes = set()
|
routes = set()
|
||||||
|
|
||||||
|
|
Reference in a new issue