File tree Expand file tree Collapse file tree 4 files changed +25
-79
lines changed Expand file tree Collapse file tree 4 files changed +25
-79
lines changed Original file line number Diff line number Diff line change 1
- import os
2
- from collections .abc import Mapping
3
1
from functools import lru_cache
4
2
from urllib .parse import urlparse
5
3
6
4
from ruamel .yaml import YAML
7
5
8
6
yaml = YAML (typ = "safe" )
9
7
10
-
11
- def _merge_dictionaries (a , b ):
12
- """Merge two dictionaries recursively.
13
-
14
- Simplified From https://stackoverflow.com/a/7205107
15
- """
16
- merged = a .copy ()
17
- for key in b :
18
- if key in a :
19
- if isinstance (a [key ], Mapping ) and isinstance (b [key ], Mapping ):
20
- merged [key ] = _merge_dictionaries (a [key ], b [key ])
21
- else :
22
- merged [key ] = b [key ]
23
- else :
24
- merged [key ] = b [key ]
25
- return merged
26
-
27
-
28
8
# memoize so we only load config once
29
9
@lru_cache ()
30
10
def _load_values ():
31
11
"""Load configuration from disk
32
12
33
13
Memoized to only load once
34
14
"""
35
- cfg = {}
36
- for source in ("config" , "secret" ):
37
- path = f"/etc/binderhub/{ source } /values.yaml"
38
- if os .path .exists (path ):
39
- print (f"Loading { path } " )
40
- with open (path ) as f :
41
- values = yaml .load (f )
42
- cfg = _merge_dictionaries (cfg , values )
43
- else :
44
- print (f"No config at { path } " )
45
- return cfg
15
+ path = "/etc/binderhub/config/values.yaml"
16
+ print (f"Loading { path } " )
17
+ with open (path ) as f :
18
+ return yaml .load (f )
46
19
47
20
48
21
def get_value (key , default = None ):
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 27
27
{{- . | toYaml | nindent 8 }}
28
28
{{- end }}
29
29
annotations :
30
- # This lets us autorestart when the configmap changes!
31
- checksum/config-map : {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
32
- checksum/secret : {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
30
+ # This lets us autorestart when the secret's pass-through config changes
31
+ checksum/config : {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
33
32
{{- with .Values.podAnnotations }}
34
33
{{- . | toYaml | nindent 8 }}
35
34
{{- end }}
44
43
{{- end }}
45
44
volumes :
46
45
- name : config
47
- configMap :
48
- name : binder-config
49
- - name : secret-config
50
46
secret :
51
47
secretName : binder-secret
52
48
{{- if .Values.config.BinderHub.use_registry }}
74
70
volumeMounts :
75
71
- mountPath : /etc/binderhub/config/
76
72
name : config
77
- - mountPath : /etc/binderhub/secret/
78
- name : secret-config
73
+ readOnly : true
79
74
{{- if .Values.config.BinderHub.use_registry }}
80
75
- mountPath : /root/.docker
81
76
name : docker-secret
Original file line number Diff line number Diff line change
1
+ {{- /*
2
+ Note that changes to the rendered version of this
3
+ file will trigger a restart of the BinderHub pod
4
+ through a annotation containing a hash of this
5
+ file rendered.
6
+ */ -}}
1
7
kind : Secret
2
8
apiVersion : v1
3
9
metadata :
4
10
name : binder-secret
5
11
type : Opaque
6
- data :
7
- {{- $values := dict "config" dict }}
8
- {{- $cfg := .Values.config }}
9
- {{- /* every 'pick' here should be matched with a corresponding 'omit' in secret.yaml */ -}}
10
- {{- if $cfg.GitHubRepoProvider }}
11
- {{- $_ := set $values.config "GitHubRepoProvider" (pick $cfg.GitHubRepoProvider "client_id" "client_secret" "access_token") }}
12
- {{- end }}
13
- {{- if $cfg.GitLabRepoProvider }}
14
- {{- $_ := set $values.config "GitLabRepoProvider" (pick $cfg.GitLabRepoProvider "access_token" "private_token") }}
15
- {{- end }}
16
- values.yaml : {{ $values | toYaml | b64enc | quote }}
12
+ stringData :
13
+ {{- /*
14
+ Stash away relevant Helm template values for
15
+ the BinderHub Python application to read from
16
+ in binderhub_config.py.
17
+ */}}
18
+ values.yaml : |
19
+ {{- pick .Values "config" "cors" "dind" "extraConfig" | toYaml | nindent 4 }}
20
+
21
+ {{- /* Glob files to allow them to be mounted by the binderhub pod */}}
22
+ {{- /* key=filename: value=content */}}
23
+ {{- (.Files.Glob "files/*").AsConfig | nindent 2 }}
17
24
---
18
25
{{- if or .Values.config.BinderHub.use_registry .Values.config.BinderHub.buildDockerConfig }}
19
26
kind : Secret
You can’t perform that action at this time.
0 commit comments