Skip to content

Commit b266d46

Browse files
author
Pat
authored
core: fix up boolean conversion logic (#7618)
* core: fix up boolean conversion logic Signed-off-by: Patrick Stephens <[email protected]>
1 parent bbc520a commit b266d46

File tree

3 files changed

+14
-37
lines changed

3 files changed

+14
-37
lines changed

plugins/out_cloudwatch_logs/cloudwatch_logs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,8 @@ static int cb_cloudwatch_init(struct flb_output_instance *ins,
185185

186186
ctx->create_group = FLB_FALSE;
187187
tmp = flb_output_get_property("auto_create_group", ins);
188-
/* native plugins use On/Off as bool, the old Go plugin used true/false */
189-
if (tmp && (strcasecmp(tmp, "On") == 0 || strcasecmp(tmp, "true") == 0)) {
190-
ctx->create_group = FLB_TRUE;
188+
if (tmp) {
189+
ctx->create_group = flb_utils_bool(tmp);
191190
}
192191

193192
ctx->retry_requests = FLB_TRUE;

src/flb_input.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -541,27 +541,16 @@ int flb_input_set_property(struct flb_input_instance *ins,
541541

542542
#ifdef FLB_HAVE_TLS
543543
else if (prop_key_check("tls", k, len) == 0 && tmp) {
544-
if (strcasecmp(tmp, "true") == 0 || strcasecmp(tmp, "on") == 0) {
545-
if ((ins->flags & FLB_IO_TLS) == 0) {
546-
flb_error("[config] %s don't support TLS", ins->name);
547-
flb_sds_destroy(tmp);
548-
return -1;
549-
}
550-
551-
ins->use_tls = FLB_TRUE;
552-
}
553-
else {
554-
ins->use_tls = FLB_FALSE;
544+
ins->use_tls = flb_utils_bool(tmp);
545+
if (ins->use_tls == FLB_TRUE && ((ins->flags & FLB_IO_TLS) == 0)) {
546+
flb_error("[config] %s does not support TLS", ins->name);
547+
flb_sds_destroy(tmp);
548+
return -1;
555549
}
556550
flb_sds_destroy(tmp);
557551
}
558552
else if (prop_key_check("tls.verify", k, len) == 0 && tmp) {
559-
if (strcasecmp(tmp, "true") == 0 || strcasecmp(tmp, "on") == 0) {
560-
ins->tls_verify = FLB_TRUE;
561-
}
562-
else {
563-
ins->tls_verify = FLB_FALSE;
564-
}
553+
ins->tls_verify = flb_utils_bool(tmp);
565554
flb_sds_destroy(tmp);
566555
}
567556
else if (prop_key_check("tls.debug", k, len) == 0 && tmp) {

src/flb_output.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -860,27 +860,16 @@ int flb_output_set_property(struct flb_output_instance *ins,
860860
#endif
861861
#ifdef FLB_HAVE_TLS
862862
else if (prop_key_check("tls", k, len) == 0 && tmp) {
863-
if (strcasecmp(tmp, "true") == 0 || strcasecmp(tmp, "on") == 0) {
864-
if ((ins->flags & FLB_IO_TLS) == 0) {
865-
flb_error("[config] %s don't support TLS", ins->name);
866-
flb_sds_destroy(tmp);
867-
return -1;
868-
}
869-
870-
ins->use_tls = FLB_TRUE;
871-
}
872-
else {
873-
ins->use_tls = FLB_FALSE;
863+
ins->use_tls = flb_utils_bool(tmp);
864+
if (ins->use_tls == FLB_TRUE && ((ins->flags & FLB_IO_TLS) == 0)) {
865+
flb_error("[config] %s does not support TLS", ins->name);
866+
flb_sds_destroy(tmp);
867+
return -1;
874868
}
875869
flb_sds_destroy(tmp);
876870
}
877871
else if (prop_key_check("tls.verify", k, len) == 0 && tmp) {
878-
if (strcasecmp(tmp, "true") == 0 || strcasecmp(tmp, "on") == 0) {
879-
ins->tls_verify = FLB_TRUE;
880-
}
881-
else {
882-
ins->tls_verify = FLB_FALSE;
883-
}
872+
ins->tls_verify = flb_utils_bool(tmp);
884873
flb_sds_destroy(tmp);
885874
}
886875
else if (prop_key_check("tls.debug", k, len) == 0 && tmp) {

0 commit comments

Comments
 (0)