Skip to content

Commit

Permalink
Make productivity oncall schedule visible to community (knative#443)
Browse files Browse the repository at this point in the history
* this is to create tools/infra oncall.html which will be accessible to OSS community.

* Fix whitespaces

* remove static mapping

* remove static mapping
  • Loading branch information
jessiezcc authored and knative-prow-robot committed Feb 4, 2019
1 parent bf7e4dd commit 25878c0
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tools/oncall/oncall.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<!-- To "deploy": gsutil cp -Z oncall.html gs://knative-infra-oncall/ -->
<html>
<script>
// extracted/modified from kubernetes/test-infra/test-infra/maintenance/oncall.html
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 = ''
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var person = oncall[key];
html += '<h2>' + key + ': ';
//construct HTML content
if (person) {
html += '<a href="https://github.com/' + person + '">';
html += person + '<img src="https://github.com/' + person + '.png?size=125"></a>';
} else {
html += 'None'
}
html += '</h2>';
}

// trivial XSS, but storage.googleapis.com is even more trivial XSS!
document.getElementById('oncall').innerHTML = html;
document.getElementById('updated').innerText = req.getResponseHeader('date');
}

get('oncall.json', build_table);
</script>
<title>Knative Tools/Infra Oncall Rotation</title>
<style>
body { background-color: #eee; padding-left: 30%; }
img { padding-left: 10px; max-width: 125px; }
</style>
<body>
<h1>Knative Tools/Infra Oncall Rotation</h1>
<p>Updated: <span id="updated">Never</span></a>
<div id="oncall">Loading...</div>
<sub><a href="https://storage.googleapis.com/knative-infra-oncall/oncall.json">data source</a></sub>
</body>
</html>

0 comments on commit 25878c0

Please sign in to comment.