add db backend redis (#445)

This commit is contained in:
sadayuki-matsuno
2017-06-27 18:10:09 +09:00
committed by kota kanbe
parent c442a433b0
commit 7778783dd8
16 changed files with 282 additions and 152 deletions

View File

@@ -9,6 +9,7 @@ import (
ver "github.com/knqyf263/go-deb-version"
ovalconf "github.com/kotakanbe/goval-dictionary/config"
db "github.com/kotakanbe/goval-dictionary/db"
ovallog "github.com/kotakanbe/goval-dictionary/log"
ovalmodels "github.com/kotakanbe/goval-dictionary/models"
)
@@ -19,13 +20,27 @@ type DebianBase struct{ Base }
func (o DebianBase) fillFromOvalDB(r *models.ScanResult) error {
ovalconf.Conf.DBType = config.Conf.OvalDBType
ovalconf.Conf.DBPath = config.Conf.OvalDBPath
if ovalconf.Conf.DBType == "sqlite3" {
ovalconf.Conf.DBPath = config.Conf.OvalDBPath
} else {
ovalconf.Conf.DBPath = config.Conf.OvalDBURL
}
util.Log.Infof("open oval-dictionary db (%s): %s",
config.Conf.OvalDBType, config.Conf.OvalDBPath)
ovalconf.Conf.DBType, ovalconf.Conf.DBPath)
ovaldb, err := db.NewDB(r.Family)
if err != nil {
ovallog.Initialize(config.Conf.LogDir)
var err error
var ovaldb db.DB
if ovaldb, err = db.NewDB(
ovalconf.Debian,
ovalconf.Conf.DBType,
ovalconf.Conf.DBPath,
ovalconf.Conf.DebugSQL,
); err != nil {
return err
}
defer ovaldb.CloseDB()
for _, pack := range r.Packages {
definitions, err := ovaldb.GetByPackName(r.Release, pack.Name)