Skip to content

Commit

Permalink
Replace push_secret_content with registry_credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Jun 27, 2023
1 parent a8d5049 commit e42f040
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
34 changes: 26 additions & 8 deletions binderhub/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ class BuildExecutor(LoggingConfigurable):
config=True,
)

push_secret_content = Unicode(
registry_credentials = Unicode(
"",
help=(
"Content of an implementation dependent secret for pushing image to a registry. "
"For example, if push tokens are temporary this can be used to pass the token "
"as an environment variable CONTAINER_ENGINE_REGISTRY_CREDENTIALS to "
"repo2docker."
"If provided this will be used instead of push_secret."
"Implementation dependent credentials for pushing image to a registry. "
"For example, if push tokens are temporary this could be used to pass "
"dynamically created credentials as an encoded JSON blob "
'`{"registry": "docker.io", "username":"user", "password":"password"}` '
"in the environment variable `CONTAINER_ENGINE_REGISTRY_CREDENTIALS` to "
"repo2docker. "
"If provided this will be used instead of push_secret. "
),
config=True,
)
Expand Down Expand Up @@ -247,6 +249,22 @@ def _default_api(self):
config=True,
)

registry_credentials = Unicode(
"",
help=(
"Implementation dependent credentials for pushing image to a registry. "
"For example, if push tokens are temporary this could be used to pass "
"dynamically created credentials as an encoded JSON blob "
'`{"registry": "docker.io", "username":"user", "password":"password"}` '
"in the environment variable `CONTAINER_ENGINE_REGISTRY_CREDENTIALS` to "
"repo2docker. "
"If provided this will be used instead of push_secret. "
"Currently this is passed to the build pod as a plan text environment "
"variable, though future implementations may use a Kubernetes secret."
),
config=True,
)

namespace = Unicode(
help="Kubernetes namespace to spawn build pods into", config=True
)
Expand Down Expand Up @@ -415,11 +433,11 @@ def submit(self):
client.V1EnvVar(name="GIT_CREDENTIAL_ENV", value=self.git_credentials)
)

if self.push_secret_content:
if self.registry_credentials:
env.append(
client.V1EnvVar(
name="CONTAINER_ENGINE_REGISTRY_CREDENTIALS",
value=self.push_secret_content,
value=self.registry_credentials,
)
)
elif self.push_secret:
Expand Down
2 changes: 1 addition & 1 deletion binderhub/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ async def get(self, provider_prefix, _unescaped_spec):
image_without_tag, image_tag
)
if push_token:
build.push_secret_content = json.dumps(push_token)
build.registry_credentials = json.dumps(push_token)
else:
build.push_secret = ""

Expand Down

0 comments on commit e42f040

Please sign in to comment.