Skip to content

Commit

Permalink
in_calyptia_fleet: persist machine_id setting.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan committed Aug 22, 2023
1 parent 57008dd commit 86f68d9
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions plugins/in_calyptia_fleet/in_calyptia_fleet.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
flb_sds_t cfgoldname;
flb_sds_t cfgcurname;
flb_sds_t header;
flb_sds_t hdr;
FILE *cfgfp;
const char *fbit_last_modified;
int fbit_last_modified_len;
Expand Down Expand Up @@ -691,16 +692,16 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
}
header = flb_sds_create_size(4096);
if (ctx->fleet_name == NULL) {
flb_sds_printf(&header,
hdr = flb_sds_printf(&header,
"[CUSTOM]\n"
" Name calyptia\n"
" api_key %s\n"
" fleet_id %s\n"
" add_label fleet_id %s\n"
" fleet.config_dir %s\n"
" calyptia_host %s\n"
" calyptia_port %d\n"
" calyptia_tls %s\n",
" Name calyptia\n"
" api_key %s\n"
" fleet_id %s\n"
" add_label fleet_id %s\n"
" fleet.config_dir %s\n"
" calyptia_host %s\n"
" calyptia_port %d\n"
" calyptia_tls %s\n",
ctx->api_key,
ctx->fleet_id,
ctx->fleet_id,
Expand All @@ -710,7 +711,7 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
tls_setting_string(ctx->ins->use_tls)
);
} else {
flb_sds_printf(&header,
hdr = flb_sds_printf(&header,
"[CUSTOM]\n"
" Name calyptia\n"
" api_key %s\n"
Expand All @@ -731,6 +732,17 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
tls_setting_string(ctx->ins->use_tls)
);
}
if (hdr == NULL) {
fclose(cfgfp);
goto http_error;
}
if (ctx->machine_id) {
hdr = flb_sds_printf(&header, " machine_id %s\n", ctx->machine_id);
if (hdr == NULL) {
fclose(cfgfp);
goto http_error;
}
}
fwrite(header, strlen(header), 1, cfgfp);
flb_sds_destroy(header);
fwrite(data, client->resp.payload_size, 1, cfgfp);
Expand Down

0 comments on commit 86f68d9

Please sign in to comment.