feat(outputs.mqtt): Add sprig functions for topic name generator (#15943)

This commit is contained in:
Diorcet Yann 2024-10-15 16:18:23 +02:00 committed by GitHub
parent 0b1581c0da
commit 809480ee59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import (
"strings"
"text/template"
"github.com/Masterminds/sprig/v3"
"github.com/influxdata/telegraf"
)
@ -17,7 +19,7 @@ type TopicNameGenerator struct {
}
func NewTopicNameGenerator(topicPrefix, topic string) (*TopicNameGenerator, error) {
tt, err := template.New("topic_name").Parse(topic)
tt, err := template.New("topic_name").Funcs(sprig.TxtFuncMap()).Parse(topic)
if err != nil {
return nil, err
}