aboutsummaryrefslogtreecommitdiffstats
path: root/syz-cluster/dashboard/handler.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-07-11 15:44:40 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-07-14 11:30:46 +0000
commitec20f94ff6effe4c2aab4b4a4ecdfb33180e6e77 (patch)
tree57058c12e7ab2ca53553afdbd75d632d98c9c9a6 /syz-cluster/dashboard/handler.go
parent76718eb73e3d1e2a43363d80ab15366706b6491f (diff)
syz-cluster: upload and share build config and log
Diffstat (limited to 'syz-cluster/dashboard/handler.go')
-rw-r--r--syz-cluster/dashboard/handler.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/syz-cluster/dashboard/handler.go b/syz-cluster/dashboard/handler.go
index f6c9b3e3b..794feba83 100644
--- a/syz-cluster/dashboard/handler.go
+++ b/syz-cluster/dashboard/handler.go
@@ -22,6 +22,7 @@ import (
type dashboardHandler struct {
title string
+ buildRepo *db.BuildRepository
seriesRepo *db.SeriesRepository
sessionRepo *db.SessionRepository
sessionTestRepo *db.SessionTestRepository
@@ -37,7 +38,8 @@ func newHandler(env *app.AppEnvironment) (*dashboardHandler, error) {
perFile := map[string]*template.Template{}
var err error
for _, name := range []string{"index.html", "series.html"} {
- perFile[name], err = template.ParseFS(templates, "templates/base.html", "templates/"+name)
+ perFile[name], err = template.ParseFS(templates,
+ "templates/base.html", "templates/templates.html", "templates/"+name)
if err != nil {
return nil, err
}
@@ -46,6 +48,7 @@ func newHandler(env *app.AppEnvironment) (*dashboardHandler, error) {
title: env.Config.Name,
templates: perFile,
blobStorage: env.BlobStorage,
+ buildRepo: db.NewBuildRepository(env.Spanner),
seriesRepo: db.NewSeriesRepository(env.Spanner),
sessionRepo: db.NewSessionRepository(env.Spanner),
sessionTestRepo: db.NewSessionTestRepository(env.Spanner),
@@ -65,6 +68,7 @@ func (h *dashboardHandler) Mux() *http.ServeMux {
mux.HandleFunc("/series/{id}", errToStatus(h.seriesInfo))
mux.HandleFunc("/patches/{id}", errToStatus(h.patchContent))
mux.HandleFunc("/findings/{id}/{key}", errToStatus(h.findingInfo))
+ mux.HandleFunc("/builds/{id}/{key}", errToStatus(h.buildInfo))
mux.HandleFunc("/", errToStatus(h.seriesList))
staticFiles, err := fs.Sub(staticFs, "static")
if err != nil {
@@ -290,6 +294,23 @@ func (h *dashboardHandler) findingInfo(w http.ResponseWriter, r *http.Request) e
}
}
+func (h *dashboardHandler) buildInfo(w http.ResponseWriter, r *http.Request) error {
+ build, err := h.buildRepo.GetByID(r.Context(), r.PathValue("id"))
+ if err != nil {
+ return err
+ } else if build == nil {
+ return fmt.Errorf("%w: build", errNotFound)
+ }
+ switch r.PathValue("key") {
+ case "log":
+ return h.streamBlob(w, build.LogURI)
+ case "config":
+ return h.streamBlob(w, build.ConfigURI)
+ default:
+ return fmt.Errorf("%w: unknown key value", errBadRequest)
+ }
+}
+
func (h *dashboardHandler) sessionTestLog(w http.ResponseWriter, r *http.Request) error {
test, err := h.sessionTestRepo.Get(r.Context(), r.PathValue("id"), r.FormValue("name"))
if err != nil {