mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Drop old code that tested the old configpanel/actions mechanism
This commit is contained in:
parent
711cfe5141
commit
63d32001ea
2 changed files with 0 additions and 298 deletions
288
lib/tests.sh
288
lib/tests.sh
|
@ -685,291 +685,3 @@ TEST_CHANGE_URL () {
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ACTIONS_CONFIG_PANEL () {
|
|
||||||
|
|
||||||
test_type=$1
|
|
||||||
|
|
||||||
# Define a function to split a file in multiple parts. Used for actions and config-panel toml
|
|
||||||
splitterAA()
|
|
||||||
{
|
|
||||||
local bound="$1"
|
|
||||||
local file="$2"
|
|
||||||
|
|
||||||
# If $2 is a real file
|
|
||||||
if [ -e "$file" ]
|
|
||||||
then
|
|
||||||
# Replace name of the file by its content
|
|
||||||
file="$(cat "$file")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local file_lenght=$(echo "$file" | wc --lines | awk '{print $1}')
|
|
||||||
|
|
||||||
bounds=($(echo "$file" | grep --line-number --extended-regexp "$bound" | cut -d':' -f1))
|
|
||||||
|
|
||||||
# Go for each line number (boundary) into the array
|
|
||||||
for line_number in $(seq 0 $(( ${#bounds[@]} -1 )))
|
|
||||||
do
|
|
||||||
# The first bound is the next line number in the array
|
|
||||||
# That the low bound on which we cut
|
|
||||||
first_bound=$(( ${bounds[$line_number+1]} - 1 ))
|
|
||||||
# If there's no next cell in the array, we got -1, in such case, use the lenght of the file.
|
|
||||||
# We cut at the end of the file
|
|
||||||
test $first_bound -lt 0 && first_bound=$file_lenght
|
|
||||||
# The second bound is the current line number in the array minus the next one.
|
|
||||||
# The the upper bound in the file.
|
|
||||||
second_bound=$(( ${bounds[$line_number]} - $first_bound - 1 ))
|
|
||||||
# Cut the file a first time from the beginning to the first bound
|
|
||||||
# And a second time from the end, back to the second bound.
|
|
||||||
parts[line_number]="$(echo "$file" | head --lines=$first_bound \
|
|
||||||
| tail --lines=$second_bound)"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$test_type" == "actions" ]
|
|
||||||
then
|
|
||||||
start_test "Actions"
|
|
||||||
|
|
||||||
toml_file="$package_path/actions.toml"
|
|
||||||
if [ ! -e "$toml_file" ]
|
|
||||||
then
|
|
||||||
log_error "No actions.toml found!"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
elif [ "$test_type" == "config_panel" ]
|
|
||||||
then
|
|
||||||
start_test "Config-panel"
|
|
||||||
|
|
||||||
toml_file="$package_path/config_panel.toml"
|
|
||||||
if [ ! -e "$toml_file" ]
|
|
||||||
then
|
|
||||||
log_error "No config_panel.toml found!"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if an install have previously work
|
|
||||||
at_least_one_install_succeeded || return 1
|
|
||||||
|
|
||||||
# Install the application in a LXC container
|
|
||||||
log_small_title "Preliminary install..."
|
|
||||||
local check_path="$(default_install_path)"
|
|
||||||
_LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path"
|
|
||||||
|
|
||||||
local main_result=0
|
|
||||||
|
|
||||||
# List first, then execute
|
|
||||||
local ret=0
|
|
||||||
local i=0
|
|
||||||
for i in $(seq 1 2)
|
|
||||||
do
|
|
||||||
# Do a test if the installation succeed
|
|
||||||
if [ $ret -ne 0 ]
|
|
||||||
then
|
|
||||||
log_error "The previous test has failed..."
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $i -eq 1 ]
|
|
||||||
then
|
|
||||||
if [ "$test_type" == "actions" ]
|
|
||||||
then
|
|
||||||
log_info "> List the available actions..."
|
|
||||||
|
|
||||||
# List the actions
|
|
||||||
_RUN_YUNOHOST_CMD "app action list $app_id"
|
|
||||||
local ret=$?
|
|
||||||
|
|
||||||
[ $ret -eq 0 ] || main_result=1
|
|
||||||
break_before_continue
|
|
||||||
|
|
||||||
elif [ "$test_type" == "config_panel" ]
|
|
||||||
then
|
|
||||||
log_info "> Show the config panel..."
|
|
||||||
|
|
||||||
# Show the config-panel
|
|
||||||
_RUN_YUNOHOST_CMD "app config show-panel $app_id"
|
|
||||||
local ret=$?
|
|
||||||
[ $ret -eq 0 ] || main_result=1
|
|
||||||
break_before_continue
|
|
||||||
|
|
||||||
fi
|
|
||||||
elif [ $i -eq 2 ]
|
|
||||||
then
|
|
||||||
local parts
|
|
||||||
if [ "$test_type" == "actions" ]
|
|
||||||
then
|
|
||||||
log_info "> Execute the actions..."
|
|
||||||
|
|
||||||
# Split the actions.toml file to separate each actions
|
|
||||||
splitterAA "^[[:blank:]]*\[[^.]*\]" "$toml_file"
|
|
||||||
elif [ "$test_type" == "config_panel" ]
|
|
||||||
then
|
|
||||||
log_info "> Apply configurations..."
|
|
||||||
|
|
||||||
# Split the config_panel.toml file to separate each configurations
|
|
||||||
splitterAA "^[[:blank:]]*\[.*\]" "$toml_file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Read each part, each action, one by one
|
|
||||||
for part in $(seq 0 $(( ${#parts[@]} -1 )))
|
|
||||||
do
|
|
||||||
local action_config_argument_name=""
|
|
||||||
local action_config_argument_type=""
|
|
||||||
local action_config_argument_default=""
|
|
||||||
local actions_config_arguments_specifics=""
|
|
||||||
local nb_actions_config_arguments_specifics=1
|
|
||||||
|
|
||||||
# Ignore part of the config_panel which are only titles
|
|
||||||
if [ "$test_type" == "config_panel" ]
|
|
||||||
then
|
|
||||||
# A real config_panel part should have a `ask = ` line. Ignore the part if not.
|
|
||||||
if ! echo "${parts[$part]}" | grep --quiet --extended-regexp "^[[:blank:]]*ask ="
|
|
||||||
then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
# Get the name of the config. ask = "Config ?"
|
|
||||||
local action_config_name="$(echo "${parts[$part]}" | grep "ask *= *" | sed 's/^.* = \"\(.*\)\"/\1/')"
|
|
||||||
|
|
||||||
# Get the config argument name "YNH_CONFIG_part1_part2.part3.partx"
|
|
||||||
local action_config_argument_name="$(echo "${parts[$part]}" | grep "^[[:blank:]]*\[.*\]$")"
|
|
||||||
# Remove []
|
|
||||||
action_config_argument_name="${action_config_argument_name//[\[\]]/}"
|
|
||||||
# And remove spaces
|
|
||||||
action_config_argument_name="${action_config_argument_name// /}"
|
|
||||||
|
|
||||||
elif [ "$test_type" == "actions" ]
|
|
||||||
then
|
|
||||||
# Get the name of the action. name = "Name of the action"
|
|
||||||
local action_config_name="$(echo "${parts[$part]}" | grep "name" | sed 's/^.* = \"\(.*\)\"/\1/')"
|
|
||||||
|
|
||||||
# Get the action. [action]
|
|
||||||
local action_config_action="$(echo "${parts[$part]}" | grep "^\[.*\]$" | sed 's/\[\(.*\)\]/\1/')"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if there's any [action.arguments]
|
|
||||||
# config_panel always have arguments.
|
|
||||||
if echo "${parts[$part]}" | grep --quiet "$action_config_action\.arguments" || [ "$test_type" == "config_panel" ]
|
|
||||||
then local action_config_has_arguments=1
|
|
||||||
else local action_config_has_arguments=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If there's arguments for this action.
|
|
||||||
if [ $action_config_has_arguments -eq 1 ]
|
|
||||||
then
|
|
||||||
if [ "$test_type" == "actions" ]
|
|
||||||
then
|
|
||||||
# Get the argument [action.arguments.name_of_the_argument]
|
|
||||||
action_config_argument_name="$(echo "${parts[$part]}" | grep "$action_config_action\.arguments\." | sed 's/.*\.\(.*\)]/\1/')"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get the type of the argument. type = "type"
|
|
||||||
action_config_argument_type="$(echo "${parts[$part]}" | grep "type" | sed 's/^.* = \"\(.*\)\"/\1/')"
|
|
||||||
# Get the default value of this argument. default = true
|
|
||||||
action_config_argument_default="$(echo "${parts[$part]}" | grep "default" | sed 's/^.* = \(.*\)/\1/')"
|
|
||||||
# Do not use true or false, use 1/0 instead
|
|
||||||
if [ "$action_config_argument_default" == "true" ] && [ "$action_config_argument_type" == "boolean" ]; then
|
|
||||||
action_config_argument_default=1
|
|
||||||
elif [ "$action_config_argument_default" == "false" ] && [ "$action_config_argument_type" == "boolean" ]; then
|
|
||||||
action_config_argument_default=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$test_type" == "config_panel" ]
|
|
||||||
then
|
|
||||||
check_process_arguments=""
|
|
||||||
while read line
|
|
||||||
do
|
|
||||||
# Remove all double quotes
|
|
||||||
add_arg="${line//\"/}"
|
|
||||||
# Then add this argument and follow it by :
|
|
||||||
check_process_arguments="${check_process_arguments}${add_arg}:"
|
|
||||||
done < <(jq -r '.extra.configpanel' $current_test_infos)
|
|
||||||
elif [ "$test_type" == "actions" ]
|
|
||||||
then
|
|
||||||
local check_process_arguments=""
|
|
||||||
while read line
|
|
||||||
do
|
|
||||||
# Remove all double quotes
|
|
||||||
add_arg="${line//\"/}"
|
|
||||||
# Then add this argument and follow it by :
|
|
||||||
check_process_arguments="${check_process_arguments}${add_arg}:"
|
|
||||||
done < <(jq -r '.extra.actions' $current_test_infos)
|
|
||||||
fi
|
|
||||||
# Look for arguments into the check_process
|
|
||||||
if echo "$check_process_arguments" | grep --quiet "$action_config_argument_name"
|
|
||||||
then
|
|
||||||
# If there's arguments for this actions into the check_process
|
|
||||||
# Isolate the values
|
|
||||||
actions_config_arguments_specifics="$(echo "$check_process_arguments" | sed "s/.*$action_config_argument_name=\(.*\)/\1/")"
|
|
||||||
# And remove values of the following action
|
|
||||||
actions_config_arguments_specifics="${actions_config_arguments_specifics%%\:*}"
|
|
||||||
nb_actions_config_arguments_specifics=$(( $(echo "$actions_config_arguments_specifics" | tr --complement --delete "|" | wc --chars) + 1 ))
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$test_type" == "config_panel" ]
|
|
||||||
then
|
|
||||||
# Finish to format the name
|
|
||||||
# Remove . by _
|
|
||||||
action_config_argument_name="${action_config_argument_name//./_}"
|
|
||||||
# Move all characters to uppercase
|
|
||||||
action_config_argument_name="${action_config_argument_name^^}"
|
|
||||||
# Add YNH_CONFIG_
|
|
||||||
action_config_argument_name="YNH_CONFIG_$action_config_argument_name"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Loop on the number of values into the check_process.
|
|
||||||
# Or loop once for the default value
|
|
||||||
for j in $(seq 1 $nb_actions_config_arguments_specifics)
|
|
||||||
do
|
|
||||||
local action_config_argument_built=""
|
|
||||||
if [ $action_config_has_arguments -eq 1 ]
|
|
||||||
then
|
|
||||||
# If there's values into the check_process
|
|
||||||
if [ -n "$actions_config_arguments_specifics" ]
|
|
||||||
then
|
|
||||||
# Build the argument from a value from the check_process
|
|
||||||
local action_config_actual_argument="$(echo "$actions_config_arguments_specifics" | cut -d'|' -f $j)"
|
|
||||||
action_config_argument_built="--args \"$action_config_argument_name=$action_config_actual_argument\""
|
|
||||||
elif [ -n "$action_config_argument_default" ]
|
|
||||||
then
|
|
||||||
# Build the argument from the default value
|
|
||||||
local action_config_actual_argument="$action_config_argument_default"
|
|
||||||
action_config_argument_built="--args \"$action_config_argument_name=$action_config_actual_argument\""
|
|
||||||
else
|
|
||||||
log_warning "> No argument into the check_process to use or default argument for \"$action_config_name\"..."
|
|
||||||
action_config_actual_argument=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$test_type" == "config_panel" ]
|
|
||||||
then
|
|
||||||
log_info "> Apply the configuration for \"$action_config_name\" with the argument \"$action_config_actual_argument\"..."
|
|
||||||
elif [ "$test_type" == "actions" ]
|
|
||||||
then
|
|
||||||
log_info "> Execute the action \"$action_config_name\" with the argument \"$action_config_actual_argument\"..."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_info "> Execute the action \"$action_config_name\"..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$test_type" == "config_panel" ]
|
|
||||||
then
|
|
||||||
# Aply a configuration
|
|
||||||
_RUN_YUNOHOST_CMD "app config apply $app_id $action_config_action $action_config_argument_built"
|
|
||||||
ret=$?
|
|
||||||
elif [ "$test_type" == "actions" ]
|
|
||||||
then
|
|
||||||
# Execute an action
|
|
||||||
_RUN_YUNOHOST_CMD "app action run $app_id $action_config_action $action_config_argument_built"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
[ $ret -eq 0 ] || main_result=1
|
|
||||||
break_before_continue
|
|
||||||
done
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
return $main_result
|
|
||||||
}
|
|
||||||
|
|
|
@ -81,8 +81,6 @@ parse_check_process() {
|
||||||
local install_args=$( extract_check_process_section "^; Manifest" "^; " $test_serie_rawconf | sed 's/\s*(.*)$//g' | tr -d '"' | tr '\n' '&')
|
local install_args=$( extract_check_process_section "^; Manifest" "^; " $test_serie_rawconf | sed 's/\s*(.*)$//g' | tr -d '"' | tr '\n' '&')
|
||||||
local preinstall_template=$(extract_check_process_section "^; pre-install" "^; " $test_serie_rawconf)
|
local preinstall_template=$(extract_check_process_section "^; pre-install" "^; " $test_serie_rawconf)
|
||||||
local preupgrade_template=$(extract_check_process_section "^; pre-upgrade" "^; " $test_serie_rawconf)
|
local preupgrade_template=$(extract_check_process_section "^; pre-upgrade" "^; " $test_serie_rawconf)
|
||||||
local action_infos=$( extract_check_process_section "^; Actions" "^; " $test_serie_rawconf)
|
|
||||||
local configpanel_infos=$( extract_check_process_section "^; Config_panel" "^; " $test_serie_rawconf)
|
|
||||||
|
|
||||||
# Add (empty) special args if they ain't provided in check_process
|
# Add (empty) special args if they ain't provided in check_process
|
||||||
echo "$install_args" | tr '&' '\n' | grep -q "^domain=" ||install_args+="domain=&"
|
echo "$install_args" | tr '&' '\n' | grep -q "^domain=" ||install_args+="domain=&"
|
||||||
|
@ -118,12 +116,6 @@ parse_check_process() {
|
||||||
local upgrade_name="$test_arg"
|
local upgrade_name="$test_arg"
|
||||||
fi
|
fi
|
||||||
extra="$(jq -n --arg upgrade_name "$upgrade_name" '{ $upgrade_name }')"
|
extra="$(jq -n --arg upgrade_name "$upgrade_name" '{ $upgrade_name }')"
|
||||||
elif [[ "$test_type" == "ACTIONS_CONFIG_PANEL" ]] && [[ "$test_arg" == "actions" ]]
|
|
||||||
then
|
|
||||||
extra="$(jq -n --arg actions "$action_infos" '{ $actions }')"
|
|
||||||
elif [[ "$test_type" == "ACTIONS_CONFIG_PANEL" ]] && [[ "$test_arg" == "config_panel" ]]
|
|
||||||
then
|
|
||||||
extra="$(jq -n --arg configpanel "$configpanel_infos" '{ $configpanel }')"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
jq -n \
|
jq -n \
|
||||||
|
@ -158,8 +150,6 @@ parse_check_process() {
|
||||||
# "Advanced" features
|
# "Advanced" features
|
||||||
|
|
||||||
is_test_enabled change_url && add_test "TEST_CHANGE_URL"
|
is_test_enabled change_url && add_test "TEST_CHANGE_URL"
|
||||||
is_test_enabled actions && add_test "ACTIONS_CONFIG_PANEL" "actions"
|
|
||||||
is_test_enabled config_panel && add_test "ACTIONS_CONFIG_PANEL" "config_panel"
|
|
||||||
|
|
||||||
# Port already used ... do we really need this ...
|
# Port already used ... do we really need this ...
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue