mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
config helpers: Semantics / comments on the validation-apply workflow
This commit is contained in:
parent
62eecb28db
commit
ee55b9bf42
1 changed files with 11 additions and 8 deletions
|
@ -160,7 +160,8 @@ _ynh_app_config_show() {
|
||||||
_ynh_app_config_validate() {
|
_ynh_app_config_validate() {
|
||||||
# Change detection
|
# Change detection
|
||||||
ynh_script_progression --message="Checking what changed in the new configuration..." --weight=1
|
ynh_script_progression --message="Checking what changed in the new configuration..." --weight=1
|
||||||
local is_error=true
|
local nothing_changed=true
|
||||||
|
local changes_validated=true
|
||||||
#for changed_status in "${!changed[@]}"
|
#for changed_status in "${!changed[@]}"
|
||||||
for short_setting in "${!old[@]}"
|
for short_setting in "${!old[@]}"
|
||||||
do
|
do
|
||||||
|
@ -178,7 +179,7 @@ _ynh_app_config_validate() {
|
||||||
file_hash[old__$short_setting]=$(sha256sum "${old[$short_setting]}" | cut -d' ' -f1)
|
file_hash[old__$short_setting]=$(sha256sum "${old[$short_setting]}" | cut -d' ' -f1)
|
||||||
if [ -z "${!short_setting}" ] ; then
|
if [ -z "${!short_setting}" ] ; then
|
||||||
changed[$short_setting]=true
|
changed[$short_setting]=true
|
||||||
is_error=false
|
nothing_changed=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -f "${!short_setting}" ] ; then
|
if [ -f "${!short_setting}" ] ; then
|
||||||
|
@ -186,18 +187,18 @@ _ynh_app_config_validate() {
|
||||||
if [[ "${file_hash[old__$short_setting]}" != "${file_hash[new__$short_setting]}" ]]
|
if [[ "${file_hash[old__$short_setting]}" != "${file_hash[new__$short_setting]}" ]]
|
||||||
then
|
then
|
||||||
changed[$short_setting]=true
|
changed[$short_setting]=true
|
||||||
is_error=false
|
nothing_changed=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ "${!short_setting}" != "${old[$short_setting]}" ]]
|
if [[ "${!short_setting}" != "${old[$short_setting]}" ]]
|
||||||
then
|
then
|
||||||
changed[$short_setting]=true
|
changed[$short_setting]=true
|
||||||
is_error=false
|
nothing_changed=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ "$is_error" == "true" ]]
|
if [[ "$nothing_changed" == "true" ]]
|
||||||
then
|
then
|
||||||
ynh_print_info "Nothing has changed"
|
ynh_print_info "Nothing has changed"
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -217,11 +218,13 @@ _ynh_app_config_validate() {
|
||||||
then
|
then
|
||||||
local key="YNH_ERROR_${short_setting}"
|
local key="YNH_ERROR_${short_setting}"
|
||||||
ynh_return "$key: \"$result\""
|
ynh_return "$key: \"$result\""
|
||||||
is_error=true
|
changes_validated=false
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "$is_error" == "true" ]]
|
# If validation failed, exit the script right now (instead of going into apply)
|
||||||
|
# Yunohost core will pick up the errors returned via ynh_return previously
|
||||||
|
if [[ "$changes_validated" == "false" ]]
|
||||||
then
|
then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue