1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-11-25 17:45:39 +00:00

check: error out on unrecognized keyword

Make sure a keyword is valid before checking if
the keyword exists in the set of KeyVals that
Check() is supposed to validate.

Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
Stephen Chung 2016-07-14 12:21:47 -04:00
parent 3dc8a31929
commit d06c91220f

View file

@ -63,13 +63,13 @@ func Check(root string, dh *DirectoryHierarchy, keywords []string) (*Result, err
}
for _, kv := range kvs {
if keywords != nil && !inSlice(kv.Keyword(), keywords) {
continue
}
keywordFunc, ok := KeywordFuncs[kv.Keyword()]
if !ok {
return nil, fmt.Errorf("Unknown keyword %q for file %q", kv.Keyword(), e.Path())
}
if keywords != nil && !inSlice(kv.Keyword(), keywords) {
continue
}
curKeyVal, err := keywordFunc(filepath.Join(root, e.Path()), info)
if err != nil {
return nil, err