From bf1ad3ce3a3d031b873fbf7c7f0fdf6af3545471 Mon Sep 17 00:00:00 2001 From: Yosiah de Koeyer Date: Sat, 12 Jul 2025 17:00:15 +1000 Subject: [PATCH] fix empty slice Signed-off-by: Yosiah de Koeyer --- cmd/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index bf0b52805..78ad52496 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -119,6 +119,14 @@ func StringToMap(s string) map[string]string { return m } +// CommaSeparatedStringToSlice transforms a comma-separated string into a slice of strings +func CommaSeparatedStringToSlice(s string) []string { + if s == "" { + return []string{} + } + return strings.Split(s, ",") +} + func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(corev1beta1.AddToScheme(scheme)) @@ -345,7 +353,7 @@ func main() { kph := flagdproxy.NewFlagdProxyHandler( flagdproxy.NewFlagdProxyConfiguration( env, - strings.Split(imagePullSecrets, ","), + CommaSeparatedStringToSlice(imagePullSecrets), labelsMap, annotationsMap, ), @@ -384,9 +392,10 @@ func main() { Scheme: mgr.GetScheme(), Log: flagdControllerLogger, } + flagdConfig := flagd.NewFlagdConfiguration( env, - strings.Split(imagePullSecrets, ","), + CommaSeparatedStringToSlice(imagePullSecrets), labelsMap, annotationsMap, )