From bfaa4c96ce8a0215044257d4de6f6c8850e5e07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Parada?= Date: Thu, 10 Oct 2024 13:05:48 -0300 Subject: [PATCH] feat: add example with processors --- config_test.go | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/config_test.go b/config_test.go index c51dc57..a719bde 100644 --- a/config_test.go +++ b/config_test.go @@ -3,6 +3,7 @@ package fluentbitconfig import ( "bytes" "encoding/json" + "fmt" "os" "path/filepath" "strings" @@ -415,3 +416,51 @@ func TestConfig_Validate_JSON(t *testing.T) { }) } } + +func Example_configWithProcessors() { + conf := Config{ + Pipeline: Pipeline{ + Inputs: Plugins{ + Plugin{ + Properties: property.Properties{ + {Key: "name", Value: "dummy"}, + {Key: "processors", Value: property.Properties{ + {Key: "logs", Value: Plugins{ + Plugin{ + Properties: property.Properties{ + {Key: "name", Value: "calyptia"}, + {Key: "actions", Value: property.Properties{ + {Key: "type", Value: "block_keys"}, + {Key: "opts", Value: property.Properties{ + {Key: "regex", Value: "star"}, + {Key: "regexEngine", Value: "pcre2"}, + }}, + }}, + }, + }, + }}, + }}, + }, + }, + }, + }, + } + yaml, err := conf.DumpAsYAML() + if err != nil { + panic(err) + } + + fmt.Println(yaml) + // Output: + // pipeline: + // inputs: + // - name: dummy + // processors: + // logs: + // - name: calyptia + // actions: + // type: block_keys + // opts: + // regex: star + // regexEngine: pcre2 +}