content: support filters on local.store#Walk()
While Walk() has been taking filter strings, it was not using the parameter. This change actually makes the filtering work. Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
@@ -90,25 +90,6 @@ func adaptContainer(o interface{}) filters.Adaptor {
|
||||
})
|
||||
}
|
||||
|
||||
func adaptContentInfo(info content.Info) filters.Adaptor {
|
||||
return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
|
||||
if len(fieldpath) == 0 {
|
||||
return "", false
|
||||
}
|
||||
|
||||
switch fieldpath[0] {
|
||||
case "digest":
|
||||
return info.Digest.String(), true
|
||||
case "size":
|
||||
// TODO: support size based filtering
|
||||
case "labels":
|
||||
return checkMap(fieldpath[1:], info.Labels)
|
||||
}
|
||||
|
||||
return "", false
|
||||
})
|
||||
}
|
||||
|
||||
func adaptContentStatus(status content.Status) filters.Adaptor {
|
||||
return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
|
||||
if len(fieldpath) == 0 {
|
||||
|
||||
@@ -181,7 +181,7 @@ func (cs *contentStore) Walk(ctx context.Context, fn content.WalkFunc, fs ...str
|
||||
if err := readInfo(&info, bkt.Bucket(k)); err != nil {
|
||||
return err
|
||||
}
|
||||
if filter.Match(adaptContentInfo(info)) {
|
||||
if filter.Match(content.AdaptInfo(info)) {
|
||||
infos = append(infos, info)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user