Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out_oracle_log_analytics: minor fixes #7966

Merged
merged 5 commits into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions plugins/out_oracle_log_analytics/oci_logan_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ static int load_oci_credentials(struct flb_oci_logan *ctx)
goto iterate;
}
mk_mem_free(profile);
profile = NULL;
}
if(found_profile) {
if(line[0] == '[') {
Expand Down Expand Up @@ -209,6 +210,7 @@ static int global_metadata_fields_create(struct flb_oci_logan *ctx)
}
f->val = flb_sds_create(val->str);
if (!f->val) {
flb_sds_destroy(f->key);
flb_free(f);
return -1;
}
Expand Down Expand Up @@ -249,6 +251,7 @@ static int log_event_metadata_create(struct flb_oci_logan *ctx)
}
f->val = flb_sds_create(val->str);
if (!f->val) {
flb_sds_destroy(f->key);
flb_free(f);
return -1;
}
Expand Down Expand Up @@ -277,6 +280,8 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins,
flb_errno();
return NULL;
}
mk_list_init(&ctx->global_metadata_fields);
mk_list_init(&ctx->log_event_metadata_fields);

ctx->ins = ins;

Expand All @@ -290,15 +295,14 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins,
if (ctx->oci_config_in_record == FLB_FALSE) {
if (ctx->oci_la_log_source_name == NULL ||
ctx->oci_la_log_group_id == NULL) {
flb_errno();
flb_plg_error(ctx->ins,
"log source name and log group id are required");
flb_oci_logan_conf_destroy(ctx);
return NULL;
}
}

if (ctx->oci_la_global_metadata != NULL) {
mk_list_init(&ctx->global_metadata_fields);
ret = global_metadata_fields_create(ctx);
if (ret != 0) {
flb_errno();
Expand All @@ -308,7 +312,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins,
}

if (ctx->oci_la_metadata != NULL) {
mk_list_init(&ctx->log_event_metadata_fields);
ret = log_event_metadata_create(ctx);
if (ret != 0) {
flb_errno();
Expand All @@ -318,7 +321,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins,
}

if (!ctx->config_file_location) {
flb_errno();
flb_plg_error(ctx->ins, "config file location is required");
flb_oci_logan_conf_destroy(ctx);
return NULL;
Expand All @@ -336,7 +338,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins,
}
else {
if (!ctx->region) {
flb_errno();
flb_plg_error(ctx->ins, "Region is required");
flb_oci_logan_conf_destroy(ctx);
return NULL;
Expand All @@ -347,7 +348,6 @@ struct flb_oci_logan *flb_oci_logan_conf_create(struct flb_output_instance *ins,

if (!ctx->uri) {
if (!ctx->namespace) {
flb_errno();
flb_plg_error(ctx->ins, "Namespace is required");
flb_oci_logan_conf_destroy(ctx);
return NULL;
Expand Down Expand Up @@ -437,16 +437,24 @@ static void metadata_fields_destroy(struct flb_oci_logan *ctx)

mk_list_foreach_safe(head, tmp, &ctx->global_metadata_fields) {
f = mk_list_entry(head, struct metadata_obj, _head);
flb_sds_destroy(f->key);
flb_sds_destroy(f->val);
if (f->key) {
flb_sds_destroy(f->key);
}
if (f->val) {
flb_sds_destroy(f->val);
}
mk_list_del(&f->_head);
flb_free(f);
}

mk_list_foreach_safe(head, tmp, &ctx->log_event_metadata_fields) {
f = mk_list_entry(head, struct metadata_obj, _head);
flb_sds_destroy(f->key);
flb_sds_destroy(f->val);
if (f->key) {
flb_sds_destroy(f->key);
}
if (f->val) {
flb_sds_destroy(f->val);
}
mk_list_del(&f->_head);
flb_free(f);
}
Expand Down Expand Up @@ -490,4 +498,4 @@ int flb_oci_logan_conf_destroy(struct flb_oci_logan *ctx) {

flb_free(ctx);
return 0;
}
}
Loading