github.com/quay/claircore@v1.5.28/updater/defaults/defaults.go (about) 1 // Package defaults sets updater defaults. 2 // 3 // Importing this package registers default updaters via its init function. 4 package defaults 5 6 import ( 7 "context" 8 "sync" 9 "time" 10 11 "github.com/quay/claircore/alpine" 12 "github.com/quay/claircore/aws" 13 "github.com/quay/claircore/debian" 14 "github.com/quay/claircore/enricher/cvss" 15 "github.com/quay/claircore/libvuln/driver" 16 "github.com/quay/claircore/oracle" 17 "github.com/quay/claircore/photon" 18 "github.com/quay/claircore/rhel" 19 "github.com/quay/claircore/rhel/rhcc" 20 "github.com/quay/claircore/suse" 21 "github.com/quay/claircore/ubuntu" 22 "github.com/quay/claircore/updater" 23 "github.com/quay/claircore/updater/osv" 24 ) 25 26 var ( 27 once sync.Once 28 regerr error 29 ) 30 31 func init() { 32 ctx, done := context.WithTimeout(context.Background(), 1*time.Minute) 33 defer done() 34 once.Do(func() { regerr = inner(ctx) }) 35 } 36 37 // Error reports if an error was encountered when initializing the default 38 // updaters. 39 func Error() error { 40 return regerr 41 } 42 43 func inner(ctx context.Context) error { 44 rf, err := rhel.NewFactory(ctx, rhel.DefaultManifest) 45 if err != nil { 46 return err 47 } 48 updater.Register("rhel", rf) 49 af, err := alpine.NewFactory(ctx) 50 if err != nil { 51 return err 52 } 53 updater.Register("alpine", af) 54 uf, err := ubuntu.NewFactory(ctx) 55 if err != nil { 56 return err 57 } 58 updater.Register("ubuntu", uf) 59 df, err := debian.NewFactory(ctx) 60 if err != nil { 61 return err 62 } 63 updater.Register("debian", df) 64 65 updater.Register("osv", new(osv.Factory)) 66 updater.Register("aws", driver.UpdaterSetFactoryFunc(aws.UpdaterSet)) 67 updater.Register("oracle", driver.UpdaterSetFactoryFunc(oracle.UpdaterSet)) 68 updater.Register("photon", driver.UpdaterSetFactoryFunc(photon.UpdaterSet)) 69 updater.Register("suse", driver.UpdaterSetFactoryFunc(suse.UpdaterSet)) 70 updater.Register("rhcc", driver.UpdaterSetFactoryFunc(rhcc.UpdaterSet)) 71 72 cvssSet := driver.NewUpdaterSet() 73 cvssSet.Add(&cvss.Enricher{}) 74 updater.Register("clair.cvss", driver.StaticSet(cvssSet)) 75 76 return nil 77 }