Skip to content

Commit aee3dff

Browse files
committed
Add comments
1 parent 1472435 commit aee3dff

File tree

1 file changed

+6
-1
lines changed
  • src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/files/jupyterhub

1 file changed

+6
-1
lines changed

src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/files/jupyterhub/02-spawner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def get_scoped_token(
5858
token_endpoint = f"http://{conda_store_url}/conda-store/api/v1/token/"
5959
http = urllib3.PoolManager()
6060

61+
# add default role bindings
6162
role_bindings = {
6263
"role_bindings": {
6364
f"{name}/*": ["viewer"],
@@ -68,16 +69,19 @@ def get_scoped_token(
6869
}
6970
}
7071

72+
# add role bindings for all the groups the user is part of
7173
if groups is not None:
7274
for group in groups:
7375
group = group.replace("/", "")
7476
role_bindings["role_bindings"][f"{group}/*"] = ["viewer"]
7577

78+
# if the user is an admin, they can view all namespace + environments
7679
if admin:
7780
role_bindings["role_bindings"]["*/*"] = ["viewer"]
7881

7982
encoded_body = json.dumps(role_bindings)
8083

84+
# generate a token with with the generated role bindings
8185
token_response = http.request(
8286
"POST",
8387
str(token_endpoint),
@@ -96,7 +100,6 @@ def get_scoped_token(
96100
# for a demo on one approach to adding test.
97101
def get_conda_store_environments(user_info: dict):
98102
import os
99-
100103
import urllib3
101104

102105
# Check for the environment variable `CONDA_STORE_API_PAGE_SIZE_LIMIT`. Fall
@@ -114,8 +117,10 @@ def get_conda_store_environments(user_info: dict):
114117
groups = user_info["groups"]
115118
name = user_info["name"]
116119
admin = user_info["admin"]
120+
# get token with appropriate scope for the user making the request
117121
scoped_token = get_scoped_token(external_url, token, name, groups, admin)
118122

123+
# get total number of records from the endpoint
119124
total_records = get_total_records(base_url, scoped_token)
120125

121126
# will contain all the environment info returned from the api

0 commit comments

Comments
 (0)