From 7eff97a86466b39849838ee20069eefa79e36ef0 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 18 May 2021 15:53:47 +0000 Subject: [PATCH] Check error return from adding shutdown function --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 5275ed1..33d4dd2 100644 --- a/main.go +++ b/main.go @@ -156,10 +156,13 @@ func main() { // +kubebuilder:scaffold:builder // Close capture file when program shuts down - mgr.Add(manager.RunnableFunc(func(stop <-chan struct{}) error { + if err := mgr.Add(manager.RunnableFunc(func(stop <-chan struct{}) error { <-stop return capture.Close() - })) + })); err != nil { + setupLog.Error(err, "unable to add close function") + os.Exit(1) + } setupLog.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {