Read oidc users namespace name from env
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful

This commit is contained in:
Madis Mägi 2023-08-02 01:49:51 +03:00
parent ff8f5eae36
commit 7f321385f7
2 changed files with 4 additions and 1 deletions

View File

@ -21,6 +21,8 @@ spec:
- name: inventory-app - name: inventory-app
image: inventory-app image: inventory-app
env: env:
- name: OIDC_USERS_NAMESPACE
value: "oidc-gateway"
- name: INVENTORY_API_KEY - name: INVENTORY_API_KEY
value: "sptWL6XFxl4b8" value: "sptWL6XFxl4b8"
- name: PYTHONUNBUFFERED - name: PYTHONUNBUFFERED

View File

@ -10,6 +10,7 @@ from kubernetes import client, config
page_api = Blueprint("api", __name__) page_api = Blueprint("api", __name__)
db = MongoClient(const.MONGO_URI).get_default_database() db = MongoClient(const.MONGO_URI).get_default_database()
api_key = os.getenv("INVENTORY_API_KEY") api_key = os.getenv("INVENTORY_API_KEY")
OIDC_USERS_NAMESPACE = os.getenv("OIDC_USERS_NAMESPACE")
def check_api_key(f): def check_api_key(f):
@wraps(f) @wraps(f)
@ -26,7 +27,7 @@ def check_api_key(f):
def get_users(): def get_users():
config.load_incluster_config() config.load_incluster_config()
api_instance = client.CustomObjectsApi() 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 = [] resp = []
for item in ret["items"]: for item in ret["items"]:
resp.append(item) resp.append(item)