Skip to content

Commit

Permalink
Merge pull request #2464 from mrueg/avoid-naked-return
Browse files Browse the repository at this point in the history
chore: Avoid naked return
  • Loading branch information
k8s-ci-robot authored Aug 5, 2024
2 parents d1e7179 + cc79a58 commit 5878458
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/watch/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// / 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 {
options.ResourceVersion = "0"
}

res, err = i.lw.List(options)
res, err := i.lw.List(options)
if err != nil {
i.metrics.ListTotal.WithLabelValues("error", i.resource).Inc()
return
return nil, err
}

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
// counters based on the outcome of the Watch operation it instruments.
func (i *InstrumentedListerWatcher) Watch(options metav1.ListOptions) (res watch.Interface, err error) {
res, err = i.lw.Watch(options)
func (i *InstrumentedListerWatcher) Watch(options metav1.ListOptions) (watch.Interface, error) {
res, err := i.lw.Watch(options)
if err != nil {
i.metrics.WatchTotal.WithLabelValues("error", i.resource).Inc()
return
return nil, err
}

i.metrics.WatchTotal.WithLabelValues("success", i.resource).Inc()
return
return res, nil
}

0 comments on commit 5878458

Please sign in to comment.