Merge pull request #295 from tangle329/master
We need check content, when cmd failed.
This commit is contained in:
commit
964aa0a15a
3 changed files with 15 additions and 12 deletions
|
|
@ -78,7 +78,7 @@ func (t *Template) Close() {
|
|||
|
||||
// Write populates a buffer using a template with NGINX configuration
|
||||
// and the servers and upstreams created by Ingress rules
|
||||
func (t *Template) Write(conf config.TemplateConfig, isValidTemplate func([]byte) error) ([]byte, error) {
|
||||
func (t *Template) Write(conf config.TemplateConfig) ([]byte, error) {
|
||||
defer t.tmplBuf.Reset()
|
||||
defer t.outCmdBuf.Reset()
|
||||
|
||||
|
|
@ -114,13 +114,7 @@ func (t *Template) Write(conf config.TemplateConfig, isValidTemplate func([]byte
|
|||
return t.tmplBuf.Bytes(), nil
|
||||
}
|
||||
|
||||
content := t.outCmdBuf.Bytes()
|
||||
err = isValidTemplate(content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return content, nil
|
||||
return t.outCmdBuf.Bytes(), nil
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func TestTemplateWithData(t *testing.T) {
|
|||
t.Errorf("invalid NGINX template: %v", err)
|
||||
}
|
||||
|
||||
_, err = ngxTpl.Write(dat, func(b []byte) error { return nil })
|
||||
_, err = ngxTpl.Write(dat)
|
||||
if err != nil {
|
||||
t.Errorf("invalid NGINX template: %v", err)
|
||||
}
|
||||
|
|
@ -166,6 +166,6 @@ func BenchmarkTemplateWithData(b *testing.B) {
|
|||
}
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
ngxTpl.Write(dat, func(b []byte) error { return nil })
|
||||
ngxTpl.Write(dat)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue