Skip to content

Commit

Permalink
cluster/template: template Blackbox.tpl
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvisa committed Jun 23, 2021
1 parent 27facad commit 58cb47d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/cluster/template/config/blackbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
package config

import (
"bytes"
"os"
"path"
"text/template"

"github.com/pingcap/tiup/embed"
)
Expand Down Expand Up @@ -55,5 +57,15 @@ func (c *BlackboxConfig) ConfigToFile(file string) error {

// ConfigWithTemplate generate the AlertManager config content by tpl
func (c *BlackboxConfig) ConfigWithTemplate(tpl string) ([]byte, error) {
return []byte(tpl), nil
tmpl, err := template.New("Blackbox").Parse(tpl)
if err != nil {
return nil, err
}

content := bytes.NewBufferString("")
if err := tmpl.Execute(content, c); err != nil {
return nil, err
}

return content.Bytes(), nil
}

0 comments on commit 58cb47d

Please sign in to comment.