From 3f56eba6dcf49ede50ff2b8cc076c02e5185be05 Mon Sep 17 00:00:00 2001 From: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:42:12 +0000 Subject: [PATCH] Fix: Prevent nil errors in setupLog.Error to ensure proper logging Closes; https://github.com/operator-framework/operator-controller/issues/1566 Closes: https://github.com/operator-framework/operator-controller/issues/1556 --- catalogd/cmd/catalogd/main.go | 4 ++-- cmd/operator-controller/main.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/catalogd/cmd/catalogd/main.go b/catalogd/cmd/catalogd/main.go index 77698444c..7ce417970 100644 --- a/catalogd/cmd/catalogd/main.go +++ b/catalogd/cmd/catalogd/main.go @@ -143,12 +143,12 @@ func main() { } if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") { - setupLog.Error(nil, "unable to configure TLS certificates: tls-cert and tls-key flags must be used together") + setupLog.Error(fmt.Errorf("unable to configure TLS certificates"), "tls-cert and tls-key flags must be used together") os.Exit(1) } if metricsAddr != "" && certFile == "" && keyFile == "" { - setupLog.Error(nil, "metrics-bind-address requires tls-cert and tls-key flags to be set") + setupLog.Error(fmt.Errorf("unable to configure metrics-bind-address"), "metrics-bind-address requires tls-cert and tls-key flags to be set") os.Exit(1) } diff --git a/cmd/operator-controller/main.go b/cmd/operator-controller/main.go index 345560bcd..a85421b14 100644 --- a/cmd/operator-controller/main.go +++ b/cmd/operator-controller/main.go @@ -128,12 +128,12 @@ func main() { } if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") { - setupLog.Error(nil, "unable to configure TLS certificates: tls-cert and tls-key flags must be used together") + setupLog.Error(fmt.Errorf("unable to configure TLS certificates"), "tls-cert and tls-key flags must be used together") os.Exit(1) } if metricsAddr != "" && certFile == "" && keyFile == "" { - setupLog.Error(nil, "metrics-bind-address requires tls-cert and tls-key flags to be set") + setupLog.Error(fmt.Errorf("unable to configure metrics-bind-address"), "metrics-bind-address requires tls-cert and tls-key flags to be set") os.Exit(1) }