Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(operatorstatus): make monitor constructor variadic #995

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/olm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func main() {

names := *writePackageServerStatusName
discovery := opClient.KubernetesInterface().Discovery()
monitor, sender := operatorstatus.NewMonitor(names, logger, discovery, configClient)
monitor, sender := operatorstatus.NewMonitor(logger, discovery, configClient, names)

handler := operatorstatus.NewCSVWatchNotificationHandler(logger, op.GetCSVSetGenerator(), op.GetReplaceFinder(), sender)
op.RegisterCSVWatchNotification(handler)
Expand Down
19 changes: 1 addition & 18 deletions pkg/lib/operatorstatus/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package operatorstatus

import (
"fmt"
"strings"
"time"

configv1 "github.com/openshift/api/config/v1"
Expand All @@ -26,10 +25,8 @@ const (
// to send update notifications to it.
//
// The name of the clusteroperator resource to monitor is specified in name.
func NewMonitor(name string, log *logrus.Logger, discovery discovery.DiscoveryInterface, configClient configv1client.ConfigV1Interface) (Monitor, Sender) {
func NewMonitor(log *logrus.Logger, discovery discovery.DiscoveryInterface, configClient configv1client.ConfigV1Interface, names ...string) (Monitor, Sender) {
logger := log.WithField("monitor", "clusteroperator")
names := split(name)

logger.Infof("monitoring the following components %s", names)

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

return status
}

func split(n string) []string {
names := make([]string, 0)

values := strings.Split(n, ",")
for _, v := range values {
v = strings.TrimSpace(v)
if v != "" {
names = append(names, v)
}
}

return names
}