Commit e09dfd2c authored by Isabella Almeida da Silva's avatar Isabella Almeida da Silva
Browse files

[SOMA-3827][SOMA-4162] Colocar warning quando tiver herdando sga_name default

- Simplicado o  uso de meta-tabelas
- Uso de raw_get para verificar se o valor estava na tabela de
configuração ou for herdado
parent f85e4755
......@@ -6,8 +6,8 @@ local schema = require("schema")
local function get(config_data, filename, config_default)
local config = {}
config_default.sgas = nil -- avoid multiple inside multiple
config_default.__index = function (t,k) return config_default[k] end
config_default.sgas = nil -- avoids multiple inside multiple
config_default.__index = config_default -- sets default values for the configuration
setmetatable(config, config_default)
local chunk, err = load(config_data, filename, "t", config)
if not chunk then
......@@ -22,7 +22,13 @@ local function get(config_data, filename, config_default)
if not ok then
return nil, "Failed processing config file "..filename..": "..err
return config
local warning = nil
-- Warns if the sga_name is being inherited from the default configuration and not explicitly declared
if config_default["sga_name"] and not rawget(config, "sga_name") then
warning = string.format("[WARNING] Config file %s contains configuration using default sga_name %s", filename, config_default["sga_name"])
return config, warning
local function get_from_multiple(filename, sga_name, config)
......@@ -41,6 +47,9 @@ local function get_from_multiple(filename, sga_name, config)
for key, data in ipairs(sgas_data) do
local sga_config, err_msg = {}
sga_config, err_msg = get(data, filename, config)
if err_msg then
table.insert(warning, err_msg)
if sga_config then
configuration.check(sga_config, true)
if sga_config.sga_name then
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment