From a0c2b22be91b0ef56cc054e1c979d9ccac1f3f82 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 19 Dec 2020 03:03:18 +0100 Subject: [PATCH] Fetch default value from manifest --- lib/tests.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/tests.sh b/lib/tests.sh index 17c35ed..caf0d9b 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -58,9 +58,18 @@ _INSTALL_APP () { LXC_START "bash /preinstall.sh" fi + # Note : we do this at this stage and not during the parsing of check_process + # because this also applies to upgrades ... + # For all manifest arg for ARG in $(jq -r '.arguments.install[].name' $package_path/manifest.json) do - echo "$install_args" | grep -q -E "\<$ARG=" || { log_error "Missing install arg $ARG ?"; return 1; } + # If the argument is not yet in install args, add its default value + if ! echo "$install_args" | grep -q -E "\<$ARG=" + then + local default_value=$(jq -e -r --arg ARG $ARG '.arguments.install[] | select(.name==$ARG) | .default' $package_path/manifest.json) + [[ $? -eq 0 ]] || { log_error "Missing install arg $ARG ?"; return 1; } + install_args+="&$ARG=$default_value" + fi done # Install the application in a LXC container