screwdriver-api 8.0.19 → 8.0.20

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.19",
3
+ "version": "8.0.20",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -124,8 +124,9 @@ module.exports = () => ({
124
124
 
125
125
  if (!pipeline) {
126
126
  throw boom.notFound();
127
- } else if (pipeline.state === 'INACTIVE') {
128
- throw boom.badRequest('Cannot create an event for an inactive pipeline');
127
+ } else if (pipeline.state !== 'ACTIVE') {
128
+ // INACTIVE or DELETING pipeline
129
+ throw boom.badRequest(`Cannot create an event for a(n) ${pipeline.state} pipeline`);
129
130
  }
130
131
 
131
132
  payload.scmContext = pipeline.scmContext;
@@ -29,6 +29,9 @@ module.exports = () => ({
29
29
  if (!pipeline) {
30
30
  throw boom.notFound('Pipeline does not exist');
31
31
  }
32
+ if (pipeline.state === 'DELETING') {
33
+ throw boom.conflict('This pipeline is already being deleted.');
34
+ }
32
35
  if (pipeline.configPipelineId && pipeline.state !== 'INACTIVE') {
33
36
  throw boom.forbidden(
34
37
  'Child pipeline can only be removed' +
@@ -38,6 +38,9 @@ module.exports = () => ({
38
38
  if (!pipeline) {
39
39
  throw boom.notFound('Pipeline does not exist');
40
40
  }
41
+ if (pipeline.state === 'DELETING') {
42
+ throw boom.conflict('This pipeline is being deleted.');
43
+ }
41
44
  if (!user) {
42
45
  throw boom.notFound(`User ${username} does not exist`);
43
46
  }
@@ -32,6 +32,9 @@ module.exports = () => ({
32
32
  if (!pipeline) {
33
33
  throw boom.notFound('Pipeline does not exist');
34
34
  }
35
+ if (pipeline.state === 'DELETING') {
36
+ throw boom.conflict('This pipeline is being deleted.');
37
+ }
35
38
  if (!user) {
36
39
  throw boom.notFound(`User ${username} does not exist`);
37
40
  }
@@ -32,6 +32,9 @@ module.exports = () => ({
32
32
  if (!pipeline) {
33
33
  throw boom.notFound('Pipeline does not exist');
34
34
  }
35
+ if (pipeline.state === 'DELETING') {
36
+ throw boom.conflict('This pipeline is being deleted.');
37
+ }
35
38
  if (!user) {
36
39
  throw boom.notFound(`User ${username} does not exist`);
37
40
  }
@@ -35,6 +35,10 @@ module.exports = () => ({
35
35
  throw boom.notFound('Pipeline does not exist');
36
36
  }
37
37
 
38
+ if (pipeline.state === 'DELETING') {
39
+ throw boom.conflict('This pipeline is being deleted.');
40
+ }
41
+
38
42
  if (!user) {
39
43
  throw boom.notFound(`User ${username} does not exist`);
40
44
  }
@@ -39,6 +39,10 @@ module.exports = () => ({
39
39
  throw boom.notFound('Pipeline does not exist');
40
40
  }
41
41
 
42
+ if (pipeline.state === 'DELETING') {
43
+ throw boom.conflict('This pipeline is being deleted.');
44
+ }
45
+
42
46
  if (!user) {
43
47
  throw boom.notFound('User does not exist');
44
48
  }
@@ -73,6 +73,9 @@ module.exports = () => ({
73
73
  if (!oldPipeline) {
74
74
  throw boom.notFound(`Pipeline ${id} does not exist`);
75
75
  }
76
+ if (oldPipeline.state === 'DELETING') {
77
+ throw boom.conflict('This pipeline is being deleted.');
78
+ }
76
79
 
77
80
  // for mysql backward compatibility
78
81
  if (!oldPipeline.adminUserIds) {
@@ -45,11 +45,14 @@ module.exports = () => ({
45
45
 
46
46
  const { id } = request.params;
47
47
  const pipeline = await pipelineFactory.get({ id });
48
- // check if pipeline exists
49
48
 
49
+ // check if pipeline exists
50
50
  if (!pipeline) {
51
51
  throw boom.notFound(`Pipeline ${id} does not exist`);
52
52
  }
53
+ if (pipeline.state === 'DELETING') {
54
+ throw boom.conflict('This pipeline is being deleted.');
55
+ }
53
56
 
54
57
  const pipelineConfig = await pipeline.getConfiguration({});
55
58
  // check if pipeline has buildCluster annotation
@@ -29,6 +29,10 @@ module.exports = () => ({
29
29
  throw boom.notFound(`Pipeline ${request.payload.pipelineId} does not exist`);
30
30
  }
31
31
 
32
+ if (pipeline.state === 'DELETING') {
33
+ throw boom.conflict('This pipeline is being deleted.');
34
+ }
35
+
32
36
  // In pipeline scope, check if the token is allowed to the pipeline
33
37
  if (!isValidToken(pipeline.id, request.auth.credentials)) {
34
38
  throw boom.forbidden('Token does not have permission to this pipeline');