mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-12-22 13:56:30 +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:
parent
3dc8a31929
commit
d06c91220f
1 changed files with 3 additions and 3 deletions
6
check.go
6
check.go
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue