Avoid running nginx if the configuration file is empty

This commit is contained in:
Manuel de Brito Fontes 2017-04-26 23:34:36 -03:00
parent 7eee34f473
commit f4147e9e6c

View file

@ -334,6 +334,9 @@ func (n NGINXController) DefaultIngressClass() string {
// testTemplate checks if the NGINX configuration inside the byte array is valid // testTemplate checks if the NGINX configuration inside the byte array is valid
// running the command "nginx -t" using a temporal file. // running the command "nginx -t" using a temporal file.
func (n NGINXController) testTemplate(cfg []byte) error { func (n NGINXController) testTemplate(cfg []byte) error {
if len(cfg) == 0 {
return fmt.Errorf("invalid nginx configuration (empty)")
}
tmpfile, err := ioutil.TempFile("", "nginx-cfg") tmpfile, err := ioutil.TempFile("", "nginx-cfg")
if err != nil { if err != nil {
return err return err