-
Notifications
You must be signed in to change notification settings - Fork 80
/
defaults.go
77 lines (68 loc) · 1.94 KB
/
defaults.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Package defaults sets updater defaults.
//
// Importing this package registers default updaters via its init function.
package defaults
import (
"context"
"sync"
"time"
"github.com/quay/claircore/alpine"
"github.com/quay/claircore/aws"
"github.com/quay/claircore/debian"
"github.com/quay/claircore/enricher/cvss"
"github.com/quay/claircore/libvuln/driver"
"github.com/quay/claircore/oracle"
"github.com/quay/claircore/photon"
"github.com/quay/claircore/rhel"
"github.com/quay/claircore/rhel/rhcc"
"github.com/quay/claircore/suse"
"github.com/quay/claircore/ubuntu"
"github.com/quay/claircore/updater"
"github.com/quay/claircore/updater/osv"
)
var (
once sync.Once
regerr error
)
func init() {
ctx, done := context.WithTimeout(context.Background(), 1*time.Minute)
defer done()
once.Do(func() { regerr = inner(ctx) })
}
// Error reports if an error was encountered when initializing the default
// updaters.
func Error() error {
return regerr
}
func inner(ctx context.Context) error {
rf, err := rhel.NewFactory(ctx, rhel.DefaultManifest)
if err != nil {
return err
}
updater.Register("rhel", rf)
af, err := alpine.NewFactory(ctx)
if err != nil {
return err
}
updater.Register("alpine", af)
uf, err := ubuntu.NewFactory(ctx)
if err != nil {
return err
}
updater.Register("ubuntu", uf)
df, err := debian.NewFactory(ctx)
if err != nil {
return err
}
updater.Register("debian", df)
updater.Register("osv", new(osv.Factory))
updater.Register("aws", driver.UpdaterSetFactoryFunc(aws.UpdaterSet))
updater.Register("oracle", driver.UpdaterSetFactoryFunc(oracle.UpdaterSet))
updater.Register("photon", driver.UpdaterSetFactoryFunc(photon.UpdaterSet))
updater.Register("suse", driver.UpdaterSetFactoryFunc(suse.UpdaterSet))
updater.Register("rhcc", driver.UpdaterSetFactoryFunc(rhcc.UpdaterSet))
cvssSet := driver.NewUpdaterSet()
cvssSet.Add(&cvss.Enricher{})
updater.Register("clair.cvss", driver.StaticSet(cvssSet))
return nil
}