screwdriver-api 4.1.180 → 4.1.181
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const boom = require('@hapi/boom');
|
|
4
|
+
const joi = require('joi');
|
|
5
|
+
const schema = require('screwdriver-data-schema');
|
|
6
|
+
const idSchema = schema.models.build.base.extract('id');
|
|
7
|
+
|
|
8
|
+
module.exports = config => ({
|
|
9
|
+
method: 'POST',
|
|
10
|
+
path: '/builds/{id}/artifacts/unzip',
|
|
11
|
+
options: {
|
|
12
|
+
description: 'Extract a ZIP for build artifacts',
|
|
13
|
+
notes: 'Extract a specific ZIP for build artifacts',
|
|
14
|
+
tags: ['api', 'builds', 'artifacts'],
|
|
15
|
+
auth: {
|
|
16
|
+
strategies: ['token'],
|
|
17
|
+
scope: ['build']
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
handler: async (req, h) => {
|
|
21
|
+
const buildId = req.params.id;
|
|
22
|
+
const { username, scope } = req.auth.credentials;
|
|
23
|
+
const isBuild = scope.includes('build');
|
|
24
|
+
const { buildFactory } = req.server.app;
|
|
25
|
+
|
|
26
|
+
if (isBuild && username !== buildId) {
|
|
27
|
+
return boom.forbidden(`Credential only valid for ${username}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return buildFactory
|
|
31
|
+
.get(buildId)
|
|
32
|
+
.then(async buildModel => {
|
|
33
|
+
if (!buildModel) {
|
|
34
|
+
throw boom.notFound('Build does not exist');
|
|
35
|
+
}
|
|
36
|
+
await buildModel.unzipArtifacts();
|
|
37
|
+
return h.response().code(202);
|
|
38
|
+
})
|
|
39
|
+
.catch(err => {
|
|
40
|
+
throw err;
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
validate: {
|
|
44
|
+
params: joi.object({
|
|
45
|
+
id: idSchema
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
package/plugins/builds/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const createRoute = require('./create');
|
|
|
11
11
|
const stepGetRoute = require('./steps/get');
|
|
12
12
|
const listStepsRoute = require('./steps/list');
|
|
13
13
|
const artifactGetRoute = require('./artifacts/get');
|
|
14
|
+
const artifactUnzipRoute = require('./artifacts/unzip');
|
|
14
15
|
const stepUpdateRoute = require('./steps/update');
|
|
15
16
|
const stepLogsRoute = require('./steps/logs');
|
|
16
17
|
const listSecretsRoute = require('./listSecrets');
|
|
@@ -1110,7 +1111,8 @@ const buildsPlugin = {
|
|
|
1110
1111
|
listSecretsRoute(),
|
|
1111
1112
|
tokenRoute(),
|
|
1112
1113
|
metricsRoute(),
|
|
1113
|
-
artifactGetRoute(options)
|
|
1114
|
+
artifactGetRoute(options),
|
|
1115
|
+
artifactUnzipRoute(),
|
|
1114
1116
|
]);
|
|
1115
1117
|
}
|
|
1116
1118
|
};
|