From 1b4f99575ee9f8ca19d7acfa9d1cd2ff974bccc2 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 20 Feb 2023 18:02:27 +0100 Subject: [PATCH] Moving warnings from the core about consistency for apt resources vs database requirement --- package_linter.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/package_linter.py b/package_linter.py index e7f8ce5..45f271b 100755 --- a/package_linter.py +++ b/package_linter.py @@ -1900,6 +1900,39 @@ class Manifest(TestSuite): % argument.get("name") ) + @test() + def resource_consistency(self): + + if app_packaging_format <= 1: + return + + resources = self.manifest["resources"] + + if "database" in list(resources.keys()): + if "apt" not in list(resources.keys()): + yield Warning( + "Having an 'apt' resource is mandatory when using a 'database' resource, to also install postgresql/mysql if needed" + ) + else: + if list(resources.keys()).index("database") < list( + resources.keys() + ).index("apt"): + yield Warning( + "The 'apt' resource should be placed before the 'database' resource, to install postgresql/mysql if needed *before* provisioning the database" + ) + + dbtype = resources["database"]["type"] + apt_packages = resources["apt"].get("packages", "").split(", ") + if dbtype == "mysql" and "mariadb-server" not in apt_packages: + yield Warning( + "When using a mysql database, you should add mariadb-server in apt dependencies. Even though it's currently installed by default in YunoHost installations, it might not be in the future !" + ) + if dbtype == "postgresql" and "postgresql" not in apt_packages: + yield Warning( + "When using a postgresql database, you should add postgresql in apt dependencies." + ) + + ######################################## # _____ _ _ # # / __ \ | | | | #