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

config_format: yaml: windows: Handle directory separator for include directive on yaml config correctly on windows #8311

Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/config_format/flb_cf_yaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1934,10 +1934,16 @@ static int read_config(struct flb_cf *conf, struct local_ctx *ctx,
return -1;
}

if (flb_sds_printf(&include_dir, "%s/%s", parent->path, cfg_file) == NULL) {
#ifdef _WIN32
#define PATH_CONCAT_TEMPLATE "%s\\%s"
#else
#define PATH_CONCAT_TEMPLATE "%s/%s"
#endif
if (flb_sds_printf(&include_dir, PATH_CONCAT_TEMPLATE, parent->path, cfg_file) == NULL) {
flb_error("unable to create full filename");
return -1;
}
#undef PATH_CONCAT_TEMPLATE

}
else {
Expand Down
14 changes: 13 additions & 1 deletion tests/internal/config_format_yaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@

#include "flb_tests_internal.h"

#ifdef _WIN32
#define FLB_TESTS_CONF_PATH FLB_TESTS_DATA_PATH "\\data\\config_format\\yaml"
#else
#define FLB_TESTS_CONF_PATH FLB_TESTS_DATA_PATH "/data/config_format/yaml"
#endif

#define FLB_000 FLB_TESTS_CONF_PATH "/fluent-bit.yaml"
#define FLB_001 FLB_TESTS_CONF_PATH "/issue_7559.yaml"
#define FLB_002 FLB_TESTS_CONF_PATH "/processors.yaml"
#define FLB_000_WIN FLB_TESTS_CONF_PATH "\\fluent-bit-windows.yaml"

#ifdef _WIN32
#define FLB_BASIC FLB_000_WIN
#else
#define FLB_BASIC FLB_000
#endif

/*
* Configurations to test:
Expand All @@ -39,7 +51,7 @@ static void test_basic()
struct cfl_variant *v;
int idx = 0;

cf = flb_cf_yaml_create(NULL, FLB_000, NULL, 0);
cf = flb_cf_yaml_create(NULL, FLB_BASIC, NULL, 0);
TEST_CHECK(cf != NULL);
if (!cf) {
exit(EXIT_FAILURE);
Expand Down
29 changes: 29 additions & 0 deletions tests/internal/data/config_format/yaml/fluent-bit-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
env:
flush_interval: 1

includes:
- service-windows.yaml

customs:
- name: ${observability}
api_key: zyJUb2tlbklEItoiY2ZlMTcx

pipeline:
inputs:
- name: tail
path: ./test.log
parser: json
read_from_head: true
- name: tail
path: ./test.log
parser: json
read_from_head: true

filters:
- name: record_modifier
match: "*"
record: powered_by calyptia

outputs:
- name: stdout
match: "*"
5 changes: 5 additions & 0 deletions tests/internal/data/config_format/yaml/service-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
env:
observability: calyptia

includes:
- test\nested.yaml
Loading