forked from kubernetes/test-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoncall.html
134 lines (125 loc) · 3.94 KB
/
oncall.html
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<!-- To "deploy": gsutil cp -Z oncall.html gs://test-infra-oncall/ -->
<html lang="en">
<script>
var rotationsMetadata = {
"google-build-admin": {
"prettyName": "Google Build Admin",
"slack": "@google-build-admin",
"timezone": '<a href="https://time.is/PT">PT</a>',
"description": 'Debian / RPM package build & publishing for releases',
},
"testinfra": {
"prettyName": "Test Infra",
"slack": "@test-infra-oncall",
"timezone": '<a href="https://time.is/PT">PT</a>',
"description": "Prow, TestGrid, and other Google hosted infrastructure"
},
"scalability": {
"prettyName": "Scalability",
"timezone": '<a href="https://time.is/CET">CET</a>',
// TODO: description
}
};
// extracted/modified from kubernetes/test-infra/gubernator/static/build.js
function get(uri, callback) {
if (uri[0] === '/') {
// Matches /bucket/file/path -> [..., "bucket", "file/path"]
var groups = uri.match(/([^/:]+)\/(.*)/);
var bucket = groups[1], path = groups[2];
var url = 'https://www.googleapis.com/storage/v1/b/' + bucket + '/o/' +
encodeURIComponent(path) + '?alt=media';
} else {
var url = uri;
}
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function (resp) {
callback(req);
};
req.send();
}
function build_table(req) {
var data = req.response;
var oncall = JSON.parse(data).Oncall;
var keys = Object.keys(oncall).sort();
var html = '';
html += '<table>';
html += '<thead> <tr> <th> Rotation </th> <th> Slack </th> <th colspan=2> Current </th> <th> Time Zone </th> <th> Description </th> </tr>';
html += '<tbody>';
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var person = oncall[key];
// get info about this rotation
var rotationInfo = rotationsMetadata[key];
var name = key;
var description = "";
var timezone = "";
var slack = "";
if (rotationInfo) {
if ("prettyName" in rotationInfo) {
name = rotationInfo["prettyName"];
}
if ("slack" in rotationInfo) {
slack = rotationInfo["slack"];
}
if ("description" in rotationInfo) {
description = rotationInfo["description"];
}
if ("timezone" in rotationInfo) {
timezone = rotationInfo["timezone"];
}
}
// add to table
html += '<tr>';
html += '<td style="font-weight: bold">' + name + '</td>';
if (person) {
html += '<td><code>' + slack + '</code></td>';
html += '<td> <a href="https://github.com/' + person + '">' + person + ' </td>';
html += '<td> <img src="https://github.com/' + person + '.png?size=125" alt=""></a> </td>';
html += '<td>' + timezone + '</td>';
html += '<td>' + description + '</td>';
} else {
html += 'None';
}
html += '</tr>'
}
html += '</tbody>';
html += '</table>';
// trivial XSS, but storage.googleapis.com is even more trivial XSS!
document.getElementById('oncall').innerHTML = html;
document.getElementById('updated').innerText = req.getResponseHeader('date');
}
get('/kubernetes-jenkins/oncall.json', build_table);
</script>
<title>K8s Oncall Rotations</title>
<style>
body {
background-color: #eee;
margin-left: auto;
margin-right: auto;
text-align: center;
}
img {
padding-left: 10px;
max-width: 125px;
}
table, th, td {
border: 1px solid black;
}
th, td {
padding: 5px;
text-align: center;
}
#oncall {
display: inline-block;
}
</style>
<body>
<h1>Kubernetes Oncall Rotations</h1>
<p>Updated: <span id="updated">Never</span>
<h2>NOTE: Rotations are Google-staffed, volunteer, best-effort during business-hours.</h2>
<div id="oncall">Loading...</div>
<div><a href="https://storage.googleapis.com/kubernetes-jenkins/oncall.json">data source</a></div>
</body>
</html>