// ListPredicate returns a list of all the items matching m. func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher) (runtime.Object, error) { list := e.NewListFunc() trace := util.NewTrace("List " + reflect.TypeOf(list).String()) defer trace.LogIfLong(600 * time.Millisecond) if name, ok := m.MatchesSingle(); ok { trace.Step("About to read single object") key, err := e.KeyFunc(ctx, name) if err != nil { return nil, err } err = e.Helper.ExtractObjToList(key, list) trace.Step("Object extracted") if err != nil { return nil, err } } else { trace.Step("About to list directory") err := e.Helper.ExtractToList(e.KeyRootFunc(ctx), list) trace.Step("List extracted") if err != nil { return nil, err } } defer trace.Step("List filtered") return generic.FilterList(list, m, generic.DecoratorFunc(e.Decorator)) }
func (r *GenericRegistry) ListPredicate(ctx api.Context, m generic.Matcher) (runtime.Object, error) { r.Lock() defer r.Unlock() if r.Err != nil { return nil, r.Err } return generic.FilterList(r.ObjectList, m, nil) }