Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deployer: Add support for binderhubs in the cilogon_app script #2407

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions deployer/cilogon_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ def persist_client_credentials_in_config_file(client, hub_type, config_filename)
}
}

if hub_type != "basehub":
if hub_type == "daskhub":
auth_config["basehub"] = jupyterhub_config
elif hub_type == "binderhub":
auth_config["binderhub"] = jupyterhub_config
else:
auth_config = jupyterhub_config

Expand All @@ -97,13 +99,17 @@ def load_client_id_from_file(config_filename):
with open(decrypted_path) as f:
auth_config = yaml.load(f)

basehub = auth_config.get("basehub", None)
daskhub = auth_config.get("basehub", None)
binderhub = auth_config.get("binderhub", None)
try:
if basehub:
if daskhub:
return auth_config["basehub"]["jupyterhub"]["hub"]["config"][
"CILogonOAuthenticator"
]["client_id"]

elif binderhub:
return auth_config["binderhub"]["jupyterhub"]["hub"]["config"][
"CILogonOAuthenticator"
]["client_id"]
return auth_config["jupyterhub"]["hub"]["config"]["CILogonOAuthenticator"][
"client_id"
]
Expand Down
11 changes: 7 additions & 4 deletions deployer/file_acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def persist_config_in_encrypted_file(encrypted_file, new_config):

def remove_jupyterhub_hub_config_key_from_encrypted_file(encrypted_file, key):
"""
Remove config from the dict `config["basehub"]["jupyterhub"]["hub"]["config"][key]`
in `encrypted_file` (the "basehub" key is optional).
Remove config from the dict `config["jupyterhub"]["hub"]["config"][<key>]`
in `encrypted_file` (the config is also searched for under daskhub/binderhub prefixes).

If after removing this config, the file only contains a config dict with empty leaves,
delete the entire file, as it no longer holds any information.
Expand All @@ -129,9 +129,12 @@ def remove_jupyterhub_hub_config_key_from_encrypted_file(encrypted_file, key):
with open(decrypted_path) as f:
config = yaml.load(f)

basehub = config.get("basehub", None)
if basehub:
daskhub = config.get("basehub", None)
binderhub = config.get("binderhub", None)
if daskhub:
config["basehub"]["jupyterhub"]["hub"]["config"].pop(key)
elif binderhub:
config["binderhub"]["jupyterhub"]["hub"]["config"].pop(key)
else:
config["jupyterhub"]["hub"]["config"].pop(key)

Expand Down