Skip to content

Commit

Permalink
feat(outputs.mqtt): Add sprig for MQTT topic name generator
Browse files Browse the repository at this point in the history
  • Loading branch information
diorcety committed Sep 27, 2024
1 parent 0febb7e commit 73a281e
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 @@ -5,6 +5,7 @@ import (
"strings"
"text/template"

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

Expand All @@ -17,7 +18,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 73a281e

Please sign in to comment.