Commit graph

94 commits

Author SHA1 Message Date
Kim Alvefur
6b1e056142 core.configmanager: Pass name and line number in context
Delays the string interpolation until the warning is logged, which may
slightly lower memory usage.

Allows retrieving the filename and line number easily.
2025-02-22 00:04:51 +01:00
Kim Alvefur
5e41daac79 core.configmanager: Fix reporting delayed warnings from global section
A Credential in the global section would be stored at
delayed_warnings["*/secret"], but get("example.com","secret") would look
for delayed_warnings["example.com/secret"]

Storing the warnings in the config itself has the unfortunate
side-effect that the config now contains util.error objects, which may
be awkward if something bypasses get(). Should rawget() also do this
filtering? getconfig() too?

Currently this only affects prosodyctl, so maybe it won't be much of a
problem.
2025-02-22 00:08:18 +01:00
Kim Alvefur
9eedb15c6f core.configmanager: Remove dependency on 'prosody' global for Credential
Minimizing dependencies on global state is nice, as it makes using
configmanager outside of Prosody easier.
2025-02-22 00:00:41 +01:00
Kim Alvefur
e91c540eea core.configmanager: Delay reporting warnings about Credential until use
Too much noise to use Credential if you get a pile of warnings every
time you touch prosodyctl for anything. This way warnings should be
printed only if e.g used by prosodyctl check config or a module command.
2025-02-12 22:35:39 +01:00
Kim Alvefur
2d4ea8ac9b core.configmanager: Remove compat
I have updated my config now, have you? :)
2025-01-21 17:21:48 +01:00
Kim Alvefur
97884eb956 util.startup: Rename credentials path variable too 2025-01-18 13:29:59 +01:00
Kim Alvefur
059d6457e0 core.configmanager: Rename Secret to Credential
To match the variable name and what systemd calls them.
2025-01-18 12:31:48 +01:00
Kim Alvefur
41a360ce2a core.configmanager: Add function for getting secrets from separate files
Idea is to enable easily retrieving of secret values from files outside
of the config, e.g. via the method used by systemd credentials.

CREDENTIALS_DIRECTORY is expected to be set by the process manager
invoking Prosody, so being unset and unavailable from prosodyctl is
going to be normal and a warning is reported in that case. Care will
have to be taken to make it clear that prosodyctl check will not work
with such values. An error is thrown if the directory is unavailable
when running under Prosody.
2025-01-16 15:21:34 +01:00
Kim Alvefur
2f37c443b8 core.configmanager: Add ways to read config values from files
Inspired by something MattJ said

Allows retrieving config values from files which are expected to be
relative to the config directory, extending on the ENV_ method of
retrieving config values from outside the config file.

