MCPcopy
hub / github.com/apecloud/kubeblocks / List

Method List

pkg/controller/lifecycle/lifecycle_test.go:60–84  ·  view source on GitHub ↗
(ctx context.Context, list client.ObjectList, opts ...client.ListOption)

Source from the content-addressed store, hash-verified

58}
59
60func (r *mockReader) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error {
61 items := reflect.ValueOf(list).Elem().FieldByName("Items")
62 if !items.IsValid() {
63 return fmt.Errorf("ObjectList has no Items field: %s", list.GetObjectKind().GroupVersionKind().String())
64 }
65 objects := reflect.MakeSlice(items.Type(), 0, 0)
66
67 listOpts := &client.ListOptions{}
68 for _, opt := range opts {
69 opt.ApplyToList(listOpts)
70 }
71 for i, o := range r.objs {
72 // ignore the GVK check
73 if listOpts.LabelSelector != nil {
74 if listOpts.LabelSelector.Matches(labels.Set(o.GetLabels())) {
75 objects = reflect.Append(objects, reflect.ValueOf(r.objs[i]).Elem())
76 }
77 }
78 }
79 if objects.Len() != 0 {
80 items.Set(objects)
81 return nil
82 }
83 return r.cli.List(ctx, list, opts...)
84}
85
86var mockKBAgentClient = func(mock func(*kbacli.MockClientMockRecorder)) {
87 cli := kbacli.NewMockClient(gomock.NewController(GinkgoT()))

Callers

nothing calls this directly

Calls 6

ApplyToListMethod · 0.80
SetMethod · 0.80
LenMethod · 0.80
TypeMethod · 0.65
ListMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected