config
Module
The config
module allows interaction with the agent's configuration.
To import it, use the following declaration:
Configuration
This module does not require specific configuration in the Alemca agent's configuration file. It is automatically loaded when the agent starts.
Lua Functions
config.all()
Returns the complete configuration of the Alemca agent.
- Return:
- A Lua table containing the full agent configuration.
nil
and an error message in case of failure.
local config = require("config")
-- fetch the whole config as a Lua table
local all, err = config.all()
assert(not err, err)
printInfo(all.global.ident)
config.get(path)
Returns the value from the configuration at a specific path.
The path must follow the format section.key
(e.g., global.client_root
).
- Parameters:
-
path
(string): The configuration path to retrieve. -
Return:
- The configuration value at the specified path.
nil
and an error message in case of failure.
local config = require("config")
local client_root, err = config.get("global.client_root")
assert(not err, err)
printInfo(client_root)
config.prefix(prefix)
Returns a subset of the configuration filtered by a prefix path.
The prefix should be a top-level section name, such as global
or iot
.
- Parameters:
-
prefix
(string): The top-level configuration prefix to filter by. -
Return:
- A Lua table containing the configuration filtered by the prefix.
nil
and an error message in case of failure.
local config = require("config")
function printRecursive(t, indent)
for k, v in pairs(t) do
if type(v) == "table" then
printInfo(string.format("%s%s:", indent, k))
printRecursive(v, indent .. " ")
else
printInfo(string.format("%s%s: %s", indent, k, v))
end
end
end
local iot, err = config.prefix("iot")
assert(not err, err)
printRecursive(iot, " ")
Associated Lua Fields
config.name
: Returns the name of theconfig
module instance.config.type
: Returns the module type (here,config
).