python imports hell

This commit is contained in:
2025-08-08 02:35:16 +03:00
parent abffe7c594
commit 5afee284b7
5 changed files with 15 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
FROM harbor.k-space.ee/k-space/microservice-base
RUN pip3 install httpx
FROM harbor.k-space.ee/k-space/microservice-base:latest
WORKDIR /app
COPY app /app
CMD /app/doorboy-proxy.py
CMD ["python3", "/app/doorboy-proxy.py"]

View File

@@ -11,11 +11,11 @@ from sanic import Sanic
from sanic.response import json, text
from sanic_prometheus import monitor
from .slack import add_slack_routes
from .users import users_with_group
import kube
import slack
app = Sanic(__name__)
add_slack_routes(app)
slack.add_routes(app)
monitor(app).expose_endpoint()
# API key for godoor controllers authenticating to k-space:floor
@@ -61,9 +61,9 @@ async def view_doorboy_uids(request):
# authorize
key = request.headers.get("KEY")
if key == DOORBOY_SECRET_FLOOR:
users = users_with_group(FLOOR_ACCESS_GROUP)
users = kube.users_with_group(FLOOR_ACCESS_GROUP)
elif key == DOORBOY_SECRET_WORKSHOP:
users = users_with_group(WORKSHOP_ACCESS_GROUP)
users = kube.users_with_group(WORKSHOP_ACCESS_GROUP)
else:
print("WARN: unknown door token in /allowed")
return "unknown doorboy secret token", 403

View File

@@ -1,14 +1,15 @@
import os
import requests
from pymongo.errors import PyMongoError
from requests.exceptions import RequestException
import os
import requests
# webhook logs to private channel or "DEV" to print to console.
SLACK_DOORLOG_CALLBACK = os.environ["SLACK_DOORLOG_CALLBACK"]
def add_slack_routes(app):
app.app.register_listener(slack_log, "after_server_start")
def add_routes(app):
app.register_listener(slack_log, "after_server_start")
def slack_post(msg):

View File

@@ -20,7 +20,6 @@ services:
driver: none
doorboy_proxy:
network_mode: host
environment:
DOORBOY_SECRET_FLOOR: "0123456789"
DOORBOY_SECRET_WORKSHOP: "9999999999"
@@ -28,5 +27,7 @@ services:
WORKSHOP_ACCESS_GROUP: "k-space:workshop"
SLACK_DOORLOG_CALLBACK: DEV
env_file: .env
ports:
- "5000:5000"
build:
context: .