diff --git a/cmd/main.go b/cmd/main.go index d8a677b..0a059cd 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -57,7 +57,7 @@ func main() { var rejectEmptyNodeDisruption bool var retryInterval time.Duration var rejectOverlappingDisruption bool - var nodeDisruptionTypes string + var nodeDisruptionTypesRaw string flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, @@ -66,7 +66,7 @@ func main() { flag.BoolVar(&rejectEmptyNodeDisruption, "reject-empty-node-disruption", false, "Reject NodeDisruption matching no actual node.") flag.DurationVar(&retryInterval, "retry-interval", controller.DefaultRetryInterval, "How long to wait between each retry (Default 60s)") flag.BoolVar(&rejectOverlappingDisruption, "reject-overlapping-disruption", false, "Automatically reject any overlapping NodeDisruption (based on node selector), preserving the oldest one") - flag.StringVar(&nodeDisruptionTypes, "node-disruption-types", "", "The list of types allowed for a node disruption separated by a comma.") + flag.StringVar(&nodeDisruptionTypesRaw, "node-disruption-types", "", "The list of types allowed for a node disruption separated by a comma.") opts := zap.Options{ Development: true, @@ -100,6 +100,8 @@ func main() { os.Exit(1) } + nodeDisruptionTypes := strings.FieldsFunc(nodeDisruptionTypesRaw, func(c rune) bool { return c == ',' }) + if err = (&controller.NodeDisruptionReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), @@ -107,7 +109,7 @@ func main() { RejectEmptyNodeDisruption: rejectEmptyNodeDisruption, RetryInterval: retryInterval, RejectOverlappingDisruption: rejectOverlappingDisruption, - NodeDisruptionTypes: strings.Split(nodeDisruptionTypes, ","), + NodeDisruptionTypes: nodeDisruptionTypes, }, }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "NodeDisruption")