Skip to content

Commit

Permalink
get-route: read info from file
Browse files Browse the repository at this point in the history
  • Loading branch information
gsanchietti committed Aug 11, 2023
1 parent a224876 commit 17f3ef1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions imageroot/pypkg/get_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def get_route(data):
agent_id = os.environ["AGENT_ID"]
try:
# Get the http route from the API
with urllib.request.urlopen(f'http://127.0.0.1/{api_path}/api/http/routers/{module}-https@redis') as res:
with urllib.request.urlopen(f'http://127.0.0.1/{api_path}/api/http/routers/{module}-https@file') as res:
traefik_https_route = json.load(res)
# Get the https route from the API
with urllib.request.urlopen(f'http://127.0.0.1/{api_path}/api/http/routers/{module}-http@redis') as res:
with urllib.request.urlopen(f'http://127.0.0.1/{api_path}/api/http/routers/{module}-http@file') as res:
traefik_http_route = json.load(res)

# Check if the route is ready to use
Expand All @@ -50,7 +50,7 @@ def get_route(data):

service_name = traefik_https_route['service']
# Get the service from the API
with urllib.request.urlopen(f'http://127.0.0.1/{api_path}/api/http/services/{service_name}@redis') as res:
with urllib.request.urlopen(f'http://127.0.0.1/{api_path}/api/http/services/{service_name}@file') as res:
service = json.load(res)

route['instance'] = data['instance']
Expand All @@ -74,11 +74,11 @@ def get_route(data):
middlewares = traefik_http_route.get("middlewares")

# Check if redirect http to https is enabled
route['http2https'] = True if middlewares and "http2https-redirectscheme@redis" in middlewares else False
route['http2https'] = True if middlewares and "http2https-redirectscheme" in middlewares else False

# Check if the path is striped from the request
if route.get("path"):
route['strip_prefix'] = True if middlewares and f'{module}-stripprefix@redis' in middlewares else False
route['strip_prefix'] = True if middlewares and f'{module}-stripprefix' in middlewares else False

# Check if the route was created manually
rdb = agent.redis_connect(privileged=True)
Expand All @@ -100,7 +100,7 @@ def get_route(data):

if middlewares and f'{module}-auth@redis' in middlewares:
try:
with urllib.request.urlopen(f'http://127.0.0.1/{api_path}/api/http/middlewares/{module}-auth@redis') as res:
with urllib.request.urlopen(f'http://127.0.0.1/{api_path}/api/http/middlewares/{module}-auth@file') as res:
auth_middleware = json.load(res)
except urllib.error.HTTPError as e:
raise Exception(f'Error reaching traefik daemon (middlewares): {e.reason}')
Expand Down

0 comments on commit 17f3ef1

Please sign in to comment.