Skip to content

Commit a3d23de

Browse files
Check if the supported namespace regex compiles at startup
1 parent 89969ec commit a3d23de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmd/utils/flags.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package utils
22

33
import (
44
"flag"
5+
"fmt"
56
"path/filepath"
7+
"regexp"
68

79
"github.com/spotahome/redis-operator/operator/redisfailover"
810
"k8s.io/client-go/util/homedir"
@@ -39,6 +41,10 @@ func (c *CMDFlags) Init() {
3941
flag.StringVar(&c.LogLevel, "log-level", "info", "set log level")
4042
// Parse flags
4143
flag.Parse()
44+
45+
if _, err := regexp.Compile(c.SupportedNamespacesRegex); err != nil {
46+
panic(fmt.Errorf("supported namespaces Regex is not valid: %w", err))
47+
}
4248
}
4349

4450
// ToRedisOperatorConfig convert the flags to redisfailover config

0 commit comments

Comments
 (0)