Skip to content
Snippets Groups Projects
Commit 38a40a9e authored by Arie Peterson's avatar Arie Peterson
Browse files

Merge branch '204-creating-initial-admin-user-fails-due-to-missing-apps' into 'main'

Resolve "Creating initial admin user fails due to missing apps"

Closes #204

See merge request !180
parents 001a98c3 2ecbe81a
No related branches found
No related tags found
1 merge request!180Resolve "Creating initial admin user fails due to missing apps"
Pipeline #45817 passed with stages
in 3 minutes and 48 seconds
...@@ -55,7 +55,7 @@ def create_app(slug, name, external_url = None): ...@@ -55,7 +55,7 @@ def create_app(slug, name, external_url = None):
:param extenal-url: if set, it marks this as an external app and :param extenal-url: if set, it marks this as an external app and
configures the url configures the url
""" """
current_app.logger.info(f"Creating app definition: {name} ({slug}") current_app.logger.info(f"Creating app definition: {name} ({slug})")
obj = App(name=name, slug=slug) obj = App(name=name, slug=slug)
......
...@@ -436,17 +436,17 @@ def debounce(timeout: float): ...@@ -436,17 +436,17 @@ def debounce(timeout: float):
return decorator return decorator
def watch_dashboard_config(app, reload): def watch_dashboard_config(app, reload):
# Number of seconds to wait before reloading in case more secrets show up.
# In particular this prevents us from reloading once for every
# secret that exists at startup in succession.
debounce_timeout = 1
@debounce(debounce_timeout)
def debounced_reload():
reload()
w = watch.Watch() w = watch.Watch()
api_instance = client.CoreV1Api(api_client.ApiClient()) api_instance = client.CoreV1Api(api_client.ApiClient())
def p(): def watch_scim_secrets():
with app.app_context(): with app.app_context():
# Number of seconds to wait before reloading in case more secrets show up.
# In particular this prevents us from reloading once for every
# secret that exists at startup in succession.
debounce_timeout = 1
@debounce(debounce_timeout)
def debounced_reload():
reload()
for event in w.stream( for event in w.stream(
api_instance.list_namespaced_secret, api_instance.list_namespaced_secret,
'flux-system', 'flux-system',
...@@ -455,8 +455,18 @@ def watch_dashboard_config(app, reload): ...@@ -455,8 +455,18 @@ def watch_dashboard_config(app, reload):
): ):
current_app.logger.info(f"{event['type']} SCIM config secret: {event['object'].metadata.name}") current_app.logger.info(f"{event['type']} SCIM config secret: {event['object'].metadata.name}")
debounced_reload() debounced_reload()
thread = threading.Thread(target=p) threading.Thread(target=watch_scim_secrets).start()
thread.start() def watch_dashboard_configmaps():
with app.app_context():
for event in w.stream(
api_instance.list_namespaced_config_map,
'flux-system',
label_selector="stackspin.net/dashboard-config=1",
watch=True
):
current_app.logger.info(f"{event['type']} dashboard config configmap: {event['object'].metadata.name}")
debounced_reload()
threading.Thread(target=watch_dashboard_configmaps).start()
def check_condition(status): def check_condition(status):
""" """
......
...@@ -27,31 +27,26 @@ spec: ...@@ -27,31 +27,26 @@ spec:
image: {{ template "backend.image" . }} image: {{ template "backend.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }} imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
envFrom: envFrom:
- configMapRef: - configMapRef:
name: {{ include "common.names.fullname" . }} name: {{ include "common.names.fullname" . }}
{{- if .Values.backend.extraEnvVarsCM }} {{- if .Values.backend.extraEnvVarsCM }}
- configMapRef: - configMapRef:
name: {{ .Values.backend.extraEnvVarsCM }} name: {{ .Values.backend.extraEnvVarsCM }}
{{- end }} {{- end }}
{{- if .Values.backend.extraEnvVarsSecret }} {{- if .Values.backend.extraEnvVarsSecret }}
- secretRef: - secretRef:
name: {{ .Values.backend.extraEnvVarsSecret }} name: {{ .Values.backend.extraEnvVarsSecret }}
{{- end }} {{- end }}
env: env:
- name: SETUP_EMAIL - name: SETUP_EMAIL
value: {{ .Values.backend.initialUser.email }} value: {{ .Values.backend.initialUser.email }}
- name: SETUP_PASSWORD - name: SETUP_PASSWORD
value: {{ .Values.backend.initialUser.password }} value: {{ .Values.backend.initialUser.password }}
- name: KRATOS_PUBLIC_URL - name: KRATOS_PUBLIC_URL
value: http://kratos-public:80 value: http://kratos-public:80
command: ["/bin/bash", "-c"] command: ["/bin/bash", "-c"]
args: args:
- flask cli user create $SETUP_EMAIL; - flask cli user create $SETUP_EMAIL;
flask cli user setpassword $SETUP_EMAIL $SETUP_PASSWORD; flask cli user setpassword $SETUP_EMAIL $SETUP_PASSWORD;
flask cli app create dashboard Dashboard; flask cli app create dashboard Dashboard;
flask cli user setrole $SETUP_EMAIL dashboard admin; flask cli user setrole $SETUP_EMAIL dashboard admin;
flask cli user setrole $SETUP_EMAIL nextcloud admin;
flask cli user setrole $SETUP_EMAIL wordpress admin;
flask cli user setrole $SETUP_EMAIL wekan admin;
flask cli user setrole $SETUP_EMAIL zulip admin;
flask cli user setrole $SETUP_EMAIL hedgedoc admin;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment