From 0bd009fb53040e9a4fdef010526d08ab4e75bb18 Mon Sep 17 00:00:00 2001 From: Charandas Date: Tue, 20 Feb 2024 13:00:02 -0800 Subject: [PATCH] K8s: fix nil deref from dummy factory for API Server options (#83132) --- pkg/cmd/grafana/apiserver/cmd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/grafana/apiserver/cmd.go b/pkg/cmd/grafana/apiserver/cmd.go index bfa7e532a46..a7a621adad7 100644 --- a/pkg/cmd/grafana/apiserver/cmd.go +++ b/pkg/cmd/grafana/apiserver/cmd.go @@ -62,7 +62,10 @@ func newCommandStartExampleAPIServer(o *APIServerOptions, stopCh <-chan struct{} } cmd.Flags().StringVar(&runtimeConfig, "runtime-config", "", "A set of key=value pairs that enable or disable built-in APIs.") - o.factory.GetOptions().AddFlags(cmd.Flags()) + + if factoryOptions := o.factory.GetOptions(); factoryOptions != nil { + factoryOptions.AddFlags(cmd.Flags()) + } // Register standard k8s flags with the command line o.RecommendedOptions = options.NewRecommendedOptions(