Skip to content

Commit

Permalink
upstream_ht: added environment variable support
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <[email protected]>
  • Loading branch information
leonardo-albertovich committed Aug 21, 2024
1 parent 4ac5b7b commit b17d357
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/flb_upstream_ha.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <fluent-bit/flb_upstream_node.h>
#include <fluent-bit/flb_config_format.h>
#include <fluent-bit/flb_kv.h>
#include <fluent-bit/flb_env.h>

#include <ctype.h>
#include <sys/types.h>
Expand Down Expand Up @@ -108,6 +109,20 @@ struct flb_upstream_node *flb_upstream_ha_node_get(struct flb_upstream_ha *ctx)
return node;
}

static inline void translate_environment_variables(flb_sds_t *value, struct
flb_config *config)
{
flb_sds_t result;

result = flb_env_var_translate(config->env, *value);

if (result != NULL) {
flb_sds_destroy(*value);

*value = (flb_sds_t) result;
}
}

static struct flb_upstream_node *create_node(int id,
struct flb_cf *cf,
struct flb_cf_section *s,
Expand Down Expand Up @@ -214,6 +229,16 @@ static struct flb_upstream_node *create_node(int id,
/* tls.key_file */
tls_key_passwd = flb_cf_section_property_get_string(cf, s, "tls.key_passwd");

translate_environment_variables((flb_sds_t *) &name, config);
translate_environment_variables((flb_sds_t *) &host, config);
translate_environment_variables((flb_sds_t *) &port, config);
translate_environment_variables((flb_sds_t *) &tls_vhost, config);
translate_environment_variables((flb_sds_t *) &tls_ca_path, config);
translate_environment_variables((flb_sds_t *) &tls_ca_file, config);
translate_environment_variables((flb_sds_t *) &tls_crt_file, config);
translate_environment_variables((flb_sds_t *) &tls_key_file, config);
translate_environment_variables((flb_sds_t *) &tls_key_passwd, config);

/*
* Create hash table to store unknown key/values that might be used
* by the caller plugin.
Expand Down

0 comments on commit b17d357

Please sign in to comment.