From 5ac175e44ed21ad1efa47cff436b4ea8e96b103d Mon Sep 17 00:00:00 2001 From: Maarten de Waard <maarten@greenhost.nl> Date: Tue, 4 Oct 2022 15:02:11 +0200 Subject: [PATCH] allow deleting external applications --- areas/apps/models.py | 8 +++++++- cliapp/cliapp/cli.py | 9 +++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/areas/apps/models.py b/areas/apps/models.py index 9cc24848..083bcbd4 100644 --- a/areas/apps/models.py +++ b/areas/apps/models.py @@ -25,7 +25,7 @@ class App(db.Model): id = db.Column(Integer, primary_key=True) name = db.Column(String(length=64)) 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 # URL is stored in a configmap (see get_url) url = db.Column(String(length=128), unique=False) @@ -229,6 +229,12 @@ class AppStatus(): # pylint: disable=too-few-public-methods :type app: App """ def __init__(self, app): + if app.external: + self.installed = True + self.ready = True + self.message = "App is external" + return + kustomization = app.kustomization if kustomization is not None and "status" in kustomization: ks_ready, ks_message = AppStatus.check_condition(kustomization['status']) diff --git a/cliapp/cliapp/cli.py b/cliapp/cliapp/cli.py index 8b148405..3355dc6a 100644 --- a/cliapp/cliapp/cli.py +++ b/cliapp/cliapp/cli.py @@ -105,12 +105,13 @@ def delete_app(slug): return app_status = app_obj.get_status() - if not app_status.installed: - app_obj.delete() - current_app.logger.info("Success.") - else: + if app_status.installed and not app_obj.external: current_app.logger.info("Can not delete installed application, run" " 'uninstall' first") + return + + app_obj.delete() + current_app.logger.info("Success.") @app_cli.command( -- GitLab