diff --git a/src/nublado2/hooks.py b/src/nublado2/hooks.py index 2143531..46ff9a4 100644 --- a/src/nublado2/hooks.py +++ b/src/nublado2/hooks.py @@ -25,6 +25,12 @@ async def pre_spawn(self, spawner: Spawner) -> None: # selected. size_name = options["size"][0] image_name = options["image"][0] + image_tag = options["image_tag"][0] + + # If the user selected one of the images in the dropdown, + # use image. + if image_name == "image_tag": + image_name = image_tag # Take size and image names, which are returned as form data, # look up associated values, and configure the spawner. diff --git a/src/nublado2/options.py b/src/nublado2/options.py index 42bc3d3..a6e6836 100644 --- a/src/nublado2/options.py +++ b/src/nublado2/options.py @@ -33,6 +33,14 @@ > {{ i.name }}
{% endfor %} + + + Select historical image:
+ @@ -66,16 +74,22 @@ async def show_options_form(self, spawner: Spawner) -> str: sizes = options_config["sizes"] images_url = options_config.get("images_url") - images = await self._get_images_from_url(images_url) + + cachemachine_response = await self._get_images_from_url(images_url) + + all_images = cachemachine_response["all"] + images = cachemachine_response["images"] images.extend(options_config["images"]) - return options_template.render(images=images, sizes=sizes) + return options_template.render( + all_images=all_images, images=images, sizes=sizes + ) async def _get_images_from_url( self, url: Optional[str] - ) -> List[Dict[str, str]]: + ) -> Dict[str, List[Dict[str, str]]]: if not url: - return [] + return {"all": [], "images": []} r = await session.get(url) if r.status != 200: