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 22, 2021
1 parent a26c0d2 commit 47b8c7c
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 47b8c7c

Please sign in to comment.