diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-02-09 16:27:43 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-02-14 10:37:08 +0000 |
| commit | 625bd0b0c49a581f12f58c31cb2bd70162b6be77 (patch) | |
| tree | 0cb57d69ba7f989c6b230a479e02e1a92f9db1a0 /pkg/html | |
| parent | d902085f716b92f42bb867eca2975c7da711b78d (diff) | |
dashboard/app: move to GOMOD from GOPATH
The deployment takes 1.1G now. Let's check what can be removed after deployment.
Diffstat (limited to 'pkg/html')
| -rw-r--r-- | pkg/html/html.go | 26 |
1 files changed, 24 insertions, 2 deletions
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{ |
