feat(outputs.mqtt): Add sprig functions for topic name generator (#15943)
This commit is contained in:
parent
0b1581c0da
commit
809480ee59
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue