@@ -87,7 +87,21 @@ class BuildExecutor(LoggingConfigurable):
8787
8888 push_secret = Unicode (
8989 "" ,
90- help = "Implementation dependent secret for pushing image to a registry." ,
90+ help = "Implementation dependent static secret for pushing image to a registry." ,
91+ config = True ,
92+ )
93+
94+ registry_credentials = Dict (
95+ {},
96+ help = (
97+ "Implementation dependent credentials for pushing image to a registry. "
98+ "For example, if push tokens are temporary this could be used to pass "
99+ "dynamically created credentials "
100+ '`{"registry": "docker.io", "username":"user", "password":"password"}`. '
101+ "This will be JSON encoded and passed in the environment variable "
102+ "CONTAINER_ENGINE_REGISTRY_CREDENTIALS` to repo2docker. "
103+ "If provided this will be used instead of push_secret."
104+ ),
91105 config = True ,
92106 )
93107
@@ -231,7 +245,26 @@ def _default_api(self):
231245 # Overrides the default for BuildExecutor
232246 push_secret = Unicode (
233247 "binder-build-docker-config" ,
234- help = "Implementation dependent secret for pushing image to a registry." ,
248+ help = (
249+ "Name of a Kubernetes secret containing static credentials for pushing "
250+ "an image to a registry."
251+ ),
252+ config = True ,
253+ )
254+
255+ registry_credentials = Dict (
256+ {},
257+ help = (
258+ "Implementation dependent credentials for pushing image to a registry. "
259+ "For example, if push tokens are temporary this could be used to pass "
260+ "dynamically created credentials "
261+ '`{"registry": "docker.io", "username":"user", "password":"password"}`. '
262+ "This will be JSON encoded and passed in the environment variable "
263+ "CONTAINER_ENGINE_REGISTRY_CREDENTIALS` to repo2docker. "
264+ "If provided this will be used instead of push_secret. "
265+ "Currently this is passed to the build pod as a plain text environment "
266+ "variable, though future implementations may use a Kubernetes secret."
267+ ),
235268 config = True ,
236269 )
237270
@@ -394,7 +427,23 @@ def submit(self):
394427 )
395428 ]
396429
397- if self .push_secret :
430+ env = [
431+ client .V1EnvVar (name = key , value = value )
432+ for key , value in self .extra_envs .items ()
433+ ]
434+ if self .git_credentials :
435+ env .append (
436+ client .V1EnvVar (name = "GIT_CREDENTIAL_ENV" , value = self .git_credentials )
437+ )
438+
439+ if self .registry_credentials :
440+ env .append (
441+ client .V1EnvVar (
442+ name = "CONTAINER_ENGINE_REGISTRY_CREDENTIALS" ,
443+ value = json .dumps (self .registry_credentials ),
444+ )
445+ )
446+ elif self .push_secret :
398447 volume_mounts .append (
399448 client .V1VolumeMount (mount_path = "/root/.docker" , name = "docker-config" )
400449 )
@@ -405,15 +454,6 @@ def submit(self):
405454 )
406455 )
407456
408- env = [
409- client .V1EnvVar (name = key , value = value )
410- for key , value in self .extra_envs .items ()
411- ]
412- if self .git_credentials :
413- env .append (
414- client .V1EnvVar (name = "GIT_CREDENTIAL_ENV" , value = self .git_credentials )
415- )
416-
417457 self .pod = client .V1Pod (
418458 metadata = client .V1ObjectMeta (
419459 name = self .name ,
0 commit comments