The following patch improved error messages for server-template lines.
This properly used <tmpl_info.prefix> instead of the <id> field for
them, which prevents to display an empty string.
94024a60dc197b26a13751a6a0eaa3071f023cfa
MINOR: server: improve parsing error for server-template
This patch relied on server-template instance detection by checking if
<id> field is NULL. However, this is not appropriate once a
server-template has its ID assigned during _srv_parse_tmpl_init(). The
expanded name is displayed, which can be a misleading information as
this is not present directly in the configuration.
This patch fixes this by now detecting a server-template by checking if
its <tmpl_info.prefix> is non NULL. Thus, a server-template remains
detected as such even after its ID has been generating. Its template
name is used on error messages instead of the expanded prefix.
switch (obj_type(ctx->obj)) {
case OBJ_TYPE_SERVER:
srv = __objt_server(ctx->obj);
- srv_id = srv->id ? srv->id : srv->tmpl_info.prefix;
+ srv_id = srv->tmpl_info.prefix ? srv->tmpl_info.prefix : srv->id;
ret = snprintf(b_tail(&ctx->str), b_room(&ctx->str),
"'%s %s/%s' : ",
- srv->id ? "server" : "server-template",
+ srv->tmpl_info.prefix ? "server-template" : "server",
srv->proxy->id, srv_id);
b_add(&ctx->str, MIN(ret, b_room(&ctx->str)));
break;