-
Notifications
You must be signed in to change notification settings - Fork 86
/
matcherfactory.go
45 lines (37 loc) · 1.05 KB
/
matcherfactory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package rhel
import (
"context"
"net/http"
"github.com/quay/zlog"
"github.com/quay/claircore/libvuln/driver"
)
var (
_ driver.MatcherFactory = (*MatcherFactory)(nil)
_ driver.MatcherConfigurable = (*MatcherFactory)(nil)
)
type MatcherFactory struct {
ignoreUnpatched bool
}
// MatcherFactory implements [driver.MatcherFactory]
func (f *MatcherFactory) Matcher(ctx context.Context) ([]driver.Matcher, error) {
m := &Matcher{
ignoreUnpatched: f.ignoreUnpatched,
}
return []driver.Matcher{m}, nil
}
type MatcherFactoryConfig struct {
IgnoreUnpatched bool `json:"ignore_unpatched" yaml:"ignore_unpatched"`
}
// MatcherFactory implements driver.MatcherConfigurable.
func (f *MatcherFactory) Configure(ctx context.Context, cfg driver.MatcherConfigUnmarshaler, _ *http.Client) error {
var fc MatcherFactoryConfig
if err := cfg(&fc); err != nil {
return err
}
f.ignoreUnpatched = fc.IgnoreUnpatched
zlog.Info(ctx).
Str("component", "rhel/MatcherFactory.Configure").
Bool("ignore_unpatched", f.ignoreUnpatched).
Msg("configured")
return nil
}