From 625bd0b0c49a581f12f58c31cb2bd70162b6be77 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Fri, 9 Feb 2024 16:27:43 +0100 Subject: dashboard/app: move to GOMOD from GOPATH The deployment takes 1.1G now. Let's check what can be removed after deployment. --- pkg/html/html.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'pkg/html') diff --git a/pkg/html/html.go b/pkg/html/html.go index 930fdd923..7e52d3930 100644 --- a/pkg/html/html.go +++ b/pkg/html/html.go @@ -7,6 +7,7 @@ import ( "fmt" "html/template" "net/url" + "path/filepath" "reflect" "strings" texttemplate "text/template" @@ -14,14 +15,35 @@ import ( "github.com/google/syzkaller/dashboard/dashapi" "github.com/google/syzkaller/pkg/vcs" + "google.golang.org/appengine/v2" ) +// searchPath differs for the tests and AppEngine because we don't follow +// the recommended folder structure (my best guess). +// When you run the dashboard/app tests, CWD is syzkaller/dashboard/app. +// When you deploy AppEngine in the GOPATH mode, CWD is syzkaller/dashboard/app. +// When you deploy AppEngine in the GOMOD, CWD is syzkaller/. +func globSearchPath() string { + if appengine.IsAppEngine() { + return "dashboard/app/" + } + return "" +} + func CreateGlob(glob string) *template.Template { - return template.Must(template.New("").Funcs(Funcs).ParseGlob(glob)) + if strings.Contains(glob, string(filepath.Separator)) { + panic("glob can't be a path, the files mask is expected") + } + return template.Must( + template.New("").Funcs(Funcs).ParseGlob(globSearchPath() + glob)) } func CreateTextGlob(glob string) *texttemplate.Template { - return texttemplate.Must(texttemplate.New("").Funcs(Funcs).ParseGlob(glob)) + if strings.Contains(glob, string(filepath.Separator)) { + panic("glob can't be a path, the files mask is expected") + } + return texttemplate.Must( + texttemplate.New("").Funcs(Funcs).ParseGlob(globSearchPath() + glob)) } var Funcs = template.FuncMap{ -- cgit mrf-deployment