diff --git a/src/_nebari/stages/kubernetes_services/__init__.py b/src/_nebari/stages/kubernetes_services/__init__.py index fae8955de1..f4c83abb21 100644 --- a/src/_nebari/stages/kubernetes_services/__init__.py +++ b/src/_nebari/stages/kubernetes_services/__init__.py @@ -235,8 +235,23 @@ class IdleCuller(schema.Base): server_shutdown_no_activity_timeout: int = 15 +class JupyterLabGalleryExhibit(schema.Base): + git: str + repository: str + title: str + description: str + icon: Optional[str] = None + + +class JupyterLabGallerySettings(schema.Base): + title: str = "Examples" + destination: str = "examples" + exhibits: List[JupyterLabGalleryExhibit] = [] + + class JupyterLab(schema.Base): default_settings: Dict[str, Any] = {} + gallery_settings: JupyterLabGallerySettings = JupyterLabGallerySettings() idle_culler: IdleCuller = IdleCuller() initial_repositories: List[Dict[str, str]] = [] preferred_dir: Optional[str] = None @@ -368,6 +383,9 @@ class JupyterhubInputVars(schema.Base): jupyterlab_default_settings: Dict[str, Any] = Field( alias="jupyterlab-default-settings" ) + jupyterlab_gallery_settings: JupyterLabGallerySettings = Field( + alias="jupyterlab-gallery-settings" + ) initial_repositories: str = Field(alias="initial-repositories") jupyterhub_overrides: List[str] = Field(alias="jupyterhub-overrides") jupyterhub_stared_storage: str = Field(alias="jupyterhub-shared-storage") @@ -534,6 +552,7 @@ def input_vars(self, stage_outputs: Dict[str, Dict[str, Any]]): jhub_apps_enabled=self.config.jhub_apps.enabled, initial_repositories=str(self.config.jupyterlab.initial_repositories), jupyterlab_default_settings=self.config.jupyterlab.default_settings, + jupyterlab_gallery_settings=self.config.jupyterlab.gallery_settings, jupyterlab_preferred_dir=self.config.jupyterlab.preferred_dir, ) diff --git a/src/_nebari/stages/kubernetes_services/template/jupyterhub.tf b/src/_nebari/stages/kubernetes_services/template/jupyterhub.tf index 4f8bebb9e4..21faca6fae 100644 --- a/src/_nebari/stages/kubernetes_services/template/jupyterhub.tf +++ b/src/_nebari/stages/kubernetes_services/template/jupyterhub.tf @@ -54,6 +54,21 @@ variable "jupyterlab-default-settings" { type = map(any) } +variable "jupyterlab-gallery-settings" { + description = "Server-side settings for jupyterlab-gallery extension" + type = object({ + title = optional(string) + destination = optional(string) + exhibits = list(object({ + git = string + repository = string + title = string + description = string + icon = optional(string) + })) + }) +} + variable "jupyterhub-hub-extraEnv" { description = "Extracted overrides to merge with jupyterhub.hub.extraEnv" type = string @@ -149,6 +164,8 @@ module "jupyterhub" { jupyterlab-default-settings = var.jupyterlab-default-settings + jupyterlab-gallery-settings = var.jupyterlab-gallery-settings + jupyterlab-pioneer-enabled = var.jupyterlab-pioneer-enabled jupyterlab-pioneer-log-format = var.jupyterlab-pioneer-log-format diff --git a/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/configmaps.tf b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/configmaps.tf index 4b8f9145b9..bb605e5e27 100644 --- a/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/configmaps.tf +++ b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/configmaps.tf @@ -47,6 +47,11 @@ resource "local_file" "jupyter_jupyterlab_pioneer_config_py" { } } +resource "local_file" "jupyter_gallery_config_json" { + content = jsonencode(var.jupyterlab-gallery-settings) + filename = "${path.module}/files/jupyter/jupyter_gallery_config.json" +} + resource "local_file" "overrides_json" { content = jsonencode(local.jupyterlab-overrides-json-object) @@ -89,7 +94,8 @@ locals { resource "kubernetes_config_map" "etc-jupyter" { depends_on = [ local_file.jupyter_server_config_py, - local_file.jupyter_jupyterlab_pioneer_config_py + local_file.jupyter_jupyterlab_pioneer_config_py, + local_file.jupyter_gallery_config_json ] metadata { diff --git a/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/variables.tf b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/variables.tf index 577dedc8ef..dddc2ba61c 100644 --- a/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/variables.tf +++ b/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/variables.tf @@ -163,6 +163,21 @@ variable "jupyterlab-default-settings" { type = map(any) } +variable "jupyterlab-gallery-settings" { + description = "Server-side settings for jupyterlab-gallery extension" + type = object({ + title = optional(string) + destination = optional(string) + exhibits = list(object({ + git = string + repository = string + title = string + description = string + icon = optional(string) + })) + }) +} + variable "jupyterlab-pioneer-enabled" { description = "Enable JupyterLab Pioneer for telemetry" type = bool diff --git a/tests/tests_unit/cli_validate/min.happy.jupyterlab.gallery_settings.yaml b/tests/tests_unit/cli_validate/min.happy.jupyterlab.gallery_settings.yaml new file mode 100644 index 0000000000..5ee991b05a --- /dev/null +++ b/tests/tests_unit/cli_validate/min.happy.jupyterlab.gallery_settings.yaml @@ -0,0 +1,10 @@ +project_name: test +jupyterlab: + gallery_settings: + title: Example repositories + destination: examples + exhibits: + - title: Nebari + git: https://github.com/nebari-dev/nebari.git + repository: https://github.com/nebari-dev/nebari + description: 🪴 Nebari - your open source data science platform