mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
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:
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user