- FileLine retrieves the first line, stripping any trailing newline
- FileContents reads the whole file
- FileLines reads lines into an array
2025-01-16 15:05:00 +01:00
Matthew Wild
9bd1726821 configmanager: Fix linter issues 2023-12-08 15:37:13 +00:00
Matthew Wild
7a288248f0 configmanager: Support for appending to existing config options
...and some other useful operations
2023-12-08 15:34:48 +00:00
Matthew Wild
cc0f973628 configmanager: Make _G accessible via Lua variable, deprecate direct access 2023-12-08 14:24:49 +00:00
Matthew Wild
c2d0d411d4 configmanager: Allow referencing previously-set options in the config file 2023-12-08 13:36:51 +00:00
Kim Alvefur
d47a7bb3bd core: Prefix module imports with prosody namespace 2023-03-17 16:23:07 +01:00
Kim Alvefur
67177ce287 core.configmanager: Remove COMPAT for old config format from 2013 2022-05-29 16:06:42 +02:00
Matthew Wild
0f493bd245 configmanager: Clearer errors when providing unexpected values after VirtualHost (fixes #1735, thanks arawaks) 2022-04-03 12:56:11 +01:00
Matthew Wild
a52c531dc5 configmanager: Add method to report loaded config files (part of #1729 fix) 2022-03-28 11:41:32 +01:00
Matthew Wild
c482490bff configmanager: Update error message to say 'VirtualHost' instead of 'Host' 2021-12-20 20:46:24 +00:00
Kim Alvefur
f563584fca core.configmanager: Handle nameprep validation errors 2019-11-02 13:56:13 +01:00
Kim Alvefur
4b69a96d83 core.configmanager: Ensure Hosts are given names
Prevents traceback from nameprep(nil)
2019-11-02 13:55:38 +01:00
Matthew Wild
7dfdcd5e09 configmanager: Pass through warnings from included files 2019-03-20 12:45:08 +00:00
Matthew Wild
1e6c93ec05 configmanager: Emit warning for duplicated config options 2019-03-20 12:20:51 +00:00
Matthew Wild
76ebc7778e configmanager: Add support for returning warnings 2019-03-20 12:19:43 +00:00
Matthew Wild
c9cc5d4a6e configmanager: Allow referencing environment variables in the config as as ENV_<name> 2018-09-03 17:45:30 +01:00
Kim Alvefur
7e64fa124a configmanager: Move firing of the 'config-reloaded' event into util.startup (fixes #1117) 2018-03-25 17:02:00 +02:00
Kim Alvefur
43b814a83b vairious: Add annotation when an empty environment is set [luacheck] 2018-02-28 20:06:26 +01:00
Kim Alvefur
ab47caa72f configmanager: Remove unused local [luacheck] 2017-05-28 23:40:26 +02:00
Emmanuel Gil Peyrot
eb231e9eab configmanager: Remove support for multiple parsers, fixes #852. 2017-05-27 15:32:28 +01:00
Kim Alvefur
1ecc3a7918 core: Split some very long lines [luacheck] 2017-03-04 17:49:48 +01:00
Kim Alvefur
27265c20e2 core.*: Remove use of module() function 2015-02-21 10:42:19 +01:00
Matthew Wild
f96b8f343a configmanager: Refactor function to avoid re-declaring local variable [luacheck] 2015-05-18 19:07:31 +01:00
Matthew Wild
3de0d3e049 configmanager: Rename unused function arguments [luacheck] 2015-05-18 19:07:06 +01:00
Matthew Wild
55f7842f8a configmanager: Rename variable to avoid name conflicts [luacheck] 2015-05-18 19:06:34 +01:00
Matthew Wild
0558bfbcb7 configmanager: Rename unused function argument [luacheck] 2015-05-18 19:05:26 +01:00
Matthew Wild
9dcab34382 configmanager: Remove unnecessary function localizations [luacheck] 2015-05-18 19:05:08 +01:00
Matthew Wild
c9c311b940 configmanager: Rename variable to avoid name conflict [luacheck] 2015-05-18 19:04:37 +01:00
Matthew Wild
7523668ad0 configmanager: Rename variable to avoid name conflict [luacheck] 2015-05-18 19:03:07 +01:00
Matthew Wild
3b8d61bf98 Merge 0.9->0.10 2014-07-31 07:11:54 +01:00
Matthew Wild
fa962495db configmanager: nameprep VirtualHost and Component names 2014-07-31 06:56:21 +01:00
Kim Alvefur
cb8d6cd008 Merge 0.9->0.10 2014-05-09 23:28:09 +02:00
Kim Alvefur
eeacb3cb6f configmanager: Delay importing LuaFileSystem until needed by an Include line 2014-05-09 19:59:49 +02:00
Kim Alvefur
084761b5ef core.configmanager: Move path utility functions into util.paths 2014-05-09 19:34:35 +02:00
Matthew Wild
8eb7b73968 Merge 0.9->trunk 2013-09-03 00:20:28 +01:00
Kim Alvefur
e7c0815019 configmanager: Fix checking of absolute paths on Windows 2013-08-30 18:51:55 +02:00
Florian Zeitz
1d833bb807 Remove all trailing whitespace 2013-08-09 17:48:21 +02:00
Matthew Wild
245f460991 configmanager: Some cleanup, remove unused variables and imports 2013-04-03 08:14:55 +01:00
Kim Alvefur
869da6c240 configmanager: Fix so unset variables are searched for in the global section 2013-03-23 04:14:52 +01:00
Matthew Wild
ee5a8c9543 configmanager, hostmanager, prosody: Almost complete removal of section-related code, and the infamous 'core' section. Still backwards-compatible with API users. 2013-03-22 11:21:24 +00:00
Matthew Wild
3c5b09b7f1 configmanager: Fix include of relative files via Include directive in config 2012-09-13 18:31:34 +01:00
Florian Zeitz
d49b9bc2ab Eliminate direct setfenv usage 2012-06-08 05:04:38 +02:00