Skip to content

Commit

Permalink
Add sprig for MQTT topic name generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann Diorcet committed Sep 27, 2024
1 parent dea972a commit 9974cbd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/outputs/mqtt/topic_name_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"text/template"

"github.com/influxdata/telegraf"
"github.com/Masterminds/sprig/v3"
)

type TopicNameGenerator struct {
Expand All @@ -17,7 +18,7 @@ type TopicNameGenerator struct {
}

func NewTopicNameGenerator(topicPrefix string, 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 9974cbd

Please sign in to comment.