From 0c3836670cd35f2f39611c89a9dc181538173dd4 Mon Sep 17 00:00:00 2001 From: Connor Catlett Date: Fri, 19 Apr 2024 17:54:12 +0000 Subject: [PATCH] Validate options in main.go Signed-off-by: Connor Catlett --- cmd/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index 048276ad48..417ec49118 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -89,7 +89,12 @@ func main() { options.AddFlags(fs) if err = fs.Parse(args); err != nil { - panic(err) + klog.ErrorS(err, "Failed to parse options") + klog.FlushAndExit(klog.ExitFlushTimeout, 0) + } + if err = options.Validate(); err != nil { + klog.ErrorS(err, "Invalid options") + klog.FlushAndExit(klog.ExitFlushTimeout, 0) } err = logsapi.ValidateAndApply(c, featureGate)