screwdriver-api 6.0.20 → 6.0.22

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": "6.0.20",
3
+ "version": "6.0.22",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -138,11 +138,16 @@ async function batchUpdateAdmins({ userFactory, pipelines, username, scmContext,
138
138
  function isRestrictedPR(restriction, prSource) {
139
139
  switch (restriction) {
140
140
  case 'all':
141
+ case 'all-admin':
141
142
  return true;
142
143
  case 'branch':
144
+ case 'branch-admin':
145
+ return prSource === 'branch';
143
146
  case 'fork':
144
- return prSource === restriction;
147
+ case 'fork-admin':
148
+ return prSource === 'fork';
145
149
  case 'none':
150
+ case 'none-admin':
146
151
  default:
147
152
  return false;
148
153
  }
@@ -248,10 +253,16 @@ function resolveChainPR(chainPR, pipeline) {
248
253
  */
249
254
  function getSkipMessageAndChainPR({ pipeline, prSource, restrictPR, chainPR }) {
250
255
  const defaultRestrictPR = restrictPR || 'none';
251
- const restriction = pipeline.annotations[ANNOT_RESTRICT_PR] || defaultRestrictPR;
252
256
  const result = {
253
257
  resolvedChainPR: resolveChainPR(chainPR, pipeline)
254
258
  };
259
+ let restriction;
260
+
261
+ if (['all-admin', 'none-admin', 'branch-admin', 'fork-admin'].includes(defaultRestrictPR)) {
262
+ restriction = defaultRestrictPR;
263
+ } else {
264
+ restriction = pipeline.annotations[ANNOT_RESTRICT_PR] || defaultRestrictPR;
265
+ }
255
266
 
256
267
  // Check for restriction upfront
257
268
  if (isRestrictedPR(restriction, prSource)) {
@@ -30,7 +30,10 @@ const webhooksPlugin = {
30
30
  joi.object().keys({
31
31
  username: joi.string().required(),
32
32
  ignoreCommitsBy: joi.array().items(joi.string()).optional(),
33
- restrictPR: joi.string().valid('all', 'none', 'branch', 'fork').optional(),
33
+ restrictPR: joi
34
+ .string()
35
+ .valid('all', 'none', 'branch', 'fork', 'all-admin', 'none-admin', 'branch-admin', 'fork-admin')
36
+ .optional(),
34
37
  chainPR: joi.boolean().optional(),
35
38
  maxBytes: joi.number().integer().optional()
36
39
  }),