Skip to content

Commit 2891c2e

Browse files
committed
dashboard, cmd/coordinator: support multiple builder owners
Prefer displaying GitHub usernames for convenience of pinging in GitHub issues, since all current builder owners have them. Keep it possible to use an email or something else if no GitHub account exists. Update the owner of the Corellium builders to be individual GitHub account, so that it can be pinged in an issue. The GitHub organization is already mentioned in the builder notes. Also switch to html/template (instead of text/template) for rendering the builders page. Fixes golang/go#49596. Change-Id: I89a96eb8f7a3057bc1f3aaee16abc9c776c45ee7 Reviewed-on: https://go-review.googlesource.com/c/build/+/363983 Trust: Dmitri Shuralyov <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 7b9db79 commit 2891c2e

File tree

7 files changed

+179
-139
lines changed

7 files changed

+179
-139
lines changed

cmd/coordinator/builders.go

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ package main
1111
import (
1212
"bytes"
1313
"encoding/json"
14+
"fmt"
15+
"html"
16+
"html/template"
1417
"net/http"
15-
"text/template"
18+
"strings"
1619

1720
"golang.org/x/build/dashboard"
1821
)
@@ -41,7 +44,34 @@ func handleBuilders(w http.ResponseWriter, r *http.Request) {
4144
}
4245
}
4346

44-
var buildersTmpl = template.Must(template.New("builders").Parse(`
47+
var buildersTmpl = template.Must(template.New("builders").Funcs(template.FuncMap{
48+
"builderOwners": func(bc *dashboard.BuildConfig) template.HTML {
49+
owners := bc.HostConfig().Owners
50+
if len(owners) == 0 {
51+
return "golang-dev"
52+
}
53+
var buf strings.Builder
54+
for i, p := range owners {
55+
if i != 0 {
56+
buf.WriteString(", ")
57+
}
58+
if p.GitHub != "" {
59+
fmt.Fprintf(&buf, `<a href="https://github.com/%s">@%[1]s</a>`, html.EscapeString(p.GitHub))
60+
} else if len(p.Emails) > 0 {
61+
name := p.Name
62+
if name == "" {
63+
name = p.Emails[0]
64+
}
65+
fmt.Fprintf(&buf, `<a href="mailto:%s">%s</a>`, html.EscapeString(p.Emails[0]), html.EscapeString(name))
66+
} else if p.Name != "" {
67+
buf.WriteString(html.EscapeString(p.Name))
68+
} else {
69+
buf.WriteString("(unnamed)")
70+
}
71+
}
72+
return template.HTML(buf.String())
73+
},
74+
}).Parse(`
4575
<!DOCTYPE html>
4676
<html>
4777
<head><link rel="stylesheet" href="/style.css"/><title>Go Farmer</title></head>
@@ -62,13 +92,13 @@ var buildersTmpl = template.Must(template.New("builders").Parse(`
6292
<h2 id='builders'>Defined Builders</h2>
6393
6494
<table>
65-
<thead><tr><th>name</th><th>pool</th><th>owner</th><th>notes</th></tr>
95+
<thead><tr><th>name</th><th>pool</th><th>owners</th><th>notes</th></tr>
6696
</thead>
6797
{{range .Builders}}
6898
<tr>
6999
<td>{{.Name}}</td>
70100
<td><a href='#{{.HostType}}'>{{.HostType}}</a></td>
71-
<td>{{if .OwnerGithub}}<a href='https://github.com/{{.OwnerGithub}}'>@{{.OwnerGithub}}</a>{{else}}{{.ShortOwner}}{{end}}</td>
101+
<td>{{builderOwners .}}</td>
72102
<td>{{.Notes}}</td>
73103
</tr>
74104
{{end}}
@@ -83,7 +113,7 @@ var buildersTmpl = template.Must(template.New("builders").Parse(`
83113
<tr id='{{.HostType}}'>
84114
<td>{{.HostType}}</td>
85115
<td>{{.PoolName}}</td>
86-
<td>{{html .Notes}}</td>
116+
<td>{{.Notes}}</td>
87117
</tr>
88118
{{end}}
89119
</table>

cmd/coordinator/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import (
1313
"encoding/json"
1414
"errors"
1515
"fmt"
16+
"html/template"
1617
"log"
1718
"net/http"
1819
"strconv"
1920
"strings"
20-
"text/template"
2121

2222
"golang.org/x/build/internal/buildgo"
2323
"golang.org/x/build/internal/coordinator/pool"

cmd/coordinator/remote_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"golang.org/x/build/buildlet"
2424
"golang.org/x/build/dashboard"
2525
"golang.org/x/build/internal/coordinator/pool"
26+
"golang.org/x/build/internal/gophers"
2627
)
2728

2829
type TestBuildletPool struct {
@@ -100,7 +101,7 @@ func addBuilder(name string) {
100101
}
101102
dashboard.Hosts["test-host"] = &dashboard.HostConfig{
102103
HostType: "test-host",
103-
104+
Owners: []*gophers.Person{{Emails: []string{"[email protected]"}}},
104105
}
105106
testPool.Add("test-host", &buildlet.Client{})
106107
}

0 commit comments

Comments
 (0)