From 58cb47dc2dffb3c8fe41f78735e210c3477ef6d0 Mon Sep 17 00:00:00 2001 From: 9547 Date: Wed, 23 Jun 2021 00:13:07 +0800 Subject: [PATCH] cluster/template: template Blackbox.tpl --- pkg/cluster/template/config/blackbox.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/template/config/blackbox.go b/pkg/cluster/template/config/blackbox.go index 4c9c53692e..3d5ed728d7 100644 --- a/pkg/cluster/template/config/blackbox.go +++ b/pkg/cluster/template/config/blackbox.go @@ -14,8 +14,10 @@ package config import ( + "bytes" "os" "path" + "text/template" "github.com/pingcap/tiup/embed" ) @@ -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 }