screwdriver-api 8.0.15 → 8.0.16
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
package/plugins/builds/create.js
CHANGED
|
@@ -64,8 +64,13 @@ module.exports = () => ({
|
|
|
64
64
|
const newAdmins = pipeline.admins;
|
|
65
65
|
|
|
66
66
|
delete newAdmins[username];
|
|
67
|
+
const newAdminUserIds = pipeline.adminUserIds.filter(
|
|
68
|
+
adminUserId => adminUserId !== user.id
|
|
69
|
+
);
|
|
70
|
+
|
|
67
71
|
// This is needed to make admins dirty and update db
|
|
68
72
|
pipeline.admins = newAdmins;
|
|
73
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
69
74
|
|
|
70
75
|
return pipeline.update().then(() => {
|
|
71
76
|
throw boom.forbidden(
|
|
@@ -83,9 +88,18 @@ module.exports = () => ({
|
|
|
83
88
|
newAdmins[username] = true;
|
|
84
89
|
// This is needed to make admins dirty and update db
|
|
85
90
|
pipeline.admins = newAdmins;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const newAdminUserIds = pipeline.adminUserIds;
|
|
86
94
|
|
|
87
|
-
|
|
95
|
+
if (!newAdminUserIds.includes(user.id)) {
|
|
96
|
+
newAdminUserIds.push(user.id);
|
|
97
|
+
|
|
98
|
+
// This is needed to make admins dirty and update db
|
|
99
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
88
100
|
}
|
|
101
|
+
|
|
102
|
+
return pipeline.update();
|
|
89
103
|
})
|
|
90
104
|
// user has good permissions, sync and create a build
|
|
91
105
|
.then(() => (job.isPR() ? pipeline.syncPR(job.prNum) : pipeline.sync()))
|
package/plugins/events/create.js
CHANGED
|
@@ -152,7 +152,7 @@ module.exports = () => ({
|
|
|
152
152
|
|
|
153
153
|
// Update admins
|
|
154
154
|
if (!prNum) {
|
|
155
|
-
await updateAdmins({ permissions, pipeline,
|
|
155
|
+
await updateAdmins({ permissions, pipeline, user });
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
// Get scmConfig
|
|
@@ -201,7 +201,7 @@ module.exports = () => ({
|
|
|
201
201
|
await updateAdmins({
|
|
202
202
|
permissions,
|
|
203
203
|
pipeline,
|
|
204
|
-
|
|
204
|
+
user
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
}
|
package/plugins/events/index.js
CHANGED
|
@@ -23,17 +23,22 @@ const eventsPlugin = {
|
|
|
23
23
|
* @method updateAdmins
|
|
24
24
|
* @param {Object} permissions User permissions
|
|
25
25
|
* @param {Pipeline} pipeline Pipeline object to update
|
|
26
|
-
* @param {String}
|
|
26
|
+
* @param {String} user User object
|
|
27
27
|
* @return {Promise} Updates the pipeline admins and throws an error if not an admin
|
|
28
28
|
*/
|
|
29
|
-
server.expose('updateAdmins', ({ permissions, pipeline,
|
|
29
|
+
server.expose('updateAdmins', ({ permissions, pipeline, user }) => {
|
|
30
|
+
const { username, id: userId } = user;
|
|
31
|
+
|
|
30
32
|
// Delete user from admin list if bad permissions
|
|
31
33
|
if (!permissions.push) {
|
|
32
34
|
const newAdmins = pipeline.admins;
|
|
33
35
|
|
|
34
36
|
delete newAdmins[username];
|
|
37
|
+
const newAdminUserIds = pipeline.adminUserIds.filter(adminUserId => adminUserId !== userId);
|
|
38
|
+
|
|
35
39
|
// This is needed to make admins dirty and update db
|
|
36
40
|
pipeline.admins = newAdmins;
|
|
41
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
37
42
|
|
|
38
43
|
return pipeline.update().then(() => {
|
|
39
44
|
throw boom.forbidden(`User ${username} does not have push permission for this repo`);
|
|
@@ -49,7 +54,16 @@ const eventsPlugin = {
|
|
|
49
54
|
newAdmins[name] = true;
|
|
50
55
|
});
|
|
51
56
|
|
|
57
|
+
const newAdminUserIds = [userId];
|
|
58
|
+
|
|
59
|
+
pipeline.adminUserIds.forEach(adminUserId => {
|
|
60
|
+
if (adminUserId !== userId) {
|
|
61
|
+
newAdminUserIds.push(adminUserId);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
52
65
|
pipeline.admins = newAdmins;
|
|
66
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
53
67
|
|
|
54
68
|
return pipeline.update();
|
|
55
69
|
});
|
|
@@ -60,8 +60,11 @@ module.exports = () => ({
|
|
|
60
60
|
const newAdmins = pipeline.admins;
|
|
61
61
|
|
|
62
62
|
delete newAdmins[username];
|
|
63
|
+
const newAdminUserIds = pipeline.adminUserIds.filter(adminUserId => adminUserId !== user.id);
|
|
64
|
+
|
|
63
65
|
// This is needed to make admins dirty and update db
|
|
64
66
|
pipeline.admins = newAdmins;
|
|
67
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
65
68
|
|
|
66
69
|
await pipeline.update();
|
|
67
70
|
|
|
@@ -77,10 +80,16 @@ module.exports = () => ({
|
|
|
77
80
|
// user has good permissions, add the user as an admin
|
|
78
81
|
if (!pipeline.admins[username] && hasPushPermissions) {
|
|
79
82
|
const newAdmins = pipeline.admins;
|
|
83
|
+
const newAdminUserIds = pipeline.adminUserIds;
|
|
80
84
|
|
|
81
85
|
newAdmins[username] = true;
|
|
86
|
+
if (!newAdminUserIds.includes(user.id)) {
|
|
87
|
+
newAdminUserIds.push(user.id);
|
|
88
|
+
}
|
|
89
|
+
|
|
82
90
|
// This is needed to make admins dirty and update db
|
|
83
91
|
pipeline.admins = newAdmins;
|
|
92
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
84
93
|
|
|
85
94
|
await pipeline.update();
|
|
86
95
|
}
|
|
@@ -95,8 +95,11 @@ async function updateAdmins(userFactory, username, scmContext, pipeline, pipelin
|
|
|
95
95
|
const newAdmins = pipeline.admins;
|
|
96
96
|
|
|
97
97
|
delete newAdmins[username];
|
|
98
|
+
const newAdminUserIds = pipeline.adminUserIds.filter(adminUserId => adminUserId !== user.id);
|
|
99
|
+
|
|
98
100
|
// This is needed to make admins dirty and update db
|
|
99
101
|
pipeline.admins = newAdmins;
|
|
102
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
100
103
|
|
|
101
104
|
return pipeline.update();
|
|
102
105
|
}
|
|
@@ -110,7 +113,16 @@ async function updateAdmins(userFactory, username, scmContext, pipeline, pipelin
|
|
|
110
113
|
newAdmins[name] = true;
|
|
111
114
|
});
|
|
112
115
|
|
|
116
|
+
const newAdminUserIds = [user.id];
|
|
117
|
+
|
|
118
|
+
pipeline.adminUserIds.forEach(adminUserId => {
|
|
119
|
+
if (adminUserId !== user.id) {
|
|
120
|
+
newAdminUserIds.push(adminUserId);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
113
124
|
pipeline.admins = newAdmins;
|
|
125
|
+
pipeline.adminUserIds = newAdminUserIds;
|
|
114
126
|
|
|
115
127
|
return pipeline.update();
|
|
116
128
|
} catch (err) {
|