Skip to content

Commit

Permalink
Change registry credentials to list
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaiacs committed Jan 28, 2025
1 parent 8cd2bcb commit 09051c4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 34 deletions.
36 changes: 19 additions & 17 deletions helm-chart/binderhub/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,25 @@ properties:
to pull the image.
registry:
type: object
additionalProperties: false
description: |
TODO
properties:
url:
type: [string, "null"]
description: |
TODO
username:
type: [string, "null"]
description: |
TODO
password:
type: [string, "null"]
description: |
TODO
type: array
items:
type: object
additionalProperties: false
description: |
TODO
properties:
url:
type: [string, "null"]
description: |
TODO
username:
type: [string, "null"]
description: |
TODO
password:
type: [string, "null"]
description: |
TODO
service:
type: object
Expand Down
14 changes: 13 additions & 1 deletion helm-chart/binderhub/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ config:
private_token: {{ .Values.gitlab.privateToken }}
{{- end }}

{{- if ne (kindOf .Values.registry) "slice" }}
registry is now a slide (list). Use:

registry:
- url:
username:
password:
- url:
username:
password:

{{- if ne (typeOf .Values.registry.enabled) "<nil>" }}

registry.enabled is removed. Use:
Expand Down Expand Up @@ -120,6 +131,7 @@ config:
image_prefix: {{.Values.registry.prefix }}

{{- end }}
{{- end }}

{{- if or .Values.build .Values.perRepoQuota }}

Expand All @@ -141,7 +153,7 @@ config:
{{- end }}


{{- if (or .Values.hub .Values.build .Values.github .Values.gitlab .Values.perRepoQuota .Values.registry.host .Values.registry.authHost .Values.registry.tokenUrl .Values.registry.prefix (ne (typeOf .Values.registry.enabled) "<nil>")) }}
{{- if (or .Values.hub .Values.build .Values.github .Values.gitlab .Values.perRepoQuota (eq (typeOf .Values.registry) "slice")) }}
{{- fail (include "removedConfig" .) }}
{{- end }}

Expand Down
34 changes: 18 additions & 16 deletions helm-chart/binderhub/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@ Render docker config.json for the registry-publishing secret and other docker co
*/}}
{{- define "buildDockerConfig" -}}

{{- /* default auth url */ -}}
{{- $url := (default "https://index.docker.io/v1" .Values.registry.url) }}

{{- /* default username if unspecified
(_json_key for gcr.io, <token> otherwise)
*/ -}}

{{- if not .Values.registry.username }}
{{- if eq $url "https://gcr.io" }}
{{- $_ := set .Values.registry "username" "_json_key" }}
{{- else }}
{{- $_ := set .Values.registry "username" "<token>" }}
{{- /* initialize a dict to represent a docker config with registry credentials */}}
{{- $auths := dict }}
{{- range .Values.registry }}
{{- /* default auth url */ -}}
{{- $url := (default "https://index.docker.io/v1" .url) }}

{{- /* default username if unspecified
(_json_key for gcr.io, <token> otherwise)
*/ -}}
{{- if not .username }}
{{- if eq $url "https://gcr.io" }}
{{- $_ := set . "username" "_json_key" }}
{{- else }}
{{- $_ := set . "username" "<token>" }}
{{- end }}
{{- end }}
{{- $username := .username -}}
{{- $auths := merge $auths (dict $url (dict "auth" (printf "%s:%s" $username .password | b64enc))) }}
{{- end }}
{{- $username := .Values.registry.username -}}

{{- /* initialize a dict to represent a docker config with registry credentials */}}
{{- $dockerConfig := dict "auths" (dict $url (dict "auth" (printf "%s:%s" $username .Values.registry.password | b64enc))) }}
{{- $dockerConfig := dict "auths" $auths }}

{{- /* augment our initialized docker config with buildDockerConfig */}}
{{- if .Values.config.BinderHub.buildDockerConfig }}
Expand Down

0 comments on commit 09051c4

Please sign in to comment.