From a7f206f0e4b264de8fb8b059d10c96beb8c6a3a4 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 3 Jul 2025 15:09:21 +0200 Subject: syz-cluster: make the displayed title configurable --- syz-cluster/dashboard/deployment.yaml | 7 +++++++ syz-cluster/dashboard/handler.go | 21 +++++++++++++++++++-- syz-cluster/dashboard/templates/base.html | 6 +++--- syz-cluster/pkg/app/config.go | 3 +++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/syz-cluster/dashboard/deployment.yaml b/syz-cluster/dashboard/deployment.yaml index 4dd683d6f..94407a9fe 100644 --- a/syz-cluster/dashboard/deployment.yaml +++ b/syz-cluster/dashboard/deployment.yaml @@ -22,6 +22,9 @@ spec: envFrom: - configMapRef: name: global-config-env + volumeMounts: + - name: config-volume + mountPath: /config ports: - containerPort: 8081 resources: @@ -31,3 +34,7 @@ spec: limits: cpu: 4 memory: 8G + volumes: + - name: config-volume + configMap: + name: global-config diff --git a/syz-cluster/dashboard/handler.go b/syz-cluster/dashboard/handler.go index 9b8503df3..ddcc51a47 100644 --- a/syz-cluster/dashboard/handler.go +++ b/syz-cluster/dashboard/handler.go @@ -21,6 +21,7 @@ import ( ) type dashboardHandler struct { + title string seriesRepo *db.SeriesRepository sessionRepo *db.SessionRepository sessionTestRepo *db.SessionTestRepository @@ -41,7 +42,12 @@ func newHandler(env *app.AppEnvironment) (*dashboardHandler, error) { return nil, err } } + cfg, err := app.Config() + if err != nil { + return nil, err + } return &dashboardHandler{ + title: cfg.Name, templates: perFile, blobStorage: env.BlobStorage, seriesRepo: db.NewSeriesRepository(env.Spanner), @@ -133,7 +139,7 @@ func (h *dashboardHandler) seriesList(w http.ResponseWriter, r *http.Request) er data.NextPageURL = urlutil.SetParam(baseURL, "offset", fmt.Sprintf("%d", data.Filter.Offset+len(data.List))) } - return h.templates["index.html"].ExecuteTemplate(w, "base.html", data) + return h.renderTemplate(w, "index.html", data) } func (h *dashboardHandler) getOffset(r *http.Request) (int, error) { @@ -202,7 +208,7 @@ func (h *dashboardHandler) seriesInfo(w http.ResponseWriter, r *http.Request) er } data.Sessions = append(data.Sessions, sessionData) } - return h.templates["series.html"].ExecuteTemplate(w, "base.html", data) + return h.renderTemplate(w, "series.html", data) } func groupFindings(findings []*db.Finding) map[string][]*db.Finding { @@ -213,6 +219,17 @@ func groupFindings(findings []*db.Finding) map[string][]*db.Finding { return ret } +func (h *dashboardHandler) renderTemplate(w http.ResponseWriter, name string, data any) error { + type page struct { + Title string + Data any + } + return h.templates[name].ExecuteTemplate(w, "base.html", page{ + Title: h.title, + Data: data, + }) +} + // nolint:dupl func (h *dashboardHandler) sessionLog(w http.ResponseWriter, r *http.Request) error { session, err := h.sessionRepo.GetByID(r.Context(), r.PathValue("id")) diff --git a/syz-cluster/dashboard/templates/base.html b/syz-cluster/dashboard/templates/base.html index df5cca54f..c154de1db 100644 --- a/syz-cluster/dashboard/templates/base.html +++ b/syz-cluster/dashboard/templates/base.html @@ -6,11 +6,11 @@ - syz-cluster + {{.Title}} - {{block "content" .}}{{end}} + {{block "content" .Data}}{{end}} diff --git a/syz-cluster/pkg/app/config.go b/syz-cluster/pkg/app/config.go index 66cebcaca..66a30bd23 100644 --- a/syz-cluster/pkg/app/config.go +++ b/syz-cluster/pkg/app/config.go @@ -13,6 +13,8 @@ import ( ) type AppConfig struct { + // The name that will be shown on the Web UI. + Name string `yaml:"name"` // How many workflows are scheduled in parallel. ParallelWorkflows int `yaml:"parallelWorkflows"` // What Lore archives are to be polled for new patch series. @@ -58,6 +60,7 @@ func loadConfig() { return } obj := AppConfig{ + Name: "Syzbot CI", ParallelWorkflows: 1, } err = yaml.Unmarshal(data, &obj) -- cgit mrf-deployment