aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dashboard/app/config.go3
-rw-r--r--dashboard/app/graphs.go14
-rw-r--r--pkg/covermerger/provider_web.go4
3 files changed, 15 insertions, 6 deletions
diff --git a/dashboard/app/config.go b/dashboard/app/config.go
index 715a0ea7b..0a30570aa 100644
--- a/dashboard/app/config.go
+++ b/dashboard/app/config.go
@@ -159,6 +159,9 @@ type CoverageConfig struct {
JobInitScript string
SyzEnvInitScript string
DashboardClientName string
+
+ // WebGitURI specifies where can we get the kernel file source code directly from AppEngine.
+ WebGitURI string
}
// DiscussionEmailConfig defines the correspondence between an email and a DiscussionSource.
diff --git a/dashboard/app/graphs.go b/dashboard/app/graphs.go
index da2652285..c8b2843cb 100644
--- a/dashboard/app/graphs.go
+++ b/dashboard/app/graphs.go
@@ -241,8 +241,10 @@ func handleHeatmap(c context.Context, w http.ResponseWriter, r *http.Request, f
})
}
-func githubTorvaldsLinuxURI(filePath string, rc covermerger.RepoCommit) string {
- return fmt.Sprintf("https://raw.githubusercontent.com/torvalds/linux/%s/%s", rc.Commit, filePath)
+func makeProxyURIProvider(url string) covermerger.FuncProxyURI {
+ return func(filePath, commit string) string {
+ return fmt.Sprintf("%s/%s/%s", url, commit, filePath)
+ }
}
func handleFileCoverage(c context.Context, w http.ResponseWriter, r *http.Request) error {
@@ -250,6 +252,10 @@ func handleFileCoverage(c context.Context, w http.ResponseWriter, r *http.Reques
if err != nil {
return err
}
+ nsConfig := getNsConfig(c, hdr.Namespace)
+ if nsConfig.Coverage == nil || nsConfig.Coverage.WebGitURI == "" {
+ return ErrClientNotFound
+ }
dateToStr := r.FormValue("dateto")
periodType := r.FormValue("period")
targetCommit := r.FormValue("commit")
@@ -270,12 +276,12 @@ func handleFileCoverage(c context.Context, w http.ResponseWriter, r *http.Reques
return fmt.Errorf("coveragedb.MakeTimePeriod: %w", err)
}
dateFrom, dateTo := tp.DatesFromTo()
- mainNsRepo, _ := getNsConfig(c, hdr.Namespace).mainRepoBranch()
+ mainNsRepo, _ := nsConfig.mainRepoBranch()
content, err := cover.RendFileCoverage(
c, hdr.Namespace, mainNsRepo,
targetCommit, "", // merge all commits to targetCommit
kernelFilePath,
- githubTorvaldsLinuxURI,
+ makeProxyURIProvider(nsConfig.Coverage.WebGitURI),
dateFrom,
dateTo,
cover.DefaultHTMLRenderConfig(),
diff --git a/pkg/covermerger/provider_web.go b/pkg/covermerger/provider_web.go
index 2a1bee85a..43bfee7e0 100644
--- a/pkg/covermerger/provider_web.go
+++ b/pkg/covermerger/provider_web.go
@@ -11,7 +11,7 @@ import (
"net/url"
)
-type FuncProxyURI func(filePath string, rc RepoCommit) string
+type FuncProxyURI func(filePath, commit string) string
type webGit struct {
funcProxy FuncProxyURI
@@ -39,7 +39,7 @@ var errFileNotFound = errors.New("file not found")
func (mr *webGit) loadFile(filePath, repo, commit string) ([]byte, error) {
var uri string
if mr.funcProxy != nil {
- uri = mr.funcProxy(filePath, RepoCommit{Repo: repo, Commit: commit})
+ uri = mr.funcProxy(filePath, commit)
} else {
uri = fmt.Sprintf("%s/plain/%s", repo, filePath)
if commit != "latest" {