This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
html.go
106 lines (98 loc) · 2.14 KB
/
html.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package pprofserver
import "html/template"
var listServices = htmlTemplate("listServices", `
<html>
<head>
<title>Service List</title>
<style>
.service-list a {
text-decoration: none;
}
/*
* Alert box styles copied from Bootstrap, which has a MIT license:
* https://github.com/twbs/bootstrap/blob/main/LICENSE
*/
.alert {
position: relative;
padding: 0.75rem 1.25rem;
margin-bottom: 1rem;
border: 1px solid transparent;
border-radius: 0.25rem;
}
.alert-danger {
color: #721c24;
background-color: #f8d7da;
border-color: #f5c6cb;
}
</style>
</head>
<body>
<div class="alert alert-danger">
EKS services are not listed here.<br /><br />
Use <a href="https://github.com/segmentio/kubectl-curl#collecting-profiles-of-go-programs">kubectl-curl</a>
to download profiles for EKS services.
</div>
<ul class="service-list">{{ range . }}
<li><a title="{{ .Name }}" href="{{ .Href }}">{{ .Name }}</a></li>
{{ end }}</ul>
</body>
</html>
`)
var lookupService = htmlTemplate("lookupService", `
<html>
<head>
<title>{{ .Name }}</title>
<style>a {text-decoration: none;}</style>
</head>
<body>
<p>
<a href="/services"><< Services</a>
</p>
<table>
<tbody>{{ range .Profiles }}
<tr>
<td>{{ .Name }}</td>
{{- if supportsFlamegraph .Params}}
<td><a href="/tree{{ .Params }}">🌲</a></td>
<td><a href="/flame{{ .Params }}">🔥</a></td>
{{- else}}
<td><a href="/tree{{ .Params }}">📜</a></td>
{{- end}}
</tr>
{{ end }}</tbody>
</table>
</body>
</html>
`)
var listNodes = htmlTemplate("listNodes", `
<html>
<head>
<title>{{ .Name }}</title>
<style>a {text-decoration: none;}</style>
</head>
<body>
<p>
<a href="/services"><< Services</a>
</p>
<table>
<th>
<tr>
<td>Nodes</td>
</tr>
</th>
<tbody>{{ range .Nodes }}
<tr>
<td><a href="{{ .Href }}">{{ .Endpoint }}</a></td>
</tr>
{{ end }}</tbody>
</table>
</body>
</html>
`)
func htmlTemplate(name, s string) *template.Template {
funcMap := template.FuncMap{
"supportsFlamegraph": supportsFlamegraph,
}
tmpl := template.New(name).Funcs(funcMap)
return template.Must(tmpl.Parse(s))
}