Settings: Support null and undefined env var substitutions
parent
299dbbe7e6
commit
c7bb18c6da
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -10,6 +10,19 @@
|
||||||
connections to the MySQL/MariaDB server (by default) instead of 1. This might
|
connections to the MySQL/MariaDB server (by default) instead of 1. This might
|
||||||
cause Etherpad to crash with a "ER_CON_COUNT_ERROR: Too many connections"
|
cause Etherpad to crash with a "ER_CON_COUNT_ERROR: Too many connections"
|
||||||
error if your server is configured with a low connection limit.
|
error if your server is configured with a low connection limit.
|
||||||
|
* Changes to environment variable substitution in `settings.json` (see the
|
||||||
|
documentation comments in `settings.json.template` for details):
|
||||||
|
* An environment variable set to the string "null" now becomes `null` instead
|
||||||
|
of the string "null". Similarly, if the environment variable is unset and
|
||||||
|
the default value is "null" (e.g., `"${UNSET_VAR:null}"`), the value now
|
||||||
|
becomes `null` instead of the string "null". It is no longer possible to
|
||||||
|
produce the string "null" via environment variable substitution.
|
||||||
|
* An environment variable set to the string "undefined" now causes the setting
|
||||||
|
to be removed instead of set to the string "undefined". Similarly, if the
|
||||||
|
environment variable is unset and the default value is "undefined" (e.g.,
|
||||||
|
`"${UNSET_VAR:undefined}"`), the setting is now removed instead of set to
|
||||||
|
the string "undefined". It is no longer possible to produce the string
|
||||||
|
"undefined" via environment variable substitution.
|
||||||
|
|
||||||
### Notable enhancements
|
### Notable enhancements
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,29 @@
|
||||||
*
|
*
|
||||||
* This is useful, for example, when running in a Docker container.
|
* This is useful, for example, when running in a Docker container.
|
||||||
*
|
*
|
||||||
|
* DETAILED RULES:
|
||||||
|
* - If the environment variable is set to the string "true" or "false", the
|
||||||
|
* value becomes Boolean true or false.
|
||||||
|
* - If the environment variable is set to the string "null", the value
|
||||||
|
* becomes null.
|
||||||
|
* - If the environment variable is set to the string "undefined", the setting
|
||||||
|
* is removed entirely, except when used as the member of an array in which
|
||||||
|
* case it becomes null.
|
||||||
|
* - If the environment variable is set to a string representation of a finite
|
||||||
|
* number, the string is converted to that number.
|
||||||
|
* - If the environment variable is set to any other string, including the
|
||||||
|
* empty string, the value is that string.
|
||||||
|
* - If the environment variable is unset and a default value is provided, the
|
||||||
|
* value is as if the environment variable was set to the provided default:
|
||||||
|
* - "${UNSET_VAR:}" becomes the empty string.
|
||||||
|
* - "${UNSET_VAR:foo}" becomes the string "foo".
|
||||||
|
* - "${UNSET_VAR:true}" and "${UNSET_VAR:false}" become true and false.
|
||||||
|
* - "${UNSET_VAR:null}" becomes null.
|
||||||
|
* - "${UNSET_VAR:undefined}" causes the setting to be removed (or be set
|
||||||
|
* to null, if used as a member of an array).
|
||||||
|
* - If the environment variable is unset and no default value is provided,
|
||||||
|
* the value becomes null.
|
||||||
|
*
|
||||||
* EXAMPLE:
|
* EXAMPLE:
|
||||||
* "port": "${PORT:9001}"
|
* "port": "${PORT:9001}"
|
||||||
* "minify": "${MINIFY}"
|
* "minify": "${MINIFY}"
|
||||||
|
|
|
@ -15,6 +15,29 @@
|
||||||
*
|
*
|
||||||
* This is useful, for example, when running in a Docker container.
|
* This is useful, for example, when running in a Docker container.
|
||||||
*
|
*
|
||||||
|
* DETAILED RULES:
|
||||||
|
* - If the environment variable is set to the string "true" or "false", the
|
||||||
|
* value becomes Boolean true or false.
|
||||||
|
* - If the environment variable is set to the string "null", the value
|
||||||
|
* becomes null.
|
||||||
|
* - If the environment variable is set to the string "undefined", the setting
|
||||||
|
* is removed entirely, except when used as the member of an array in which
|
||||||
|
* case it becomes null.
|
||||||
|
* - If the environment variable is set to a string representation of a finite
|
||||||
|
* number, the string is converted to that number.
|
||||||
|
* - If the environment variable is set to any other string, including the
|
||||||
|
* empty string, the value is that string.
|
||||||
|
* - If the environment variable is unset and a default value is provided, the
|
||||||
|
* value is as if the environment variable was set to the provided default:
|
||||||
|
* - "${UNSET_VAR:}" becomes the empty string.
|
||||||
|
* - "${UNSET_VAR:foo}" becomes the string "foo".
|
||||||
|
* - "${UNSET_VAR:true}" and "${UNSET_VAR:false}" become true and false.
|
||||||
|
* - "${UNSET_VAR:null}" becomes null.
|
||||||
|
* - "${UNSET_VAR:undefined}" causes the setting to be removed (or be set
|
||||||
|
* to null, if used as a member of an array).
|
||||||
|
* - If the environment variable is unset and no default value is provided,
|
||||||
|
* the value becomes null.
|
||||||
|
*
|
||||||
* EXAMPLE:
|
* EXAMPLE:
|
||||||
* "port": "${PORT:9001}"
|
* "port": "${PORT:9001}"
|
||||||
* "minify": "${MINIFY}"
|
* "minify": "${MINIFY}"
|
||||||
|
|
|
@ -509,17 +509,13 @@ const coerceValue = (stringValue) => {
|
||||||
return +stringValue;
|
return +stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the boolean literal case is easy.
|
switch (stringValue) {
|
||||||
if (stringValue === 'true') {
|
case 'true': return true;
|
||||||
return true;
|
case 'false': return false;
|
||||||
|
case 'undefined': return undefined;
|
||||||
|
case 'null': return null;
|
||||||
|
default: return stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stringValue === 'false') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise, return this value as-is
|
|
||||||
return stringValue;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue