forked from taskcluster/docker-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload-schema.js
More file actions
executable file
·50 lines (44 loc) · 1.29 KB
/
upload-schema.js
File metadata and controls
executable file
·50 lines (44 loc) · 1.29 KB
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
#!/usr/bin/env node --harmony
/**
The docker worker schema situation is not as easy as the queue or other http
services. The worker consumes mostly from a private state pulling from trusted
resources. That and the fact that we could have thousands of workers makes
auto pushing schema's tricky. For now this script does the uploads manually.
*/
var co = require('co');
var aws = require('aws-sdk-promise');
var loadConfig = require('taskcluster-base/config');
var config = loadConfig({
defaults: require('../config/defaults'),
profile: require('../config/production'),
filename: 'docker-worker'
});
co(function* () {
var s3 = new aws.S3({
region: config.get('schema:region'),
params: {
Bucket: config.get('schema:bucket')
}
});
function* put(path, object) {
var key = config.get('schema:path') + path;
console.log('uploading: %s', key);
return yield s3.putObject({
Key: key,
ContentType: 'application/json',
Body: new Buffer(JSON.stringify(object, null, 2))
}).promise();
}
yield [
put('payload.json', require('../schemas/payload'))
];
})(function(err) {
if (err) {
console.error(err);
process.exit(1);
}
console.log(
'Done uploading schemas to s3://%s%s',
config.get('schema:bucket'), config.get('schema:path')
);
});