Change magic comment put next to config options which are forced through the environment

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2024-05-28 21:32:04 +02:00
parent 825a14a69b
commit 3de9e12f70
2 changed files with 8 additions and 11 deletions
+6 -8
View File
@@ -82,13 +82,6 @@ bool writeFTLtoml(const bool verbose)
print_toml_allowed_values(conf_item->a, fp, 85, level-1);
}
// Print info if this value is overwritten by an env var
if(conf_item->f & FLAG_ENV_VAR)
{
print_comment(fp, ">>> This config is overwritten by an environmental variable <<<", "", 85, level-1);
env_vars++;
}
// Write value
indentTOML(fp, level-1);
fprintf(fp, "%s = ", conf_item->p[level-1]);
@@ -105,7 +98,12 @@ bool writeFTLtoml(const bool verbose)
if(changed)
{
fprintf(fp, " ### CHANGED, default = ");
// Print info if this value is overwritten by an env var
if(conf_item->f & FLAG_ENV_VAR)
env_vars++;
fprintf(fp, " ### CHANGED%s, default = ", conf_item->f & FLAG_ENV_VAR ? " (env)" : "");
writeTOMLvalue(fp, -1, conf_item->t, &conf_item->d);
modified++;
}
+2 -3
View File
@@ -1326,10 +1326,9 @@
@test "Environmental variable is favored over config file" {
# The config file has -10 but we set FTLCONF_misc_nice="-11"
run bash -c 'grep -B1 "nice = -11" /etc/pihole/pihole.toml'
run bash -c 'grep "nice = -11" /etc/pihole/pihole.toml'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == " # >>> This config is overwritten by an environmental variable <<<" ]]
[[ ${lines[1]} == " nice = -11 ### CHANGED, default = -10" ]]
[[ ${lines[2]} == " nice = -11 ### CHANGED (env), default = -10" ]]
}
@test "Correct number of environmental variables is logged" {