Skip to content

Commit

Permalink
let RewriteTag filter fullfill namespaceable interface
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Freitag <[email protected]>
  • Loading branch information
MarkusFreitag committed Apr 22, 2024
1 parent ae9a676 commit 4d00ba3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion apis/fluentbit/v1alpha2/plugins/filter/rewritetag_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package filter

import (
"crypto/md5"
"fmt"
"strings"

"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins"
"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins/params"
)
Expand All @@ -18,7 +22,7 @@ type RewriteTag struct {
// When the filter emits a record under the new Tag, there is an internal emitter
// plugin that takes care of the job. Since this emitter expose metrics as any other
// component of the pipeline, you can use this property to configure an optional name for it.
EmitterName string `json:"emitterName,omitempty"`
EmitterName string `json:"emitterName,omitempty"`
EmitterMemBufLimit string `json:"emitterMemBufLimit,omitempty"`
EmitterStorageType string `json:"emitterStorageType,omitempty"`
}
Expand Down Expand Up @@ -47,3 +51,11 @@ func (r *RewriteTag) Params(_ plugins.SecretLoader) (*params.KVs, error) {
}
return kvs, nil
}

func (r *RewriteTag) MakeNamespaced(ns string) {
for idx, rule := range r.Rules {
parts := strings.Fields(rule)
parts[2] = fmt.Sprintf("%x.%s", md5.Sum([]byte(ns)), parts[2])
r.Rules[idx] = strings.Join(parts, " ")
}
}

0 comments on commit 4d00ba3

Please sign in to comment.