Skip to content

Commit

Permalink
Merge pull request #113 from lsst-sqre/tickets/DM-26506
Browse files Browse the repository at this point in the history
[DM-26506] Derive cachemachine URL from base URL
  • Loading branch information
rra authored Jan 27, 2022
2 parents fdc56cb + e2640b4 commit cae9eaf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion dev-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jupyterhub:
config:
base_url: "https://minikube.lsst.codes"
butler_secret_path: "secret/k8s_operator/minikube.lsst.codes/butler-secret"
images_url: "http://cachemachine.cachemachine.svc.cluster.local/cachemachine/jupyter/available"
volumes:
- name: home
emptyDir: {}
Expand Down
7 changes: 0 additions & 7 deletions src/nublado2/nublado_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ def gafaelfawr_token(self) -> Optional[str]:
except FileNotFoundError:
return None

@property
def images_url(self) -> str:
"""URL to fetch list of images to show in options form.
Generally, this is a link to the cachemachine service."""
return self._config["images_url"]

@property
def lab_environment(self) -> Dict[str, str]:
"""Environment variable settings for the lab (possibly templates)."""
Expand Down
20 changes: 13 additions & 7 deletions src/nublado2/options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""Spawner option form handling."""

from __future__ import annotations

from typing import List, Optional, Tuple
from urllib.parse import urljoin

from jinja2 import Template
from jupyterhub.spawner import Spawner
Expand Down Expand Up @@ -100,19 +105,20 @@


class NubladoOptions(LoggingConfigurable):
async def show_options_form(self, spawner: Spawner) -> str:
nc = NubladoConfig()
def __init__(self) -> None:
self.nublado_config = NubladoConfig()

(cached_images, all_images) = await self._get_images_from_url(
nc.images_url
)
cached_images.extend(nc.pinned_images)
async def show_options_form(self, spawner: Spawner) -> str:
base_url = self.nublado_config.base_url
url = urljoin(base_url, "cachemachine/jupyter/available")
(cached_images, all_images) = await self._get_images_from_url(url)
cached_images.extend(self.nublado_config.pinned_images)

return options_template.render(
dropdown_sentinel=DROPDOWN_SENTINEL_VALUE,
cached_images=cached_images,
all_images=all_images,
sizes=nc.sizes.values(),
sizes=self.nublado_config.sizes.values(),
)

async def _get_images_from_url(
Expand Down

0 comments on commit cae9eaf

Please sign in to comment.