chore: Avoid naked return
This commit is contained in:
parent
d1e717911b
commit
cc79a58411
|
|
@ -74,31 +74,31 @@ func NewInstrumentedListerWatcher(lw cache.ListerWatcher, metrics *ListWatchMetr
|
||||||
|
|
||||||
// List is a wrapper func around the cache.ListerWatcher.List func. It increases the success/error
|
// List is a wrapper func around the cache.ListerWatcher.List func. It increases the success/error
|
||||||
// / counters based on the outcome of the List operation it instruments.
|
// / counters based on the outcome of the List operation it instruments.
|
||||||
func (i *InstrumentedListerWatcher) List(options metav1.ListOptions) (res runtime.Object, err error) {
|
func (i *InstrumentedListerWatcher) List(options metav1.ListOptions) (runtime.Object, error) {
|
||||||
|
|
||||||
if i.useAPIServerCache {
|
if i.useAPIServerCache {
|
||||||
options.ResourceVersion = "0"
|
options.ResourceVersion = "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err = i.lw.List(options)
|
res, err := i.lw.List(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.metrics.ListTotal.WithLabelValues("error", i.resource).Inc()
|
i.metrics.ListTotal.WithLabelValues("error", i.resource).Inc()
|
||||||
return
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
i.metrics.ListTotal.WithLabelValues("success", i.resource).Inc()
|
i.metrics.ListTotal.WithLabelValues("success", i.resource).Inc()
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch is a wrapper func around the cache.ListerWatcher.Watch func. It increases the success/error
|
// Watch is a wrapper func around the cache.ListerWatcher.Watch func. It increases the success/error
|
||||||
// counters based on the outcome of the Watch operation it instruments.
|
// counters based on the outcome of the Watch operation it instruments.
|
||||||
func (i *InstrumentedListerWatcher) Watch(options metav1.ListOptions) (res watch.Interface, err error) {
|
func (i *InstrumentedListerWatcher) Watch(options metav1.ListOptions) (watch.Interface, error) {
|
||||||
res, err = i.lw.Watch(options)
|
res, err := i.lw.Watch(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.metrics.WatchTotal.WithLabelValues("error", i.resource).Inc()
|
i.metrics.WatchTotal.WithLabelValues("error", i.resource).Inc()
|
||||||
return
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
i.metrics.WatchTotal.WithLabelValues("success", i.resource).Inc()
|
i.metrics.WatchTotal.WithLabelValues("success", i.resource).Inc()
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue