From 7f321385f71305955635dead7ce0411fbcf9e055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madis=20M=C3=A4gi?= Date: Wed, 2 Aug 2023 01:49:51 +0300 Subject: [PATCH] Read oidc users namespace name from env --- deployment.yaml | 2 ++ inventory-app/api.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/deployment.yaml b/deployment.yaml index 0712aee..29e9471 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -21,6 +21,8 @@ spec: - name: inventory-app image: inventory-app env: + - name: OIDC_USERS_NAMESPACE + value: "oidc-gateway" - name: INVENTORY_API_KEY value: "sptWL6XFxl4b8" - name: PYTHONUNBUFFERED diff --git a/inventory-app/api.py b/inventory-app/api.py index 10241aa..c7d7fb5 100644 --- a/inventory-app/api.py +++ b/inventory-app/api.py @@ -10,6 +10,7 @@ from kubernetes import client, config page_api = Blueprint("api", __name__) db = MongoClient(const.MONGO_URI).get_default_database() api_key = os.getenv("INVENTORY_API_KEY") +OIDC_USERS_NAMESPACE = os.getenv("OIDC_USERS_NAMESPACE") def check_api_key(f): @wraps(f) @@ -26,7 +27,7 @@ def check_api_key(f): def get_users(): config.load_incluster_config() api_instance = client.CustomObjectsApi() - ret = api_instance.list_namespaced_custom_object("codemowers.io", "v1alpha1", "default", "oidcgatewayusers") + ret = api_instance.list_namespaced_custom_object("codemowers.io", "v1alpha1", OIDC_USERS_NAMESPACE, "oidcgatewayusers") resp = [] for item in ret["items"]: resp.append(item)