Skip to content

Commit

Permalink
feat(outputs.mqtt): Add sprig functions for topic name generator (#15943
Browse files Browse the repository at this point in the history
)
  • Loading branch information
diorcety authored Oct 15, 2024
1 parent 0b1581c commit 809480e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/outputs/mqtt/topic_name_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"strings"
"text/template"

"github.com/Masterminds/sprig/v3"

"github.com/influxdata/telegraf"
)

Expand All @@ -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
}
Expand Down

0 comments on commit 809480e

Please sign in to comment.