Software /
code /
prosody
Changeset
13388:de6c1a170871
configmanager: Allow referencing previously-set options in the config file
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 08 Dec 2023 13:36:51 +0000 |
parents | 13387:e5ddae99faa8 |
children | 13389:47d0d80da208 |
files | core/configmanager.lua |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/core/configmanager.lua Thu Dec 07 12:08:01 2023 +0000 +++ b/core/configmanager.lua Fri Dec 08 13:36:51 2023 +0000 @@ -62,6 +62,16 @@ return false; end +local function rawget_option(config_table, host, key) + if host and key then + local hostconfig = rawget(config_table, host); + if not hostconfig then + return nil; + end + return rawget(hostconfig, key); + end +end + function _M.set(host, key, value) return set(config, host, key, value); end @@ -119,6 +129,10 @@ if k:match("^ENV_") then return os.getenv(k:sub(5)); end + local val = rawget_option(config_table, env.__currenthost or "*", k); + if val ~= nil then + return val; + end return rawget(_G, k); end, __newindex = function (_, k, v)