Skip to content

Commit fe2a683

Browse files
committed
config: Add a validation function for service parameters
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 6315162 commit fe2a683

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

include/fluent-bit/flb_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ struct flb_config {
369369
struct flb_config *flb_config_init();
370370
void flb_config_exit(struct flb_config *config);
371371
const char *flb_config_prop_get(const char *key, struct mk_list *list);
372+
int flb_config_service_property_is_valid(const char *k);
372373
int flb_config_set_property(struct flb_config *config,
373374
const char *k, const char *v);
374375
int flb_config_set_program_name(struct flb_config *config, char *name);

src/flb_config.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,26 @@ int set_log_level_from_env(struct flb_config *config)
830830
return -1;
831831
}
832832

833+
int flb_config_service_property_is_valid(const char *k)
834+
{
835+
int i = 0;
836+
size_t len;
837+
char *key;
838+
839+
len = strnlen(k, 256);
840+
key = service_configs[0].key;
841+
842+
while (key != NULL) {
843+
if (prop_key_check(key, k, len) == 0) {
844+
return FLB_TRUE;
845+
}
846+
847+
key = service_configs[++i].key;
848+
}
849+
850+
return FLB_FALSE;
851+
}
852+
833853
int flb_config_set_property(struct flb_config *config,
834854
const char *k, const char *v)
835855
{
@@ -918,6 +938,8 @@ int flb_config_set_property(struct flb_config *config,
918938
}
919939
key = service_configs[++i].key;
920940
}
941+
942+
flb_warn("[config] unknown service property '%s', it has been ignored", k);
921943
return 0;
922944
}
923945

@@ -1536,6 +1558,12 @@ int flb_config_load_config_format(struct flb_config *config, struct flb_cf *cf)
15361558
/* Yaml allow parsers definitions in any Yaml file, all good */
15371559
}
15381560
}
1561+
1562+
if (s->type == FLB_CF_OTHER &&
1563+
strcasecmp(s->name, "processor") != 0) {
1564+
flb_warn("[config] unknown configuration section '%s', it has been ignored",
1565+
s->name);
1566+
}
15391567
}
15401568

15411569
/* Read main 'service' section */

0 commit comments

Comments
 (0)