Skip to content

Commit 00a6118

Browse files
committed
fix gocyclo lints
1 parent b7d955f commit 00a6118

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pkg/client/cache.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,23 @@ func (c *singleObjectCache) List(ctx context.Context, opts *ListOptions, out run
189189
labelSel = opts.LabelSelector
190190
}
191191

192+
outItems, err := c.getListItems(objs, labelSel)
193+
if err != nil {
194+
return err
195+
}
196+
return apimeta.SetList(out, outItems)
197+
}
198+
199+
func (c *singleObjectCache) getListItems(objs []interface{}, labelSel labels.Selector) ([]runtime.Object, error) {
192200
outItems := make([]runtime.Object, 0, len(objs))
193201
for _, item := range objs {
194202
obj, isObj := item.(runtime.Object)
195203
if !isObj {
196-
return fmt.Errorf("cache contained %T, which is not an Object", obj)
204+
return nil, fmt.Errorf("cache contained %T, which is not an Object", obj)
197205
}
198206
meta, err := apimeta.Accessor(obj)
199207
if err != nil {
200-
return err
208+
return nil, err
201209
}
202210
if labelSel != nil {
203211
lbls := labels.Set(meta.GetLabels())
@@ -207,7 +215,7 @@ func (c *singleObjectCache) List(ctx context.Context, opts *ListOptions, out run
207215
}
208216
outItems = append(outItems, obj.DeepCopyObject())
209217
}
210-
return apimeta.SetList(out, outItems)
218+
return outItems, nil
211219
}
212220

213221
// TODO: Make an interface with this function that has an Informers as an object on the struct

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ gometalinter.v2 --disable-all --enable=misspell \
126126
--enable=nakedret \
127127
--enable=interfacer \
128128
--enable=misspell \
129+
--enable=gocyclo \
129130
./pkg/...
130131
# TODO: Enable these as we fix them to make them pass
131-
# --enable=gocyclo \
132132
# --enable=maligned \
133133
# --enable=dupl \
134134
# --enable=safesql \

0 commit comments

Comments
 (0)