diff --git a/apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-filter-recordTransformer.cfg b/apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-filter-recordTransformer.cfg
new file mode 100644
index 000000000..1dc6756a0
--- /dev/null
+++ b/apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-filter-recordTransformer.cfg
@@ -0,0 +1,35 @@
+
+
+ @id main
+ @type label_router
+
+ @label @a2170d34e9940ec56d328100e375c43e
+
+ namespaces default,kube-system
+
+
+
+
\ No newline at end of file
diff --git a/apis/fluentd/v1alpha1/tests/helper_test.go b/apis/fluentd/v1alpha1/tests/helper_test.go
index 22a8ad5a2..075e91440 100644
--- a/apis/fluentd/v1alpha1/tests/helper_test.go
+++ b/apis/fluentd/v1alpha1/tests/helper_test.go
@@ -607,3 +607,30 @@ func Test_DuplicateRemovalCRSpecs(t *testing.T) {
i++
}
}
+
+func Test_RecordTransformer(t *testing.T) {
+ g := NewGomegaWithT(t)
+ sl := plugins.NewSecretLoader(nil, Fluentd.Namespace, logr.Logger{})
+
+ psr := fluentdv1alpha1.NewGlobalPluginResources("main")
+ psr.CombineGlobalInputsPlugins(sl, Fluentd.Spec.GlobalInputs)
+
+ clustercfgRouter, err := psr.BuildCfgRouter(&FluentdClusterFluentdConfig1)
+ g.Expect(err).NotTo(HaveOccurred())
+ clusterFilters := []fluentdv1alpha1.ClusterFilter{FluentdClusterRecordTransformerFilter}
+ clusterOutputs := []fluentdv1alpha1.ClusterOutput{FluentdClusterOutputCluster}
+ clustercfgResources, _ := psr.PatchAndFilterClusterLevelResources(sl, FluentdClusterFluentdConfig1.GetCfgId(), clusterFilters, clusterOutputs)
+ err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
+ g.Expect(err).NotTo(HaveOccurred())
+
+ // we should not see any permutations in serialized config
+ i := 0
+ for i < maxRuntimes {
+ config, errs := psr.RenderMainConfig(false)
+ // fmt.Println(config)
+ g.Expect(errs).NotTo(HaveOccurred())
+ g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-filter-recordTransformer.cfg"))).To(Equal(config))
+
+ i++
+ }
+}
diff --git a/apis/fluentd/v1alpha1/tests/tools.go b/apis/fluentd/v1alpha1/tests/tools.go
index b053c3e1e..22883582a 100644
--- a/apis/fluentd/v1alpha1/tests/tools.go
+++ b/apis/fluentd/v1alpha1/tests/tools.go
@@ -199,6 +199,25 @@ spec:
value: ${record["kubernetes"]["namespace_name"]}
`
+ FluentdClusterRecordTransformerFilter fluentdv1alpha1.ClusterFilter
+ FluentdClusterRecordTransformerRaw = `
+apiVersion: fluentd.fluent.io/v1alpha1
+kind: ClusterFilter
+metadata:
+ name: fluentd-filter
+ labels:
+ filter.fluentd.fluent.io/enabled: "true"
+spec:
+ filters:
+ - recordTransformer:
+ enableRuby: true
+ autoTypeCast: true
+ renewRecord: true
+ records:
+ - key: kubernetes_ns
+ value: ${record["kubernetes"]["namespace_name"]}
+`
+
FluentdClusterOutputBuffer fluentdv1alpha1.ClusterOutput
FluentdClusterOutputBufferRaw = `
apiVersion: fluentd.fluent.io/v1alpha1
@@ -562,6 +581,7 @@ func init() {
ParseIntoObject(FluentdConfigUser1Raw, &FluentdConfigUser1)
ParseIntoObject(FluentdConfig1Raw, &FluentdConfig1)
ParseIntoObject(FluentdClusterFilter1Raw, &FluentdClusterFilter1)
+ ParseIntoObject(FluentdClusterRecordTransformerRaw, &FluentdClusterRecordTransformerFilter)
ParseIntoObject(FluentdClusterOutputClusterRaw, &FluentdClusterOutputCluster)
ParseIntoObject(FluentdClusterOutputLogOperatorRaw, &FluentdClusterOutputLogOperator)
ParseIntoObject(FluentdClusterOutputBufferRaw, &FluentdClusterOutputBuffer)