Allow module level parameter deprecation
Parameter deprecation on the module level means that the parameter should no longer be used but using it will not cause an error. If a deprecated parameter is used, it will be removed from the configuration.
This commit is contained in:
parent
96af90628f
commit
fd2d22eba6
@ -107,7 +107,11 @@ enum mxs_module_param_options
|
||||
MXS_MODULE_OPT_PATH_W_OK = (1 << 3), /**< PATH: Write permission to path required */
|
||||
MXS_MODULE_OPT_PATH_F_OK = (1 << 4), /**< PATH: Path must exist */
|
||||
MXS_MODULE_OPT_PATH_CREAT = (1 << 5), /**< PATH: Create path if it doesn't exist */
|
||||
MXS_MODULE_OPT_ENUM_UNIQUE = (1 << 6) /**< ENUM: Only one value can be defined */
|
||||
MXS_MODULE_OPT_ENUM_UNIQUE = (1 << 6), /**< ENUM: Only one value can be defined */
|
||||
|
||||
/**< Parameter is deprecated: Causes a warning to be logged if the parameter
|
||||
* is used but will not cause a configuration error. */
|
||||
MXS_MODULE_OPT_DEPRECATED = (1 << 7),
|
||||
};
|
||||
|
||||
/** String to enum value mappings */
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <ini.h>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <maxscale/adminusers.h>
|
||||
#include <maxscale/alloc.h>
|
||||
@ -2391,6 +2392,27 @@ static void process_path_parameter(MXS_CONFIG_PARAMETER *param)
|
||||
}
|
||||
}
|
||||
|
||||
static bool param_is_deprecated(const MXS_MODULE_PARAM* params, const char* name, const char* modname)
|
||||
{
|
||||
bool rval = false;
|
||||
|
||||
for (int i = 0; params[i].name; i++)
|
||||
{
|
||||
if (strcmp(params[i].name, name) == 0)
|
||||
{
|
||||
if (params[i].options & MXS_MODULE_OPT_DEPRECATED)
|
||||
{
|
||||
MXS_WARNING("Parameter '%s' for module '%s' is deprecated and "
|
||||
"will be ignored.", name, modname);
|
||||
rval = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check that the configuration objects have valid parameters
|
||||
*
|
||||
@ -2440,6 +2462,8 @@ check_config_objects(CONFIG_CONTEXT *context)
|
||||
|
||||
if (param_set != NULL)
|
||||
{
|
||||
std::vector<std::string> to_be_removed;
|
||||
|
||||
MXS_CONFIG_PARAMETER *params = obj->parameters;
|
||||
while (params)
|
||||
{
|
||||
@ -2471,9 +2495,19 @@ check_config_objects(CONFIG_CONTEXT *context)
|
||||
/** Fix old-style object names */
|
||||
config_fix_param(mod->parameters, params);
|
||||
}
|
||||
|
||||
if (mod && param_is_deprecated(mod->parameters, params->name, obj->object))
|
||||
{
|
||||
to_be_removed.push_back(params->name);
|
||||
}
|
||||
}
|
||||
params = params->next;
|
||||
}
|
||||
|
||||
for (auto it = to_be_removed.begin(); it != to_be_removed.end(); it++)
|
||||
{
|
||||
config_remove_param(obj, it->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (mod && missing_required_parameters(mod->parameters, obj->parameters))
|
||||
|
Loading…
x
Reference in New Issue
Block a user