Merge pull request #42 from YunoHost/report-arg-type-issues

Report missing or bad manifest arg type, or unecessary 'choices' usage
This commit is contained in:
Alexandre Aubin 2019-02-07 15:48:39 +01:00 committed by GitHub
commit 6ed98bf540
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -272,13 +272,21 @@ def check_manifest(path):
print_warning("[YEP-2.1] " + service + " service may not exist") print_warning("[YEP-2.1] " + service + " service may not exist")
if "install" in manifest["arguments"]: if "install" in manifest["arguments"]:
types = ("domain", "path", "password", "user", "admin")
for nbr, typ in enumerate(types): recognized_types = ("domain", "path", "boolean", "app", "password", "user", "string")
for install_arg in manifest["arguments"]["install"]:
if typ == install_arg["name"]: for argument in manifest["arguments"]["install"]:
if "type" not in install_arg: if not "type" in argument.keys():
print_error("[YEP-2.1] You should specify the type of the key with %s" % (typ)) print_error("[YEP-2.1] You should specify the type of the argument '%s'. You can use : %s." % (argument["name"], ', '.join(recognized_types)))
elif argument["type"] not in recognized_types:
print_warning("[YEP-2.1] The type '%s' for argument '%s' is not recognized... it probably doesn't behave as you expect ? Choose among those instead : %s" % (argument["type"], argument["name"], ', '.join(recognized_types)))
if "choices" in argument.keys():
choices = [ c.lower() for c in argument["choices"] ]
if len(choices) == 2:
if ("true" in choices and "false" in choices) or ("yes" in choices and "no" in choices):
print_warning("Argument %s : you might want to simply use a boolean-type argument. No need to specify the choices list yourself." % argument["name"])
if "url" in manifest and manifest["url"].endswith("_ynh"): if "url" in manifest and manifest["url"].endswith("_ynh"):
print_warning("'url' is not meant to be the url of the yunohost package, but rather the website or repo of the upstream app itself...") print_warning("'url' is not meant to be the url of the yunohost package, but rather the website or repo of the upstream app itself...")