From 46de4f55263ff0376d642beddd3b8e1065bc82ba Mon Sep 17 00:00:00 2001 From: urso Date: Thu, 4 Mar 2021 19:47:14 +0100 Subject: [PATCH] fix error if indexcomponent is not installed --- libbeat/template/load.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libbeat/template/load.go b/libbeat/template/load.go index f3eaf67f5f87..813b96346750 100644 --- a/libbeat/template/load.go +++ b/libbeat/template/load.go @@ -188,9 +188,6 @@ func (l *ESLoader) checkExistsTemplate(name string) (bool, error) { // Other status codes or IO errors during the request are reported as error. func (l *ESLoader) checkExistsComponentTemplate(name string) (bool, error) { status, _, err := l.client.Request("GET", "/_component_template/"+name, "", nil, nil) - if err != nil { - return false, err - } switch status { case http.StatusNotFound: @@ -198,7 +195,10 @@ func (l *ESLoader) checkExistsComponentTemplate(name string) (bool, error) { case http.StatusOK: return true, nil default: - return false, &StatusError{status: status} + if err == nil { + err = &StatusError{status: status} + } + return false, err } }