allow deleting external applications

This commit is contained in:
Maarten de Waard 2022-10-04 15:02:11 +02:00
parent 808533fabd
commit 5ac175e44e
No known key found for this signature in database
GPG key ID: 1D3E893A657CC8DA
2 changed files with 12 additions and 5 deletions

View file

@ -25,7 +25,7 @@ class App(db.Model):
id = db.Column(Integer, primary_key=True) id = db.Column(Integer, primary_key=True)
name = db.Column(String(length=64)) name = db.Column(String(length=64))
slug = db.Column(String(length=64), unique=True) slug = db.Column(String(length=64), unique=True)
external = db.Column(Boolean, unique=False, nullable=False, default=True, server_default='0') external = db.Column(Boolean, unique=False, nullable=False, server_default='0')
# The URL is only stored in the DB for external applications; otherwise the # The URL is only stored in the DB for external applications; otherwise the
# URL is stored in a configmap (see get_url) # URL is stored in a configmap (see get_url)
url = db.Column(String(length=128), unique=False) url = db.Column(String(length=128), unique=False)
@ -229,6 +229,12 @@ class AppStatus(): # pylint: disable=too-few-public-methods
:type app: App :type app: App
""" """
def __init__(self, app): def __init__(self, app):
if app.external:
self.installed = True
self.ready = True
self.message = "App is external"
return
kustomization = app.kustomization kustomization = app.kustomization
if kustomization is not None and "status" in kustomization: if kustomization is not None and "status" in kustomization:
ks_ready, ks_message = AppStatus.check_condition(kustomization['status']) ks_ready, ks_message = AppStatus.check_condition(kustomization['status'])

View file

@ -105,12 +105,13 @@ def delete_app(slug):
return return
app_status = app_obj.get_status() app_status = app_obj.get_status()
if not app_status.installed: if app_status.installed and not app_obj.external:
app_obj.delete()
current_app.logger.info("Success.")
else:
current_app.logger.info("Can not delete installed application, run" current_app.logger.info("Can not delete installed application, run"
" 'uninstall' first") " 'uninstall' first")
return
app_obj.delete()
current_app.logger.info("Success.")
@app_cli.command( @app_cli.command(