CLI interface for external apps

This commit is contained in:
Mart van Santen 2022-09-24 01:04:29 +08:00
parent 6e427f275f
commit a2019a32d0
5 changed files with 113 additions and 8 deletions

View file

@ -71,6 +71,34 @@ def create_app(slug, name):
db.session.commit()
current_app.logger.info(f"App definition: {name} ({slug}) created")
@app_cli.command("create-external")
@click.argument("slug")
@click.argument("name")
@click.argument("url")
def create_external_app(slug, name, url):
"""Create an app for external access
:param slug: str short name of the app
:param name: str name of the application
:param url: str URL of application
"""
obj = App()
obj.name = name
obj.slug = slug
obj.external = True
obj.url = url
app_obj = App.query.filter_by(slug=slug).first()
if app_obj:
current_app.logger.info(f"App definition: {name} ({slug}) already exists in database")
return
db.session.add(obj)
db.session.commit()
current_app.logger.info(f"App definition: {name} ({slug}) created")
@app_cli.command("list")
@ -151,6 +179,11 @@ def install_app(slug):
current_app.logger.error(f"App {slug} does not exist")
return
if app.external:
current_app.logger.info(
f"App {slug} is an external app and can not be provisioned automatically")
return
current_status = app.get_status()
if current_status == APP_NOT_INSTALLED_STATUS:
app.install()