Skip to content

Commit 3dae6fb

Browse files
Merge pull request #995 from njhale/refactor-opstatus
refactor(operatorstatus): make monitor constructor variadic
2 parents 43cd26a + f632fb7 commit 3dae6fb

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

cmd/olm/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func main() {
204204

205205
names := *writePackageServerStatusName
206206
discovery := opClient.KubernetesInterface().Discovery()
207-
monitor, sender := operatorstatus.NewMonitor(names, logger, discovery, configClient)
207+
monitor, sender := operatorstatus.NewMonitor(logger, discovery, configClient, names)
208208

209209
handler := operatorstatus.NewCSVWatchNotificationHandler(logger, op.GetCSVSetGenerator(), op.GetReplaceFinder(), sender)
210210
op.RegisterCSVWatchNotification(handler)

pkg/lib/operatorstatus/monitor.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package operatorstatus
22

33
import (
44
"fmt"
5-
"strings"
65
"time"
76

87
configv1 "github.com/openshift/api/config/v1"
@@ -26,10 +25,8 @@ const (
2625
// to send update notifications to it.
2726
//
2827
// The name of the clusteroperator resource to monitor is specified in name.
29-
func NewMonitor(name string, log *logrus.Logger, discovery discovery.DiscoveryInterface, configClient configv1client.ConfigV1Interface) (Monitor, Sender) {
28+
func NewMonitor(log *logrus.Logger, discovery discovery.DiscoveryInterface, configClient configv1client.ConfigV1Interface, names ...string) (Monitor, Sender) {
3029
logger := log.WithField("monitor", "clusteroperator")
31-
names := split(name)
32-
3330
logger.Infof("monitoring the following components %s", names)
3431

3532
monitor := &monitor{
@@ -208,17 +205,3 @@ func Waiting(clock clock.Clock, name string) *configv1.ClusterOperatorStatus {
208205

209206
return status
210207
}
211-
212-
func split(n string) []string {
213-
names := make([]string, 0)
214-
215-
values := strings.Split(n, ",")
216-
for _, v := range values {
217-
v = strings.TrimSpace(v)
218-
if v != "" {
219-
names = append(names, v)
220-
}
221-
}
222-
223-
return names
224-
}

0 commit comments

Comments
 (0)