screwdriver-api 8.0.11 → 8.0.13

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "8.0.11",
3
+ "version": "8.0.13",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -111,7 +111,7 @@
111
111
  "screwdriver-config-parser": "^12.0.0",
112
112
  "screwdriver-coverage-bookend": "^3.0.0",
113
113
  "screwdriver-coverage-sonar": "^5.0.0",
114
- "screwdriver-data-schema": "^25.1.3",
114
+ "screwdriver-data-schema": "^25.2.0",
115
115
  "screwdriver-datastore-sequelize": "^10.0.0",
116
116
  "screwdriver-executor-base": "^11.0.0",
117
117
  "screwdriver-executor-docker": "^8.0.1",
@@ -18,15 +18,18 @@ const ANNOTATION_USE_DEPLOY_KEY = 'screwdriver.cd/useDeployKey';
18
18
  * @return {Promise}
19
19
  */
20
20
  function getPermissionsForOldPipeline({ scmContexts, pipeline, user }) {
21
+ const isPipelineSCMContextObsolete = !scmContexts.includes(pipeline.scmContext);
22
+ const isUserFromAnotherSCMContext = user.scmContext !== pipeline.scmContext;
23
+
21
24
  // this pipeline's scmContext has been removed, allow current admin to change it
22
- if (!scmContexts.includes(pipeline.scmContext)) {
23
- const permission = { admin: false };
25
+ // also allow pipeline admins from other scmContexts to change it
26
+ if (isPipelineSCMContextObsolete || isUserFromAnotherSCMContext) {
27
+ const isUserIdInAdminList = pipeline.adminUserIds.includes(user.id);
28
+ const isSCMUsernameInAdminsObject = !!pipeline.admins[user.username];
24
29
 
25
- if (pipeline.admins[user.username]) {
26
- permission.admin = true;
27
- }
30
+ const isAdmin = isUserIdInAdminList || (isPipelineSCMContextObsolete && isSCMUsernameInAdminsObject);
28
31
 
29
- return Promise.resolve(permission);
32
+ return Promise.resolve({ admin: isAdmin });
30
33
  }
31
34
 
32
35
  return user.getPermissions(pipeline.scmUri);
@@ -136,6 +139,10 @@ module.exports = () => ({
136
139
  [username]: true
137
140
  };
138
141
 
142
+ if (!oldPipeline.adminUserIds.includes(user.id)) {
143
+ oldPipeline.adminUserIds.push(user.id);
144
+ }
145
+
139
146
  if (settings) {
140
147
  oldPipeline.settings = { ...oldPipeline.settings, ...settings };
141
148
  }