slack /open-xxx from inventory-app

This commit is contained in:
2025-08-08 05:15:29 +03:00
parent eeeb5ecace
commit f5cfb3454a
5 changed files with 125 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
from typing import List
from kubernetes import client, config
import os
from typing import List, Tuple
from kubernetes import client, config
OIDC_USERS_NAMESPACE = os.getenv("OIDC_USERS_NAMESPACE")
@@ -22,3 +23,20 @@ def users_with_group(group: str) -> List[str]:
print(f"INFO: {len(users)} users in group {group}")
return users
# -> (groups[], username)
def by_slackid(slack_id: str) -> Tuple[List[str], str]:
config.load_incluster_config()
api_instance = client.CustomObjectsApi()
ret = api_instance.list_namespaced_custom_object(
"codemowers.cloud", "v1beta1", OIDC_USERS_NAMESPACE, "oidcusers"
)
for item in ret["items"]:
if slack_id == item.get("status", {}).get("slackId", None):
return item.get("status", {}).get("groups", []), item.get(
"metadata", {}
).get("name", "")
return [], ""