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

Reduce verbosity of backend startup routines

parent 51b0eb23
No related branches found
No related tags found
1 merge request!84Resolve "Support adding a TOTP device"
...@@ -13,7 +13,7 @@ def populate_apps(): ...@@ -13,7 +13,7 @@ def populate_apps():
for app in App.query.all(): for app in App.query.all():
slug = app.slug slug = app.slug
database_apps[slug] = app database_apps[slug] = app
logging.info(f"database app: {slug}") logging.debug(f"database app: {slug}")
_populate_apps_from(database_apps, "stackspin-apps") _populate_apps_from(database_apps, "stackspin-apps")
_populate_apps_from(database_apps, "stackspin-apps-custom") _populate_apps_from(database_apps, "stackspin-apps-custom")
...@@ -27,19 +27,19 @@ def _populate_apps_from(database_apps, configmap_name): ...@@ -27,19 +27,19 @@ def _populate_apps_from(database_apps, configmap_name):
logging.info(f"Could not find configmap '{configmap_name}' in namespace 'flux-system'; ignoring.") logging.info(f"Could not find configmap '{configmap_name}' in namespace 'flux-system'; ignoring.")
else: else:
for app_slug, app_data in cm_apps.items(): for app_slug, app_data in cm_apps.items():
logging.info(f"configmap app: {app_slug}") logging.debug(f"configmap app: {app_slug}")
if app_slug in database_apps: if app_slug in database_apps:
logging.info(f" already present in database") logging.debug(f" already present in database")
else: else:
logging.info(f" not present in database, adding!") logging.debug(f" not present in database, adding!")
data = yaml.safe_load(app_data) data = yaml.safe_load(app_data)
name = data["name"] name = data["name"]
logging.info(f" name: {name}") logging.debug(f" name: {name}")
external = data.get("external", False) external = data.get("external", False)
logging.info(f" type external: {type(external)}") logging.debug(f" type external: {type(external)}")
logging.info(f" external: {external}") logging.debug(f" external: {external}")
url = data.get("url", None) url = data.get("url", None)
logging.info(f" url: {url}") logging.debug(f" url: {url}")
new_app = App(slug=app_slug, name=name, external=external, url=url) new_app = App(slug=app_slug, name=name, external=external, url=url)
db.session.add(new_app) db.session.add(new_app)
db.session.commit() db.session.commit()
...@@ -52,7 +52,7 @@ def populate_oauthclients(): ...@@ -52,7 +52,7 @@ def populate_oauthclients():
for client in OAuthClientApp.query.all(): for client in OAuthClientApp.query.all():
id = client.oauthclient_id id = client.oauthclient_id
database_oauthclients[id] = client database_oauthclients[id] = client
logging.info(f"database oauthclient: {id}") logging.debug(f"database oauthclient: {id}")
_populate_oauthclients_from(database_oauthclients, "stackspin-oauthclients") _populate_oauthclients_from(database_oauthclients, "stackspin-oauthclients")
_populate_oauthclients_from(database_oauthclients, "stackspin-oauthclients-custom") _populate_oauthclients_from(database_oauthclients, "stackspin-oauthclients-custom")
...@@ -65,11 +65,11 @@ def _populate_oauthclients_from(database_oauthclients, configmap_name): ...@@ -65,11 +65,11 @@ def _populate_oauthclients_from(database_oauthclients, configmap_name):
logging.info(f"Could not find configmap '{configmap_name}' in namespace 'flux-system'; ignoring.") logging.info(f"Could not find configmap '{configmap_name}' in namespace 'flux-system'; ignoring.")
else: else:
for client_id, client_app in cm_oauthclients.items(): for client_id, client_app in cm_oauthclients.items():
logging.info(f"configmap oauthclient: {client_id}") logging.debug(f"configmap oauthclient: {client_id}")
if client_id in database_oauthclients: if client_id in database_oauthclients:
logging.info(f" already present in database") logging.debug(f" already present in database")
else: else:
logging.info(f" not present in database, adding!") logging.debug(f" not present in database, adding!")
# Take the value of the configmap mapping (`client_app`) and # Take the value of the configmap mapping (`client_app`) and
# interpret it as the slug of the app that this oauthclient # interpret it as the slug of the app that this oauthclient
# belongs to. # belongs to.
...@@ -78,6 +78,6 @@ def _populate_oauthclients_from(database_oauthclients, configmap_name): ...@@ -78,6 +78,6 @@ def _populate_oauthclients_from(database_oauthclients, configmap_name):
logging.error(f" could not find app with slug {client_app}") logging.error(f" could not find app with slug {client_app}")
continue continue
new_client = OAuthClientApp(oauthclient_id=client_id, app_id=app.id) new_client = OAuthClientApp(oauthclient_id=client_id, app_id=app.id)
logging.info(f" new oauth client: {new_client}") logging.debug(f" new oauth client: {new_client}")
db.session.add(new_client) db.session.add(new_client)
db.session.commit() db.session.commit()
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