From 5169954be82fabcfb6f7c0a01f4803c81cb65c67 Mon Sep 17 00:00:00 2001 From: Martin Maly Date: Tue, 8 Feb 2022 14:27:11 -0800 Subject: [PATCH] Add Missing file.Close() calls (#2761) Calls to close files were missing in a couple of places --- internal/fnruntime/runner.go | 1 + pkg/api/kptfile/v1/validation.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/fnruntime/runner.go b/internal/fnruntime/runner.go index 051a533032..eeb839a6db 100644 --- a/internal/fnruntime/runner.go +++ b/internal/fnruntime/runner.go @@ -470,6 +470,7 @@ func newFnConfig(f *kptfilev1.Function, pkgPath types.UniquePath) (*yaml.RNode, return nil, errors.E(op, fn, fmt.Errorf("missing function config %q", f.ConfigPath)) } + defer file.Close() b, err := ioutil.ReadAll(file) if err != nil { return nil, errors.E(op, fn, err) diff --git a/pkg/api/kptfile/v1/validation.go b/pkg/api/kptfile/v1/validation.go index 6489afd7f3..7b1be7c6ef 100644 --- a/pkg/api/kptfile/v1/validation.go +++ b/pkg/api/kptfile/v1/validation.go @@ -177,6 +177,7 @@ func GetValidatedFnConfigFromPath(pkgPath types.UniquePath, configPath string) ( if err != nil { return nil, fmt.Errorf("functionConfig must exist in the current package") } + defer file.Close() reader := kio.ByteReader{Reader: file, PreserveSeqIndent: true, WrapBareSeqNode: true, DisableUnwrapping: true} nodes, err := reader.Read() if err != nil {