Skip to content

Commit 89c46e0

Browse files
committed
in_calyptia_fleet: backport support for net.* properties for the upstream connection
Signed-off-by: Matt Yates <[email protected]>
1 parent dbce361 commit 89c46e0

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

plugins/custom_calyptia/calyptia.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ flb_sds_t custom_calyptia_pipeline_config_get(struct flb_config *ctx)
215215

216216
int set_fleet_input_properties(struct calyptia *ctx, struct flb_input_instance *fleet)
217217
{
218+
struct mk_list *head;
219+
struct mk_list *tmp;
220+
struct flb_kv *keyval;
221+
218222
if (!fleet) {
219223
flb_plg_error(ctx->ins, "invalid fleet input instance");
220224
return -1;
@@ -255,6 +259,12 @@ int set_fleet_input_properties(struct calyptia *ctx, struct flb_input_instance *
255259
flb_input_set_property(fleet, "interval_nsec", ctx->fleet_interval_nsec);
256260
}
257261

262+
mk_list_foreach(head, &ctx->ins->net_properties) {
263+
keyval = mk_list_entry(head, struct flb_kv, _head);
264+
flb_debug("set fleet net property: %s=%s", keyval->key, keyval->val);
265+
flb_input_set_property(fleet, keyval->key, keyval->val);
266+
}
267+
258268
return 0;
259269
}
260270

@@ -267,6 +277,8 @@ static struct flb_output_instance *setup_cloud_output(struct flb_config *config,
267277
struct flb_slist_entry *val = NULL;
268278
flb_sds_t label;
269279
struct flb_config_map_val *mv;
280+
struct mk_list *tmp;
281+
struct flb_kv *keyval;
270282

271283
cloud = flb_output_new(config, "calyptia", ctx, FLB_FALSE);
272284

@@ -354,6 +366,12 @@ static struct flb_output_instance *setup_cloud_output(struct flb_config *config,
354366
flb_sds_destroy(label);
355367
}
356368

369+
mk_list_foreach(head, &ctx->ins->net_properties) {
370+
keyval = mk_list_entry(head, struct flb_kv, _head);
371+
flb_debug("set cloud net property: %s=%s", keyval->key, keyval->val);
372+
flb_output_set_property(cloud, keyval->key, keyval->val);
373+
}
374+
357375
#ifdef FLB_HAVE_CHUNK_TRACE
358376
flb_output_set_property(cloud, "pipeline_id", ctx->pipeline_id);
359377
#endif /* FLB_HAVE_CHUNK_TRACE */
@@ -727,6 +745,7 @@ static struct flb_config_map config_map[] = {
727745
FLB_CONFIG_MAP_MULT, FLB_TRUE, offsetof(struct calyptia, add_labels),
728746
"Label to append to the generated metric."
729747
},
748+
730749
{
731750
FLB_CONFIG_MAP_STR, "machine_id", NULL,
732751
0, FLB_TRUE, offsetof(struct calyptia, machine_id),
@@ -790,4 +809,5 @@ struct flb_custom_plugin custom_calyptia_plugin = {
790809
.config_map = config_map,
791810
.cb_init = cb_calyptia_init,
792811
.cb_exit = cb_calyptia_exit,
812+
.flags = FLB_CUSTOM_NET_CLIENT,
793813
};

plugins/in_calyptia_fleet/in_calyptia_fleet.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,6 +1869,7 @@ flb_sds_t fleet_config_get(struct flb_in_calyptia_fleet_config *ctx)
18691869
}
18701870

18711871
fleet_config_get_properties(&buf, &c_ins->properties, ctx->fleet_config_legacy_format);
1872+
fleet_config_get_properties(&buf, &c_ins->net_properties, ctx->fleet_config_legacy_format);
18721873

18731874
if (flb_config_prop_get("fleet_id", &c_ins->properties) == NULL) {
18741875
if (ctx->fleet_id != NULL) {
@@ -2529,6 +2530,9 @@ static int in_calyptia_fleet_init(struct flb_input_instance *in,
25292530
return -1;
25302531
}
25312532

2533+
/* set upstream settings from 'net.*' */
2534+
flb_input_upstream_set(ctx->u, ctx->ins);
2535+
25322536
/* Log initial interval values */
25332537
flb_plg_debug(ctx->ins, "initial collector interval: sec=%d nsec=%d",
25342538
ctx->interval_sec, ctx->interval_nsec);

tests/runtime/custom_calyptia_input_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ static struct test_context *init_test_context()
5858
return NULL;
5959
}
6060

61+
mk_list_init(&t_ctx->ctx->ins->net_properties);
62+
6163
/* Initialize test values in ctx */
6264
t_ctx->ctx->api_key = flb_strdup("test_api_key");
6365
t_ctx->ctx->fleet_config_dir = flb_strdup("/test/config/dir");

0 commit comments

Comments
 (0)