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 | |
| 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.
| -rw-r--r-- | dashboard/app/app.yaml | 10 | ||||
| -rw-r--r-- | pkg/html/html.go | 26 |
2 files changed, 29 insertions, 7 deletions
diff --git a/dashboard/app/app.yaml b/dashboard/app/app.yaml index c8884e759..fda916425 100644 --- a/dashboard/app/app.yaml +++ b/dashboard/app/app.yaml @@ -15,15 +15,15 @@ inbound_services: handlers: - url: /favicon.ico - static_files: static/favicon.ico - upload: static/favicon.ico + static_files: dashboard/app/static/favicon.ico + upload: dashboard/app/static/favicon.ico secure: always - url: /robots.txt - static_files: static/robots.txt - upload: static/robots.txt + static_files: dashboard/app/static/robots.txt + upload: dashboard/app/static/robots.txt secure: always - url: /static - static_dir: static + static_dir: dashboard/app/static secure: always - url: /(admin|cron/.*) script: auto 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{ |
