MXS-2304 Remove config_get_param()
Replaced with other functions. Also removed password deprecation check.
This commit is contained in:
@ -1709,34 +1709,6 @@ static bool process_config_context(CONFIG_CONTEXT* context)
|
|||||||
return error_count == 0;
|
return error_count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_passwd_deprecation(CONFIG_CONTEXT* obj)
|
|
||||||
{
|
|
||||||
if (auto p = config_get_param(obj->parameters, "passwd"))
|
|
||||||
{
|
|
||||||
if (obj->parameters->contains(CN_PASSWORD))
|
|
||||||
{
|
|
||||||
MXS_WARNING("Both 'password' and 'passwd' specified. Using value of '%s'.", CN_PASSWORD);
|
|
||||||
}
|
|
||||||
|
|
||||||
MXS_WARNING("The parameter 'passwd' is deprecated: use '%s' instead", CN_PASSWORD);
|
|
||||||
config_replace_param(obj, CN_PASSWORD, p->value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MXS_CONFIG_PARAMETER* config_get_param(MXS_CONFIG_PARAMETER* params, const char* name)
|
|
||||||
{
|
|
||||||
while (params)
|
|
||||||
{
|
|
||||||
if (!strcmp(params->name, name))
|
|
||||||
{
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
params = params->next;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MXS_CONFIG_PARAMETER::get_bool(const std::string& key) const
|
bool MXS_CONFIG_PARAMETER::get_bool(const std::string& key) const
|
||||||
{
|
{
|
||||||
string param_value = get_string(key);
|
string param_value = get_string(key);
|
||||||
@ -1963,25 +1935,18 @@ bool config_add_param(CONFIG_CONTEXT* obj, const char* key, const char* value)
|
|||||||
|
|
||||||
bool config_append_param(CONFIG_CONTEXT* obj, const char* key, const char* value)
|
bool config_append_param(CONFIG_CONTEXT* obj, const char* key, const char* value)
|
||||||
{
|
{
|
||||||
MXS_CONFIG_PARAMETER* param = config_get_param(obj->parameters, key);
|
mxb_assert(obj->parameters->contains(key));
|
||||||
mxb_assert(param);
|
auto old_val = obj->parameters->get_string(key);
|
||||||
int paramlen = strlen(param->value) + strlen(value) + 2;
|
string new_val = old_val + "," + value;
|
||||||
char tmp[paramlen];
|
char* new_val_z = config_clean_string_list(new_val.c_str());
|
||||||
|
|
||||||
bool rval = false;
|
bool rval = false;
|
||||||
|
if (new_val_z)
|
||||||
strcpy(tmp, param->value);
|
|
||||||
strcat(tmp, ",");
|
|
||||||
strcat(tmp, value);
|
|
||||||
|
|
||||||
char* new_value = config_clean_string_list(tmp);
|
|
||||||
|
|
||||||
if (new_value)
|
|
||||||
{
|
{
|
||||||
MXS_FREE(param->value);
|
MXS_CONFIG_PARAMETER::set(&obj->parameters, key, new_val_z);
|
||||||
param->value = new_value;
|
MXS_FREE(new_val_z);
|
||||||
rval = true;
|
rval = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3170,8 +3135,6 @@ static bool check_config_objects(CONFIG_CONTEXT* context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
do_passwd_deprecation(obj);
|
|
||||||
|
|
||||||
for (const auto& a : to_be_removed)
|
for (const auto& a : to_be_removed)
|
||||||
{
|
{
|
||||||
config_remove_param(obj, a.c_str());
|
config_remove_param(obj, a.c_str());
|
||||||
|
@ -253,12 +253,3 @@ void dump_param_list(int file,
|
|||||||
* @return True if the parameter can be modified at runtime
|
* @return True if the parameter can be modified at runtime
|
||||||
*/
|
*/
|
||||||
bool config_can_modify_at_runtime(const char* name);
|
bool config_can_modify_at_runtime(const char* name);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get a configuration parameter
|
|
||||||
*
|
|
||||||
* @param params List of parameters
|
|
||||||
* @param name Name of parameter to get
|
|
||||||
* @return The parameter or NULL if the parameter was not found
|
|
||||||
*/
|
|
||||||
MXS_CONFIG_PARAMETER* config_get_param(MXS_CONFIG_PARAMETER* params, const char* name);
|
|
||||||
|
@ -112,14 +112,13 @@ bool test_load_config(const char* input, Server* server)
|
|||||||
config_add_defaults(obj, config_server_params);
|
config_add_defaults(obj, config_server_params);
|
||||||
|
|
||||||
TEST(strcmp(obj->object, server->name()) == 0, "Server names differ");
|
TEST(strcmp(obj->object, server->name()) == 0, "Server names differ");
|
||||||
TEST(strcmp(server->address, config_get_param(param, "address")->value) == 0,
|
TEST(param->get_string("address") == server->address, "Server addresses differ");
|
||||||
"Server addresses differ");
|
TEST(param->get_string("protocol") == server->protocol(), "Server protocols differ");
|
||||||
TEST(server->protocol() == config_get_param(param, "protocol")->value,
|
TEST(param->get_string("authenticator") == server->get_authenticator(),
|
||||||
"Server protocols differ");
|
|
||||||
TEST(server->get_authenticator() == config_get_param(param, "authenticator")->value,
|
|
||||||
"Server authenticators differ");
|
"Server authenticators differ");
|
||||||
TEST(server->port == atoi(config_get_param(param, "port")->value), "Server ports differ");
|
TEST(param->get_integer("port") == server->port, "Server ports differ");
|
||||||
TEST(Server::server_alloc(obj->object, obj->parameters), "Failed to create server from loaded config");
|
TEST(Server::server_alloc(obj->object, obj->parameters),
|
||||||
|
"Failed to create server from loaded config");
|
||||||
duplicate_context_finish(&dcontext);
|
duplicate_context_finish(&dcontext);
|
||||||
config_context_free(obj);
|
config_context_free(obj);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user