Skip to content

Commit c461f3e

Browse files
cosmo0920edsiper
authored andcommitted
plugin: Detect config format and use a proper loader
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent b785118 commit c461f3e

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

src/flb_plugin.c

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -422,36 +422,41 @@ int flb_plugin_load_config_file(const char *file, struct flb_config *config)
422422
return -1;
423423
}
424424

425-
/*
426-
* pass to the config_format loader also in case some Yaml have been included in
427-
* the service section through the option 'plugins_file'
428-
*/
429-
ret = flb_plugin_load_config_format(cf, config);
430-
if (ret == -1) {
431-
return -1;
432-
}
433-
434-
/* (classic mode) read all 'plugins' sections */
435-
mk_list_foreach(head, &cf->sections) {
436-
section = mk_list_entry(head, struct flb_cf_section, _head);
437-
if (strcasecmp(section->name, "plugins") != 0) {
438-
continue;
439-
}
440-
441-
cfl_list_foreach(head_e, &section->properties->list) {
442-
entry = cfl_list_entry(head_e, struct cfl_kvpair, _head);
443-
if (strcasecmp(entry->key, "path") != 0) {
425+
if (cf->format == FLB_CF_FLUENTBIT) {
426+
/* (classic mode) read all 'plugins' sections */
427+
mk_list_foreach(head, &cf->sections) {
428+
section = mk_list_entry(head, struct flb_cf_section, _head);
429+
if (strcasecmp(section->name, "plugins") != 0) {
444430
continue;
445431
}
446432

447-
/* Load plugin with router function */
448-
ret = flb_plugin_load_router(entry->val->data.as_string, config);
449-
if (ret == -1) {
450-
flb_cf_destroy(cf);
451-
return -1;
433+
cfl_list_foreach(head_e, &section->properties->list) {
434+
entry = cfl_list_entry(head_e, struct cfl_kvpair, _head);
435+
if (strcasecmp(entry->key, "path") != 0) {
436+
continue;
437+
}
438+
439+
/* Load plugin with router function */
440+
ret = flb_plugin_load_router(entry->val->data.as_string, config);
441+
if (ret == -1) {
442+
flb_cf_destroy(cf);
443+
return -1;
444+
}
452445
}
453446
}
454447
}
448+
#ifdef FLB_HAVE_LIBYAML
449+
else if (cf->format == FLB_CF_YAML) {
450+
/*
451+
* pass to the config_format loader also in case some Yaml have been included in
452+
* the service section through the option 'plugins_file'
453+
*/
454+
ret = flb_plugin_load_config_format(cf, config);
455+
if (ret == -1) {
456+
return -1;
457+
}
458+
}
459+
#endif
455460

456461
flb_cf_destroy(cf);
457462
return 0;

0 commit comments

Comments
 (0)