diff options
Diffstat (limited to 'pkg/html/html.go')
| -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{ |
