Skip to content

Commit

Permalink
Create acct_mgt package for Python sources
Browse files Browse the repository at this point in the history
Move all the account management code into the acct_mgt package.
Putting the code into a single namespace like this makes it easier to
write modular code, keeps the top-level directory organized, and makes
testing simpler.

x-branch: feature/prepare-for-tests
  • Loading branch information
larsks committed Jan 11, 2022
1 parent 93aa817 commit a85eec2
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
Empty file added acct_mgt/__init__.py
Empty file.
19 changes: 4 additions & 15 deletions wsgi.py → acct_mgt/app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""WSGI application for MOC openshift account management microservice"""
"""Flask application for MOC openshift account management microservice"""

import logging
import json
import os
from flask import Flask, request, Response
from flask_httpauth import HTTPBasicAuth

import defaults
import kubeclient
import moc_openshift
from . import defaults
from . import kubeclient
from . import moc_openshift

ENVPREFIX = "ACCT_MGT_"

Expand Down Expand Up @@ -356,13 +355,3 @@ def delete_quota(project):
return shift.delete_moc_quota(project)

return APP


APP = create_app()

if __name__ == "__main__":
APP.run()
else:
APP.logger = logging.getLogger("gunicorn.error")
# logger level INFO = 20 see (https://docs.python.org/3/library/logging.html#levels)
APP.logger.setLevel(20)
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions acct_mgt/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""WSGI wrapper for tooling that expects a top-level application object"""

import logging

from . import app

APP = app.create_app()

if __name__ == "__main__":
APP.run()
else:
APP.logger = logging.getLogger("gunicorn.error")
# logger level INFO = 20 see (https://docs.python.org/3/library/logging.html#levels)
APP.logger.setLevel(20)
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
exec gunicorn -b 0.0.0.0:8080 -c config.py -e PYTHONBUFFERED=TRUE wsgi:APP --log-file=-
exec gunicorn -b 0.0.0.0:8080 -c config.py -e PYTHONBUFFERED=TRUE acct_mgt.wsgi:APP --log-file=-

0 comments on commit a85eec2

Please sign in to comment.