From ee8966344d368f1f49c9fb4bd2999e4a823cc80d Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Mon, 8 Aug 2022 15:09:52 +0300 Subject: [PATCH] Replace with anonymoud functions (#53386) --- pkg/build/plugins/manifest.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/build/plugins/manifest.go b/pkg/build/plugins/manifest.go index 1166a0d41f6..037bb176a2c 100644 --- a/pkg/build/plugins/manifest.go +++ b/pkg/build/plugins/manifest.go @@ -99,7 +99,11 @@ func BuildManifest(ctx context.Context, dpath string, signingAdmin bool) error { if err != nil { return fmt.Errorf("failed to get signed manifest from Grafana API: %w", err) } - defer logError(resp.Body.Close()) + defer func() { + if err := resp.Body.Close(); err != nil { + log.Println("failed to close response body, err: %w", err) + } + }() if resp.StatusCode != 200 { msg, err := ioutil.ReadAll(resp.Body) if err != nil { @@ -114,7 +118,11 @@ func BuildManifest(ctx context.Context, dpath string, signingAdmin bool) error { if err != nil { return fmt.Errorf("failed to create %s: %w", manifestPath, err) } - defer logCloseError(f.Close) + defer func() { + if err := f.Close(); err != nil { + log.Println("failed to close file, err: %w", err) + } + }() if _, err := io.Copy(f, resp.Body); err != nil { return fmt.Errorf("failed to write %s: %w", manifestPath, err) }