admin/sync: Able to filter on the second column

This commit is contained in:
nemunaire 2022-11-02 17:42:08 +01:00
commit 7b2603afb0
2 changed files with 23 additions and 1 deletions

View file

@ -47,6 +47,28 @@ func (c *CheckExceptions) GetFileExceptions(paths ...string) *CheckExceptions {
return &ret
}
func (c *CheckExceptions) Filter2ndCol(str string) *CheckExceptions {
if c == nil {
return nil
}
ret := CheckExceptions{}
for k, v := range *c {
cols := strings.SplitN(k, ":", 3)
if len(cols) < 2 {
continue
}
if eval, err := filepath.Match(cols[1], str); err == nil && eval {
ret[k] = v
break
}
}
return &ret
}
func (c *CheckExceptions) HasException(ref string) bool {
if c == nil {
return false