wip: replace some references to the old prototype
This commit is contained in:
committed by
=Michael Hohn
parent
1f52a0ab37
commit
ccf064fe6c
@@ -19,7 +19,6 @@ import (
|
|||||||
"github.com/hohn/ghes-mirva-server/analyze"
|
"github.com/hohn/ghes-mirva-server/analyze"
|
||||||
"github.com/hohn/ghes-mirva-server/api"
|
"github.com/hohn/ghes-mirva-server/api"
|
||||||
co "github.com/hohn/ghes-mirva-server/common"
|
co "github.com/hohn/ghes-mirva-server/common"
|
||||||
"github.com/hohn/ghes-mirva-server/store"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *CommanderSingle) Run() {
|
func (c *CommanderSingle) Run() {
|
||||||
@@ -65,9 +64,9 @@ func (c *CommanderSingle) StatusResponse(w http.ResponseWriter, js co.JobSpec, j
|
|||||||
slog.Debug("Submitting status response", "session", vaid)
|
slog.Debug("Submitting status response", "session", vaid)
|
||||||
|
|
||||||
all_scanned := []api.ScannedRepo{}
|
all_scanned := []api.ScannedRepo{}
|
||||||
jobs := store.GetJobList(js.ID)
|
jobs := storage.GetJobList(js.ID)
|
||||||
for _, job := range jobs {
|
for _, job := range jobs {
|
||||||
astat := store.GetStatus(js.ID, job.ORL).ToExternalString()
|
astat := storage.GetStatus(js.ID, job.ORL).ToExternalString()
|
||||||
all_scanned = append(all_scanned,
|
all_scanned = append(all_scanned,
|
||||||
api.ScannedRepo{
|
api.ScannedRepo{
|
||||||
Repository: api.Repository{
|
Repository: api.Repository{
|
||||||
@@ -85,7 +84,7 @@ func (c *CommanderSingle) StatusResponse(w http.ResponseWriter, js co.JobSpec, j
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
astat := store.GetStatus(js.ID, js.OwnerRepo).ToExternalString()
|
astat := storage.GetStatus(js.ID, js.OwnerRepo).ToExternalString()
|
||||||
|
|
||||||
status := api.StatusResponse{
|
status := api.StatusResponse{
|
||||||
SessionId: js.ID,
|
SessionId: js.ID,
|
||||||
@@ -120,7 +119,6 @@ func (c *CommanderSingle) RootHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *CommanderSingle) MirvaStatus(w http.ResponseWriter, r *http.Request) {
|
func (c *CommanderSingle) MirvaStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
// TODO Port this function from ghes-mirva-server
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
slog.Info("mrva status request for ",
|
slog.Info("mrva status request for ",
|
||||||
"owner", vars["owner"],
|
"owner", vars["owner"],
|
||||||
@@ -135,7 +133,7 @@ func (c *CommanderSingle) MirvaStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
// The status reports one status for all jobs belonging to an id.
|
// The status reports one status for all jobs belonging to an id.
|
||||||
// So we simply report the status of a job as the status of all.
|
// So we simply report the status of a job as the status of all.
|
||||||
spec := store.GetJobList(id)
|
spec := storage.GetJobList(id)
|
||||||
if spec == nil {
|
if spec == nil {
|
||||||
msg := "No jobs found for given job id"
|
msg := "No jobs found for given job id"
|
||||||
slog.Error(msg, "id", vars["codeql_variant_analysis_id"])
|
slog.Error(msg, "id", vars["codeql_variant_analysis_id"])
|
||||||
@@ -150,7 +148,7 @@ func (c *CommanderSingle) MirvaStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
OwnerRepo: job.ORL,
|
OwnerRepo: job.ORL,
|
||||||
}
|
}
|
||||||
|
|
||||||
ji := store.GetJobInfo(js)
|
ji := storage.GetJobInfo(js)
|
||||||
|
|
||||||
c.StatusResponse(w, js, ji, id)
|
c.StatusResponse(w, js, ji, id)
|
||||||
}
|
}
|
||||||
@@ -185,7 +183,7 @@ func (c *CommanderSingle) MirvaDownloadArtifact(w http.ResponseWriter, r *http.R
|
|||||||
func (c *CommanderSingle) DownloadResponse(w http.ResponseWriter, js co.JobSpec, vaid int) {
|
func (c *CommanderSingle) DownloadResponse(w http.ResponseWriter, js co.JobSpec, vaid int) {
|
||||||
slog.Debug("Forming download response", "session", vaid, "job", js)
|
slog.Debug("Forming download response", "session", vaid, "job", js)
|
||||||
|
|
||||||
astat := store.GetStatus(vaid, js.OwnerRepo)
|
astat := storage.GetStatus(vaid, js.OwnerRepo)
|
||||||
|
|
||||||
var dlr api.DownloadResponse
|
var dlr api.DownloadResponse
|
||||||
if astat == co.StatusSuccess {
|
if astat == co.StatusSuccess {
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mutex sync.Mutex
|
jobs map[int][]co.AnalyzeJob = make(map[int][]co.AnalyzeJob)
|
||||||
|
info map[co.JobSpec]co.JobInfo = make(map[co.JobSpec]co.JobInfo)
|
||||||
|
status map[co.JobSpec]co.Status = make(map[co.JobSpec]co.Status)
|
||||||
result map[co.JobSpec]co.AnalyzeResult = make(map[co.JobSpec]co.AnalyzeResult)
|
result map[co.JobSpec]co.AnalyzeResult = make(map[co.JobSpec]co.AnalyzeResult)
|
||||||
|
mutex sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
type StorageSingle struct {
|
type StorageSingle struct {
|
||||||
@@ -174,3 +177,21 @@ func PackageResults(ar co.AnalyzeResult, owre co.OwnerRepo, vaid int) (zipPath s
|
|||||||
}
|
}
|
||||||
return zpath, nil
|
return zpath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetJobList(sessionid int) []co.AnalyzeJob {
|
||||||
|
mutex.Lock()
|
||||||
|
defer mutex.Unlock()
|
||||||
|
return jobs[sessionid]
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetJobInfo(js co.JobSpec) co.JobInfo {
|
||||||
|
mutex.Lock()
|
||||||
|
defer mutex.Unlock()
|
||||||
|
return info[js]
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStatus(sessionid int, orl co.OwnerRepo) co.Status {
|
||||||
|
mutex.Lock()
|
||||||
|
defer mutex.Unlock()
|
||||||
|
return status[co.JobSpec{ID: sessionid, OwnerRepo: orl}]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user