From 197e9252e6a085414f66ac49d889ec635f2cf422 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 21 Dec 2023 12:33:16 +0900 Subject: [PATCH 1/2] config_format: yaml: Use \ instead of / for concatenating paths on Windows Signed-off-by: Hiroshi Hatake --- src/config_format/flb_cf_yaml.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config_format/flb_cf_yaml.c b/src/config_format/flb_cf_yaml.c index e3c84873230..04943da2caf 100644 --- a/src/config_format/flb_cf_yaml.c +++ b/src/config_format/flb_cf_yaml.c @@ -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 { From beea5911b8c1bbd137476b36259151a3ce2a7bae Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 21 Dec 2023 13:34:17 +0900 Subject: [PATCH 2/2] config_format: yaml: test: Make runnable for yaml config on Windows Signed-off-by: Hiroshi Hatake --- tests/internal/config_format_yaml.c | 14 ++++++++- .../yaml/fluent-bit-windows.yaml | 29 +++++++++++++++++++ .../config_format/yaml/service-windows.yaml | 5 ++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/internal/data/config_format/yaml/fluent-bit-windows.yaml create mode 100644 tests/internal/data/config_format/yaml/service-windows.yaml diff --git a/tests/internal/config_format_yaml.c b/tests/internal/config_format_yaml.c index b4da4d14bef..6f1fc488a6a 100644 --- a/tests/internal/config_format_yaml.c +++ b/tests/internal/config_format_yaml.c @@ -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: @@ -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); diff --git a/tests/internal/data/config_format/yaml/fluent-bit-windows.yaml b/tests/internal/data/config_format/yaml/fluent-bit-windows.yaml new file mode 100644 index 00000000000..41f204fb005 --- /dev/null +++ b/tests/internal/data/config_format/yaml/fluent-bit-windows.yaml @@ -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: "*" diff --git a/tests/internal/data/config_format/yaml/service-windows.yaml b/tests/internal/data/config_format/yaml/service-windows.yaml new file mode 100644 index 00000000000..fd8602ef9fe --- /dev/null +++ b/tests/internal/data/config_format/yaml/service-windows.yaml @@ -0,0 +1,5 @@ +env: + observability: calyptia + +includes: + - test\nested.yaml