Fix storage modules types and interfaces to compile server

This commit is contained in:
Michael Hohn
2024-06-16 20:16:26 -07:00
committed by =Michael Hohn
parent 6229c08900
commit 8b310e43ad
6 changed files with 52 additions and 20 deletions

View File

@@ -13,6 +13,7 @@ import (
"mrvacommander/pkg/agent"
"mrvacommander/pkg/logger"
"mrvacommander/pkg/qldbstore"
"mrvacommander/pkg/qpstore"
"mrvacommander/pkg/queue"
"mrvacommander/pkg/server"
@@ -79,13 +80,13 @@ func main() {
ss := storage.NewStorageSingle(config.Storage.StartingID, &storage.Visibles{})
qp, err := qpstore.NewStore(config.Storage.StartingID)
qp, err := qpstore.NewStore(&qpstore.Visibles{})
if err != nil {
slog.Error("Unable to initialize query pack storage")
os.Exit(1)
}
ql, err := storage.NewQLDBStore(config.Storage.StartingID, &storage.Visibles{})
ql, err := qldbstore.NewStore(&qldbstore.Visibles{})
if err != nil {
slog.Error("Unable to initialize ql database storage")
os.Exit(1)
@@ -116,19 +117,15 @@ func main() {
Logger: sl,
})
ss, err := storage.NewServerStore(config.Storage.StartingID, &storage.Visibles{})
if err != nil {
slog.Error("Unable to initialize server storage")
os.Exit(1)
}
ss := storage.NewStorageSingle(config.Storage.StartingID, &storage.Visibles{})
qp, err := qpstore.NewStore(config.Storage.StartingID)
qp, err := qpstore.NewStore(&qpstore.Visibles{})
if err != nil {
slog.Error("Unable to initialize query pack storage")
os.Exit(1)
}
ql, err := storage.NewQLDBStore(config.Storage.StartingID, &storage.Visibles{})
ql, err := qldbstore.NewStore(&qldbstore.Visibles{})
if err != nil {
slog.Error("Unable to initialize ql database storage")
os.Exit(1)

View File

@@ -7,9 +7,9 @@ import (
"mrvacommander/pkg/codeql"
"mrvacommander/pkg/common"
"mrvacommander/pkg/logger"
"mrvacommander/pkg/qldbstore"
"mrvacommander/pkg/qpstore"
"mrvacommander/pkg/queue"
"mrvacommander/pkg/storage"
"mrvacommander/utils"
"os"
"path/filepath"
@@ -37,7 +37,7 @@ type Visibles struct {
// TODO extra package for query pack storage
QueryPackStore qpstore.Storage
// TODO extra package for ql db storage
QLDBStore storage.Storage
QLDBStore qldbstore.Storage
}
func (r *RunnerSingle) worker(wid int) {

View File

@@ -1,6 +1,32 @@
package qldbstore
import (
"mrvacommander/pkg/common"
)
type DBLocation struct {
Prefix string
File string
}
type Storage interface {
FindAvailableDBs(analysisReposRequested []common.NameWithOwner) (not_found_repos []common.NameWithOwner,
analysisRepos *map[common.NameWithOwner]DBLocation)
}
type Visibles struct{}
type StorageQLDB struct{}
func NewStore(v *Visibles) (Storage, error) {
s := StorageQLDB{}
return &s, nil
}
func (s *StorageQLDB) FindAvailableDBs(analysisReposRequested []common.NameWithOwner) (
not_found_repos []common.NameWithOwner,
analysisRepos *map[common.NameWithOwner]DBLocation) {
// TODO implement
return nil, nil
}

View File

@@ -1,13 +1,5 @@
package qpstore
import (
"mrvacommander/pkg/common"
"mrvacommander/pkg/qldbstore"
)
type Storage interface {
NextID() int
SaveQueryPack(tgz []byte, sessionID int) (storagePath string, error error)
FindAvailableDBs(analysisReposRequested []common.NameWithOwner) (not_found_repos []common.NameWithOwner,
analysisRepos *map[common.NameWithOwner]qldbstore.DBLocation)
}

16
pkg/qpstore/qpstore.go Normal file
View File

@@ -0,0 +1,16 @@
package qpstore
type Visibles struct{}
type StorageQP struct{}
func NewStore(v *Visibles) (Storage, error) {
s := StorageQP{}
return &s, nil
}
func (s *StorageQP) SaveQueryPack(tgz []byte, sessionID int) (storagePath string, error error) {
// TODO implement
return "", nil
}

View File

@@ -3,6 +3,7 @@ package server
import (
"mrvacommander/pkg/common"
"mrvacommander/pkg/logger"
"mrvacommander/pkg/qldbstore"
"mrvacommander/pkg/qpstore"
"mrvacommander/pkg/queue"
"mrvacommander/pkg/storage"
@@ -52,5 +53,5 @@ type Visibles struct {
// TODO extra package for query pack storage
QueryPackStore qpstore.Storage
// TODO extra package for ql db storage
QLDBStore storage.Storage
QLDBStore qldbstore.Storage
}