55 "flag"
66 "os"
77 "os/signal"
8+ "regexp"
89
910 "github.com/super-phenix/volume-replicator/internal/k8s"
1011 "github.com/super-phenix/volume-replicator/internal/replicator"
@@ -16,17 +17,25 @@ func main() {
1617 ctx , cancel := signal .NotifyContext (context .Background (), os .Interrupt )
1718 defer cancel ()
1819
19- var kubeconfig , namespace string
20+ var kubeconfig , namespace , exclusionRegexStr string
2021 flag .StringVar (& kubeconfig , "kubeconfig" , "" , "path to kubeconfig file" )
2122 flag .StringVar (& namespace , "namespace" , os .Getenv ("NAMESPACE" ), "deployment namespace" )
22- flag .StringVar (& replicator . ExclusionRegex , "exclusion-regex" , os .Getenv ("EXCLUSION_REGEX" ), "regex to exclude PVCs from replication" )
23+ flag .StringVar (& exclusionRegexStr , "exclusion-regex" , os .Getenv ("EXCLUSION_REGEX" ), "regex to exclude PVCs from replication" )
2324 klog .InitFlags (nil )
2425 flag .Parse ()
2526
2627 if namespace == "" {
2728 klog .Fatalf ("must provide the namespace in which the controller is running through --namespace" )
2829 }
2930
31+ if exclusionRegexStr != "" {
32+ var err error
33+ replicator .ExclusionRegex , err = regexp .Compile (exclusionRegexStr )
34+ if err != nil {
35+ klog .Fatalf ("failed to compile exclusion regex: %s" , err .Error ())
36+ }
37+ }
38+
3039 if err := k8s .Load (kubeconfig ); err != nil {
3140 klog .Fatalf ("failed to load kubernetes configuration: %s" , err .Error ())
3241 }
0 commit comments