fmt with ruff
This commit is contained in:
16
app/users.py
16
app/users.py
@@ -1,22 +1,24 @@
|
||||
|
||||
from typing import List
|
||||
from kubernetes import client, config
|
||||
import os
|
||||
|
||||
OIDC_USERS_NAMESPACE = os.getenv("OIDC_USERS_NAMESPACE")
|
||||
|
||||
|
||||
def users_with_group(group: str) -> List[str]:
|
||||
config.load_incluster_config()
|
||||
api_instance = client.CustomObjectsApi()
|
||||
|
||||
|
||||
users = List[str]
|
||||
|
||||
ret = api_instance.list_namespaced_custom_object("codemowers.cloud", "v1beta1", OIDC_USERS_NAMESPACE, "oidcusers")
|
||||
|
||||
ret = api_instance.list_namespaced_custom_object(
|
||||
"codemowers.cloud", "v1beta1", OIDC_USERS_NAMESPACE, "oidcusers"
|
||||
)
|
||||
for item in ret["items"]:
|
||||
if group not in item.get("status", {}).get("groups", []):
|
||||
continue
|
||||
|
||||
users.append(item['metadata']['name'])
|
||||
|
||||
|
||||
users.append(item["metadata"]["name"])
|
||||
|
||||
print(f"INFO: {len(users)} users in group {group}")
|
||||
return users
|
||||
|
Reference in New Issue
Block a user