@@ -56,25 +56,32 @@ func NewCollector(logger klog.Logger, trimaranSpec *pluginConfig.TrimaranSpec) (
56
56
logger .V (4 ).Info ("Using TrimaranSpec" , "type" , trimaranSpec .MetricProvider .Type ,
57
57
"address" , trimaranSpec .MetricProvider .Address , "watcher" , trimaranSpec .WatcherAddress )
58
58
59
- var client loadwatcherapi.Client
59
+ var (
60
+ client loadwatcherapi.Client
61
+ err error
62
+ )
60
63
if trimaranSpec .WatcherAddress != "" {
61
- client , _ = loadwatcherapi .NewServiceClient (trimaranSpec .WatcherAddress )
64
+ client , err = loadwatcherapi .NewServiceClient (trimaranSpec .WatcherAddress )
62
65
} else {
63
66
opts := watcher.MetricsProviderOpts {
64
67
Name : string (trimaranSpec .MetricProvider .Type ),
65
68
Address : trimaranSpec .MetricProvider .Address ,
66
69
AuthToken : trimaranSpec .MetricProvider .Token ,
67
70
InsecureSkipVerify : trimaranSpec .MetricProvider .InsecureSkipVerify ,
68
71
}
69
- client , _ = loadwatcherapi .NewLibraryClient (opts )
72
+ client , err = loadwatcherapi .NewLibraryClient (opts )
73
+ }
74
+
75
+ if err != nil {
76
+ return nil , err
70
77
}
71
78
72
79
collector := & Collector {
73
80
client : client ,
74
81
}
75
82
76
83
// populate metrics before returning
77
- err : = collector .updateMetrics (logger )
84
+ err = collector .updateMetrics (logger )
78
85
if err != nil {
79
86
logger .Error (err , "Unable to populate metrics initially" )
80
87
}
0 commit comments