diff --git a/binderhub/build.py b/binderhub/build.py index 4ab9ec65b..ed64aa390 100644 --- a/binderhub/build.py +++ b/binderhub/build.py @@ -16,7 +16,7 @@ from kubernetes import client, watch from tornado.ioloop import IOLoop from tornado.log import app_log -from traitlets import Any, Bool, Dict, Integer, Unicode, default +from traitlets import Any, Bool, Dict, Integer, List, Unicode, default from traitlets.config import LoggingConfigurable from .utils import KUBE_REQUEST_TIMEOUT, ByteSpecification, rendezvous_rank @@ -125,6 +125,15 @@ class BuildExecutor(LoggingConfigurable): config=True, ) + repo2docker_extra_args = List( + Unicode, + default_value=[], + help=""" + Extra commandline parameters to be passed to jupyter-repo2docker during build + """, + config=True, + ) + def __init__(self, **kwargs): super().__init__(**kwargs) self.main_loop = IOLoop.current() @@ -156,6 +165,8 @@ def get_r2d_cmd_options(self): r2d_options.append("--build-memory-limit") r2d_options.append(str(self.memory_limit)) + r2d_options += self.repo2docker_extra_args + return r2d_options def get_cmd(self): diff --git a/binderhub/tests/test_build.py b/binderhub/tests/test_build.py index 7f7a795ea..6c87f2a15 100644 --- a/binderhub/tests/test_build.py +++ b/binderhub/tests/test_build.py @@ -13,7 +13,7 @@ from tornado.httputil import url_concat from tornado.queues import Queue -from binderhub.build import KubernetesBuildExecutor, ProgressEvent +from binderhub.build import BuildExecutor, KubernetesBuildExecutor, ProgressEvent from binderhub.build_local import LocalRepo2dockerBuild, ProcessTerminated, _execute_cmd from .utils import async_requests @@ -415,3 +415,21 @@ def break_callback(): lines.append(line) assert lines == ["1\n"] assert str(exc.value) == f"ProcessTerminated: {cmd}" + + +def test_extra_r2d_options(): + bex = BuildExecutor() + bex.repo2docker_extra_args = ["--repo-dir=/srv/repo"] + bex.image_name = "test:test" + bex.ref = "main" + + assert bex.get_r2d_cmd_options() == [ + "--ref=main", + "--image=test:test", + "--no-clean", + "--no-run", + "--json-logs", + "--user-name=jovyan", + "--user-id=1000", + "--repo-dir=/srv/repo", + ]