screwdriver-api 8.0.179 → 8.0.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 +1 -1
- package/plugins/auth/index.js +2 -2
- package/plugins/auth/token.js +3 -3
- package/plugins/buildClusters/create.js +5 -0
- package/plugins/buildClusters/get.js +5 -0
- package/plugins/buildClusters/list.js +5 -0
- package/plugins/buildClusters/remove.js +5 -0
- package/plugins/buildClusters/update.js +5 -0
- package/plugins/builds/artifacts/get.js +5 -0
- package/plugins/builds/artifacts/getAll.js +5 -0
- package/plugins/builds/artifacts/unzip.js +5 -0
- package/plugins/builds/create.js +3 -0
- package/plugins/builds/get.js +5 -0
- package/plugins/builds/getBuildStatuses.js +5 -0
- package/plugins/builds/listSecrets.js +5 -0
- package/plugins/builds/metrics.js +5 -0
- package/plugins/builds/steps/get.js +5 -0
- package/plugins/builds/steps/list.js +5 -0
- package/plugins/builds/steps/logs.js +5 -0
- package/plugins/builds/update.js +5 -0
- package/plugins/coverage/info.js +5 -0
- package/plugins/isAdmin.js +3 -0
- package/plugins/jobs/buildCluster/remove.js +5 -0
- package/plugins/jobs/buildCluster/update.js +5 -0
- package/plugins/jobs/get.js +5 -0
- package/plugins/jobs/lastSuccessfulMeta.js +5 -0
- package/plugins/jobs/latestBuild.js +5 -0
- package/plugins/jobs/listBuilds.js +5 -0
- package/plugins/jobs/metrics.js +5 -0
- package/plugins/jobs/notify.js +5 -0
- package/plugins/jobs/update.js +5 -0
- package/plugins/pipelines/badge.js +8 -15
- package/plugins/pipelines/jobBadge.js +44 -49
- package/plugins/secrets/create.js +5 -0
- package/plugins/secrets/get.js +5 -0
- package/plugins/secrets/remove.js +5 -0
- package/plugins/secrets/update.js +5 -0
- package/plugins/stages/get.js +5 -0
- package/plugins/stages/stageBuilds/list.js +5 -0
- package/plugins/tokens/create.js +5 -0
- package/plugins/tokens/list.js +5 -0
- package/plugins/tokens/refresh.js +5 -0
- package/plugins/tokens/remove.js +5 -0
- package/plugins/tokens/update.js +5 -0
package/package.json
CHANGED
package/plugins/auth/index.js
CHANGED
|
@@ -115,13 +115,13 @@ const authPlugin = {
|
|
|
115
115
|
throw boom.unauthorized();
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
const credentials = request.auth
|
|
118
|
+
const { credentials } = request.auth;
|
|
119
119
|
|
|
120
120
|
if (!credentials.auth || credentials.auth.type !== 'api_token') {
|
|
121
121
|
return h.continue;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
const apiTokenId = credentials.auth
|
|
124
|
+
const { apiTokenId } = credentials.auth;
|
|
125
125
|
|
|
126
126
|
if (!apiTokenId) {
|
|
127
127
|
throw boom.forbidden(`Your token is invalid`);
|
package/plugins/auth/token.js
CHANGED
|
@@ -29,13 +29,13 @@ module.exports = () => ({
|
|
|
29
29
|
},
|
|
30
30
|
handler: async (request, h) => {
|
|
31
31
|
let profile = request.auth.credentials;
|
|
32
|
-
const { scope, token, username } = profile;
|
|
32
|
+
const { scope, token, username, permission = 'all' } = profile;
|
|
33
33
|
const { buildFactory, jobFactory, pipelineFactory } = request.server.app;
|
|
34
34
|
|
|
35
35
|
// Check Build ID impersonate
|
|
36
36
|
if (request.params.buildId) {
|
|
37
|
-
if (!scope.includes('admin')) {
|
|
38
|
-
return boom.forbidden(`User ${username}
|
|
37
|
+
if (!scope.includes('admin') || permission !== 'all') {
|
|
38
|
+
return boom.forbidden(`User ${username} must be an admin with all permission to impersonate`);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const build = await buildFactory.get(request.params.buildId);
|
|
@@ -15,6 +15,11 @@ module.exports = () => ({
|
|
|
15
15
|
strategies: ['token'],
|
|
16
16
|
scope: ['user', '!guest']
|
|
17
17
|
},
|
|
18
|
+
plugins: {
|
|
19
|
+
authorization: {
|
|
20
|
+
permission: 'all'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
18
23
|
|
|
19
24
|
handler: async (request, h) => {
|
|
20
25
|
const { buildClusterFactory, bannerFactory } = request.server.app;
|
|
@@ -16,6 +16,11 @@ module.exports = () => ({
|
|
|
16
16
|
strategies: ['token'],
|
|
17
17
|
scope: ['user', '!guest']
|
|
18
18
|
},
|
|
19
|
+
plugins: {
|
|
20
|
+
authorization: {
|
|
21
|
+
permission: 'all'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
19
24
|
|
|
20
25
|
handler: async (request, h) => {
|
|
21
26
|
const { buildClusterFactory, userFactory, bannerFactory } = request.server.app;
|
|
@@ -16,6 +16,11 @@ module.exports = () => ({
|
|
|
16
16
|
strategies: ['token'],
|
|
17
17
|
scope: ['user', '!guest']
|
|
18
18
|
},
|
|
19
|
+
plugins: {
|
|
20
|
+
authorization: {
|
|
21
|
+
permission: 'all'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
19
24
|
|
|
20
25
|
handler: async (request, h) => {
|
|
21
26
|
const { buildClusterFactory, bannerFactory } = request.server.app;
|
|
@@ -28,6 +28,11 @@ module.exports = config => ({
|
|
|
28
28
|
strategies: ['session', 'token'],
|
|
29
29
|
scope: ['user', 'build', 'pipeline']
|
|
30
30
|
},
|
|
31
|
+
plugins: {
|
|
32
|
+
authorization: {
|
|
33
|
+
permission: 'read'
|
|
34
|
+
}
|
|
35
|
+
},
|
|
31
36
|
|
|
32
37
|
handler: async (req, h) => {
|
|
33
38
|
const { name: artifact, id: buildId } = req.params;
|
package/plugins/builds/create.js
CHANGED
package/plugins/builds/get.js
CHANGED
|
@@ -17,6 +17,11 @@ module.exports = () => ({
|
|
|
17
17
|
strategies: ['token'],
|
|
18
18
|
scope: ['user', 'build', '!guest']
|
|
19
19
|
},
|
|
20
|
+
plugins: {
|
|
21
|
+
authorization: {
|
|
22
|
+
permission: 'read'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
|
|
21
26
|
handler: async (request, h) => {
|
|
22
27
|
const factory = request.server.app.buildFactory;
|
|
@@ -19,6 +19,11 @@ module.exports = () => ({
|
|
|
19
19
|
strategies: ['token'],
|
|
20
20
|
scope: ['user', '!guest', 'build']
|
|
21
21
|
},
|
|
22
|
+
plugins: {
|
|
23
|
+
authorization: {
|
|
24
|
+
permission: 'read'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
22
27
|
|
|
23
28
|
handler: async (request, h) => {
|
|
24
29
|
const factory = request.server.app.buildFactory;
|
|
@@ -17,6 +17,11 @@ module.exports = () => ({
|
|
|
17
17
|
strategies: ['token'],
|
|
18
18
|
scope: ['user', 'build', 'pipeline', '!guest', 'temporal']
|
|
19
19
|
},
|
|
20
|
+
plugins: {
|
|
21
|
+
authorization: {
|
|
22
|
+
permission: 'read'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
|
|
21
26
|
handler: async (request, h) => {
|
|
22
27
|
const { stepFactory } = request.server.app;
|
|
@@ -289,6 +289,11 @@ module.exports = config => ({
|
|
|
289
289
|
strategies: ['token', 'session'],
|
|
290
290
|
scope: ['user', 'pipeline', 'build']
|
|
291
291
|
},
|
|
292
|
+
plugins: {
|
|
293
|
+
authorization: {
|
|
294
|
+
permission: 'read'
|
|
295
|
+
}
|
|
296
|
+
},
|
|
292
297
|
|
|
293
298
|
handler: (req, h) => {
|
|
294
299
|
const { credentials } = req.auth;
|
package/plugins/builds/update.js
CHANGED
|
@@ -90,6 +90,11 @@ module.exports = () => ({
|
|
|
90
90
|
strategies: ['token'],
|
|
91
91
|
scope: ['build', 'pipeline', 'user', '!guest', 'temporal']
|
|
92
92
|
},
|
|
93
|
+
plugins: {
|
|
94
|
+
authorization: {
|
|
95
|
+
permission: 'execute'
|
|
96
|
+
}
|
|
97
|
+
},
|
|
93
98
|
|
|
94
99
|
handler: async (request, h) => {
|
|
95
100
|
const { buildFactory } = request.server.app;
|
package/plugins/coverage/info.js
CHANGED
|
@@ -11,6 +11,11 @@ module.exports = config => ({
|
|
|
11
11
|
strategies: ['token'],
|
|
12
12
|
scope: ['user', 'build']
|
|
13
13
|
},
|
|
14
|
+
plugins: {
|
|
15
|
+
authorization: {
|
|
16
|
+
permission: 'read'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
14
19
|
|
|
15
20
|
handler: async (request, h) => {
|
|
16
21
|
const data = await config.coveragePlugin.getInfo(request.query);
|
package/plugins/isAdmin.js
CHANGED
|
@@ -17,6 +17,11 @@ module.exports = () => ({
|
|
|
17
17
|
strategies: ['token'],
|
|
18
18
|
scope: ['user', '!guest']
|
|
19
19
|
},
|
|
20
|
+
plugins: {
|
|
21
|
+
authorization: {
|
|
22
|
+
permission: 'all'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
|
|
21
26
|
handler: async (request, h) => {
|
|
22
27
|
const { jobFactory, bannerFactory, userFactory, pipelineFactory } = request.server.app;
|
|
@@ -17,6 +17,11 @@ module.exports = () => ({
|
|
|
17
17
|
strategies: ['token'],
|
|
18
18
|
scope: ['user', '!guest']
|
|
19
19
|
},
|
|
20
|
+
plugins: {
|
|
21
|
+
authorization: {
|
|
22
|
+
permission: 'all'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
handler: async (request, h) => {
|
|
21
26
|
const adminAnnotation = 'screwdriver.cd/sdAdminBuildClusterOverride';
|
|
22
27
|
const { payload } = request;
|
package/plugins/jobs/get.js
CHANGED
|
@@ -17,6 +17,11 @@ module.exports = () => ({
|
|
|
17
17
|
strategies: ['token'],
|
|
18
18
|
scope: ['user', 'build', 'pipeline']
|
|
19
19
|
},
|
|
20
|
+
plugins: {
|
|
21
|
+
authorization: {
|
|
22
|
+
permission: 'read'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
|
|
21
26
|
handler: async (request, h) => {
|
|
22
27
|
const factory = request.server.app.jobFactory;
|
|
@@ -16,6 +16,11 @@ module.exports = () => ({
|
|
|
16
16
|
strategies: ['token'],
|
|
17
17
|
scope: ['user', 'build', 'pipeline']
|
|
18
18
|
},
|
|
19
|
+
plugins: {
|
|
20
|
+
authorization: {
|
|
21
|
+
permission: 'read'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
19
24
|
|
|
20
25
|
handler: async (request, h) => {
|
|
21
26
|
const factory = request.server.app.jobFactory;
|
|
@@ -18,6 +18,11 @@ module.exports = () => ({
|
|
|
18
18
|
strategies: ['token'],
|
|
19
19
|
scope: ['user', 'pipeline', 'build']
|
|
20
20
|
},
|
|
21
|
+
plugins: {
|
|
22
|
+
authorization: {
|
|
23
|
+
permission: 'read'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
21
26
|
|
|
22
27
|
handler: async (request, h) => {
|
|
23
28
|
const factory = request.server.app.jobFactory;
|
package/plugins/jobs/metrics.js
CHANGED
|
@@ -19,6 +19,11 @@ module.exports = () => ({
|
|
|
19
19
|
strategies: ['token'],
|
|
20
20
|
scope: ['user', '!guest', 'pipeline']
|
|
21
21
|
},
|
|
22
|
+
plugins: {
|
|
23
|
+
authorization: {
|
|
24
|
+
permission: 'read'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
22
27
|
|
|
23
28
|
handler: async (request, h) => {
|
|
24
29
|
const factory = request.server.app.jobFactory;
|
package/plugins/jobs/notify.js
CHANGED
package/plugins/jobs/update.js
CHANGED
|
@@ -17,6 +17,11 @@ module.exports = () => ({
|
|
|
17
17
|
strategies: ['token'],
|
|
18
18
|
scope: ['user', '!guest', 'pipeline']
|
|
19
19
|
},
|
|
20
|
+
plugins: {
|
|
21
|
+
authorization: {
|
|
22
|
+
permission: 'write'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
|
|
21
26
|
handler: async (request, h) => {
|
|
22
27
|
const { jobFactory, pipelineFactory, userFactory, bannerFactory } = request.server.app;
|
|
@@ -22,24 +22,24 @@ module.exports = config => ({
|
|
|
22
22
|
const { pipelineFactory, eventFactory } = request.server.app;
|
|
23
23
|
const pipelineId = request.params.id;
|
|
24
24
|
const { statusColor } = config;
|
|
25
|
-
const badgeConfig = {
|
|
26
|
-
statusColor
|
|
27
|
-
};
|
|
28
25
|
const contentType = 'image/svg+xml;charset=utf-8';
|
|
26
|
+
let label;
|
|
29
27
|
|
|
30
28
|
try {
|
|
31
29
|
// Get pipeline
|
|
32
30
|
const pipeline = await pipelineFactory.get(pipelineId);
|
|
33
31
|
|
|
34
32
|
if (!pipeline) {
|
|
35
|
-
return h.response(getPipelineBadge(
|
|
33
|
+
return h.response(getPipelineBadge({ statusColor })).header('Content-Type', contentType);
|
|
36
34
|
}
|
|
37
35
|
|
|
36
|
+
label = pipeline.name;
|
|
37
|
+
|
|
38
38
|
// Get latest pipeline events
|
|
39
39
|
const latestEvents = await eventFactory.getPipelineTypeBuildEvents(pipelineId);
|
|
40
40
|
|
|
41
41
|
if (!latestEvents || Object.keys(latestEvents).length === 0) {
|
|
42
|
-
return h.response(getPipelineBadge(
|
|
42
|
+
return h.response(getPipelineBadge({ statusColor, label })).header('Content-Type', contentType);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Only care about latest
|
|
@@ -47,26 +47,19 @@ module.exports = config => ({
|
|
|
47
47
|
const builds = await lastEvent.getBuilds({ readOnly: true, sortBy: 'id', sort: 'descending' });
|
|
48
48
|
|
|
49
49
|
if (!builds || builds.length < 1) {
|
|
50
|
-
return h.response(getPipelineBadge(
|
|
50
|
+
return h.response(getPipelineBadge({ statusColor, label })).header('Content-Type', contentType);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// Convert build statuses
|
|
54
54
|
const buildsStatus = builds.map(build => build.status.toLowerCase());
|
|
55
55
|
|
|
56
56
|
return h
|
|
57
|
-
.response(
|
|
58
|
-
getPipelineBadge(
|
|
59
|
-
Object.assign(badgeConfig, {
|
|
60
|
-
buildsStatus,
|
|
61
|
-
label: pipeline.name
|
|
62
|
-
})
|
|
63
|
-
)
|
|
64
|
-
)
|
|
57
|
+
.response(getPipelineBadge({ statusColor, label, buildsStatus }))
|
|
65
58
|
.header('Content-Type', contentType);
|
|
66
59
|
} catch (err) {
|
|
67
60
|
logger.error(`Failed to get badge for pipeline:${pipelineId}: ${err.message}`);
|
|
68
61
|
|
|
69
|
-
return h.response(getPipelineBadge(
|
|
62
|
+
return h.response(getPipelineBadge({ statusColor, label }));
|
|
70
63
|
}
|
|
71
64
|
},
|
|
72
65
|
validate: {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const joi = require('joi');
|
|
4
4
|
const schema = require('screwdriver-data-schema');
|
|
5
5
|
const idSchema = schema.models.pipeline.base.extract('id');
|
|
6
|
+
const logger = require('screwdriver-logger');
|
|
6
7
|
const { getJobBadge } = require('./helper');
|
|
7
8
|
|
|
8
9
|
module.exports = config => ({
|
|
@@ -22,61 +23,55 @@ module.exports = config => ({
|
|
|
22
23
|
const { pipelineFactory } = request.server.app;
|
|
23
24
|
const { id, jobName } = request.params;
|
|
24
25
|
const { statusColor } = config;
|
|
25
|
-
const badgeConfig = {
|
|
26
|
-
statusColor
|
|
27
|
-
};
|
|
28
26
|
const contentType = 'image/svg+xml;charset=utf-8';
|
|
27
|
+
let label;
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
29
|
+
try {
|
|
30
|
+
const [job, pipeline] = await Promise.all([
|
|
31
|
+
jobFactory.get({
|
|
32
|
+
pipelineId: id,
|
|
33
|
+
name: jobName
|
|
34
|
+
}),
|
|
35
|
+
pipelineFactory.get(id)
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
if (!pipeline) {
|
|
39
|
+
return h.response(getJobBadge({ statusColor })).header('Content-Type', contentType);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
label = pipeline.name;
|
|
43
|
+
|
|
44
|
+
if (!job) {
|
|
45
|
+
return h.response(getJobBadge({ statusColor, label })).header('Content-Type', contentType);
|
|
46
|
+
}
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
label = `${pipeline.name}:${jobName}`;
|
|
49
|
+
|
|
50
|
+
if (job.state === 'DISABLED') {
|
|
51
|
+
return h
|
|
52
|
+
.response(
|
|
53
|
+
getJobBadge({
|
|
54
|
+
statusColor,
|
|
55
|
+
label,
|
|
56
|
+
builds: [{ status: 'DISABLED' }]
|
|
57
|
+
})
|
|
58
|
+
)
|
|
59
|
+
.header('Content-Type', contentType);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const builds = await job.getBuilds({
|
|
63
|
+
paginate: {
|
|
64
|
+
page: 1,
|
|
65
|
+
count: 1
|
|
57
66
|
}
|
|
67
|
+
});
|
|
58
68
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
count: 1
|
|
63
|
-
}
|
|
64
|
-
};
|
|
69
|
+
return h.response(getJobBadge({ statusColor, label, builds })).header('Content-Type', contentType);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
logger.error(`Failed to get job badge for pipeline:${id}, job:${jobName}: ${err.message}`);
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.response(
|
|
69
|
-
getJobBadge(
|
|
70
|
-
Object.assign(badgeConfig, {
|
|
71
|
-
builds,
|
|
72
|
-
label: `${pipeline.name}:${jobName}`
|
|
73
|
-
})
|
|
74
|
-
)
|
|
75
|
-
)
|
|
76
|
-
.header('Content-Type', contentType);
|
|
77
|
-
});
|
|
78
|
-
})
|
|
79
|
-
.catch(() => h.response(getJobBadge(badgeConfig)));
|
|
73
|
+
return h.response(getJobBadge({ statusColor, label })).header('Content-Type', contentType);
|
|
74
|
+
}
|
|
80
75
|
},
|
|
81
76
|
validate: {
|
|
82
77
|
params: joi.object({
|
|
@@ -17,6 +17,11 @@ module.exports = () => ({
|
|
|
17
17
|
strategies: ['token'],
|
|
18
18
|
scope: ['user', '!guest', 'pipeline']
|
|
19
19
|
},
|
|
20
|
+
plugins: {
|
|
21
|
+
authorization: {
|
|
22
|
+
permission: 'all'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
|
|
21
26
|
handler: async (request, h) => {
|
|
22
27
|
const { pipelineFactory, secretFactory, userFactory } = request.server.app;
|
package/plugins/secrets/get.js
CHANGED
|
@@ -17,6 +17,11 @@ module.exports = () => ({
|
|
|
17
17
|
strategies: ['token'],
|
|
18
18
|
scope: ['user', '!guest', 'pipeline']
|
|
19
19
|
},
|
|
20
|
+
plugins: {
|
|
21
|
+
authorization: {
|
|
22
|
+
permission: 'all'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
|
|
21
26
|
handler: async (request, h) => {
|
|
22
27
|
const factory = request.server.app.secretFactory;
|
package/plugins/stages/get.js
CHANGED
|
@@ -18,6 +18,11 @@ module.exports = () => ({
|
|
|
18
18
|
strategies: ['token'],
|
|
19
19
|
scope: ['user', '!guest']
|
|
20
20
|
},
|
|
21
|
+
plugins: {
|
|
22
|
+
authorization: {
|
|
23
|
+
permission: 'read'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
21
26
|
|
|
22
27
|
handler: async (request, h) => {
|
|
23
28
|
const { stageFactory, stageBuildFactory } = request.server.app;
|
package/plugins/tokens/create.js
CHANGED
package/plugins/tokens/list.js
CHANGED
package/plugins/tokens/remove.js
CHANGED
package/plugins/tokens/update.js
CHANGED