From f4147e9e6c9658b0accc98cecf681f7ed0aed2c3 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Wed, 26 Apr 2017 23:34:36 -0300 Subject: [PATCH] Avoid running nginx if the configuration file is empty --- controllers/nginx/pkg/cmd/controller/nginx.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controllers/nginx/pkg/cmd/controller/nginx.go b/controllers/nginx/pkg/cmd/controller/nginx.go index d0a05ebbd..ca4f7e978 100644 --- a/controllers/nginx/pkg/cmd/controller/nginx.go +++ b/controllers/nginx/pkg/cmd/controller/nginx.go @@ -334,6 +334,9 @@ func (n NGINXController) DefaultIngressClass() string { // testTemplate checks if the NGINX configuration inside the byte array is valid // running the command "nginx -t" using a temporal file. func (n NGINXController) testTemplate(cfg []byte) error { + if len(cfg) == 0 { + return fmt.Errorf("invalid nginx configuration (empty)") + } tmpfile, err := ioutil.TempFile("", "nginx-cfg") if err != nil { return err