Skip to content

Commit

Permalink
feat(outputs.mqtt): Add sprig functions for topic name generator (inf…
Browse files Browse the repository at this point in the history
  • Loading branch information
diorcety authored and asaharn committed Oct 16, 2024
1 parent 570219e commit d9f10b4
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 d9f10b4

Please sign in to comment.