Skip to content

Commit 32a4556

Browse files
getall funcs now return empty list if no matches
1 parent 7eebdae commit 32a4556

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

store.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (s Store) GetAll(pattern string) (KVPairs, error) {
9494
}
9595
}
9696
if len(ks) == 0 {
97-
return ks, ErrNoMatch
97+
return ks, nil
9898
}
9999
sort.Sort(ks)
100100
return ks, nil
@@ -106,6 +106,9 @@ func (s Store) GetAllValues(pattern string) ([]string, error) {
106106
if err != nil {
107107
return vs, err
108108
}
109+
if len(ks) == 0 {
110+
return vs, nil
111+
}
109112
for _, kv := range ks {
110113
vs = append(vs, kv.Value)
111114
}

store_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var getalltests = []struct {
6161
KVPair{"/app/upstream/host1", "203.0.113.0.1:8080"},
6262
KVPair{"/app/upstream/host2", "203.0.113.0.2:8080"}}},
6363
{"[]a]", filepath.ErrBadPattern, nil},
64+
{"/app/missing/*", nil, []KVPair{}},
6465
}
6566

6667
func TestGetAll(t *testing.T) {

0 commit comments

Comments
 (0)