From 06613d3c6bbe634bfaf0258bcdf7e99c3ae6cc5b Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Thu, 3 Aug 2023 14:13:17 +0200 Subject: [PATCH] fix: variable shadowing --- services/policies/pkg/engine/opa/engine.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/policies/pkg/engine/opa/engine.go b/services/policies/pkg/engine/opa/engine.go index b4107ba1840..21c07cdb4aa 100644 --- a/services/policies/pkg/engine/opa/engine.go +++ b/services/policies/pkg/engine/opa/engine.go @@ -24,13 +24,15 @@ type OPA struct { // NewOPA returns a ready to use opa engine. func NewOPA(timeout time.Duration, logger log.Logger, conf config.Engine) (OPA, error) { - var mtReader io.Reader + var mtReader io.ReadCloser if conf.Mimes != "" { - mtReader, err := os.Open(conf.Mimes) + var err error + mtReader, err = os.Open(conf.Mimes) if err != nil { return OPA{}, err } + defer mtReader.Close() }