screwdriver-data-schema 21.8.2 → 21.10.1

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/api/validator.js CHANGED
@@ -33,6 +33,8 @@ const SCHEMA_JOB_PERMUTATION = Joi.object()
33
33
  freezeWindows: Job.freezeWindows,
34
34
  image: Job.image,
35
35
  order: Job.order,
36
+ parameters: Job.parameters,
37
+ provider: Job.provider,
36
38
  requires: Job.requires,
37
39
  secrets: Job.secrets,
38
40
  settings: Job.settings,
@@ -62,7 +64,7 @@ const SCHEMA_OUTPUT = Joi.object()
62
64
  jobs: SCHEMA_JOBS,
63
65
  childPipelines: Base.childPipelines,
64
66
  workflowGraph: WorkflowGraph.workflowGraph,
65
- parameters: Parameters.parameters,
67
+ parameters: Parameters.parameters.default({}),
66
68
  warnMessages: Joi.array().optional(),
67
69
  subscribe: Base.subscribe
68
70
  })
package/config/base.js CHANGED
@@ -60,7 +60,7 @@ const SCHEMA_CONFIG = Joi.object()
60
60
  cache: SCHEMA_CACHE,
61
61
  childPipelines: SCHEMA_CHILD_PIPELINES,
62
62
  subscribe: SCHEMA_SUBSCRIBE,
63
- parameters: Parameters.parameters
63
+ parameters: Parameters.parameters.default({})
64
64
  })
65
65
  .unknown(false);
66
66
 
package/config/job.js CHANGED
@@ -4,6 +4,8 @@ const Joi = require('joi');
4
4
  const Annotations = require('./annotations');
5
5
  const Regex = require('./regex');
6
6
  const sdCron = require('./cronExpression');
7
+ const Parameters = require('./parameters');
8
+ const Provider = require('./provider');
7
9
 
8
10
  const SPECIFIC_BRANCH_POS = 4;
9
11
 
@@ -166,6 +168,8 @@ const SCHEMA_SOURCEPATH = Joi.string()
166
168
  .optional();
167
169
  const SCHEMA_SOURCEPATHS = Joi.alternatives().try(Joi.array().items(SCHEMA_SOURCEPATH), SCHEMA_SOURCEPATH);
168
170
  const SCHEMA_CACHE = Joi.boolean().optional();
171
+ const SCHEMA_PARAMETERS = Parameters.parameters.optional();
172
+ const SCHEMA_PROVIDER = Provider.provider.optional();
169
173
  const SCHEMA_JOB = Joi.object()
170
174
  .keys({
171
175
  annotations: Annotations.annotations,
@@ -177,6 +181,8 @@ const SCHEMA_JOB = Joi.object()
177
181
  image: SCHEMA_IMAGE,
178
182
  matrix: SCHEMA_MATRIX,
179
183
  order: SCHEMA_ORDER,
184
+ parameters: SCHEMA_PARAMETERS,
185
+ provider: SCHEMA_PROVIDER,
180
186
  requires: SCHEMA_REQUIRES,
181
187
  secrets: SCHEMA_SECRETS,
182
188
  settings: SCHEMA_SETTINGS,
@@ -211,6 +217,8 @@ module.exports = {
211
217
  jobNoDupSteps: SCHEMA_JOB_NO_DUP_STEPS,
212
218
  matrix: SCHEMA_MATRIX,
213
219
  order: SCHEMA_ORDER,
220
+ parameters: SCHEMA_PARAMETERS,
221
+ provider: SCHEMA_PROVIDER,
214
222
  requires: SCHEMA_REQUIRES,
215
223
  requiresValue: SCHEMA_REQUIRES_VALUE,
216
224
  secret: SCHEMA_SECRET,
@@ -12,16 +12,14 @@ const SCHEMA_PARAMETERS_OBJECT = Joi.object({
12
12
  'object.unknown': 'only supports string or key: {{#label}} pair as values'
13
13
  });
14
14
 
15
- const SCHEMA_PARAMETERS = Joi.object()
16
- .pattern(
17
- Joi.any(),
18
- Joi.alternatives().try(
19
- SCHEMA_PARAMETERS_STRING,
20
- Joi.array().items(SCHEMA_PARAMETERS_STRING),
21
- SCHEMA_PARAMETERS_OBJECT
22
- )
15
+ const SCHEMA_PARAMETERS = Joi.object().pattern(
16
+ Joi.any(),
17
+ Joi.alternatives().try(
18
+ SCHEMA_PARAMETERS_STRING,
19
+ Joi.array().items(SCHEMA_PARAMETERS_STRING),
20
+ SCHEMA_PARAMETERS_OBJECT
23
21
  )
24
- .default({});
22
+ );
25
23
 
26
24
  module.exports = {
27
25
  parameters: SCHEMA_PARAMETERS
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ const Joi = require('joi');
4
+ const Regex = require('./regex');
5
+
6
+ const SCHEMA_VPC_OBJECT = Joi.object({
7
+ vpcId: Joi.string()
8
+ .regex(Regex.VPC_ID)
9
+ .max(128)
10
+ .description('VPC ID')
11
+ .example('vpc-1a2b3c4d')
12
+ .required(),
13
+ securityGroupIds: Joi.array()
14
+ .items(
15
+ Joi.string()
16
+ .regex(Regex.SECURITY_GROUP_ID)
17
+ .max(128)
18
+ .description('Security group ID')
19
+ .example('sg-51530134')
20
+ )
21
+ .min(1)
22
+ .label('List of security group IDs')
23
+ .required(),
24
+ subnetIds: Joi.array()
25
+ .items(
26
+ Joi.string()
27
+ .regex(Regex.SUBNET_ID)
28
+ .max(128)
29
+ .description('Subnet ID')
30
+ .example('subnet-01234567890abcdef')
31
+ )
32
+ .min(1)
33
+ .label('List of subnet IDs')
34
+ .required()
35
+ });
36
+
37
+ const SCHEMA_PROVIDER = Joi.object().keys({
38
+ name: Joi.string()
39
+ .valid('aws')
40
+ .max(64)
41
+ .description('Provider name')
42
+ .example('aws'),
43
+ region: Joi.string()
44
+ .regex(Regex.REGION)
45
+ .max(64)
46
+ .description('Region')
47
+ .example('us-west-2'),
48
+ accountId: Joi.alternatives()
49
+ .try(
50
+ Joi.string()
51
+ .regex(Regex.ACCOUNT_ID)
52
+ .max(12),
53
+ Joi.number()
54
+ .integer()
55
+ .min(12)
56
+ )
57
+ .description('Account ID')
58
+ .example('123456789012'),
59
+ vpc: SCHEMA_VPC_OBJECT.optional(),
60
+ role: Joi.string()
61
+ .regex(Regex.ROLE_ARN)
62
+ .max(512)
63
+ .description('Role ARN')
64
+ .example('arn:aws:iam::123456789012:role/aws-service-role/amazonaws.com/AWSServiceRole'),
65
+ executor: Joi.string()
66
+ .valid('sls', 'eks')
67
+ .max(64)
68
+ .description('Executor name')
69
+ .example('eks'),
70
+ clusterName: Joi.string()
71
+ .max(128)
72
+ .description('Cluster name')
73
+ .example('sd-build-eks')
74
+ });
75
+
76
+ module.exports = {
77
+ provider: SCHEMA_PROVIDER
78
+ };
package/config/regex.js CHANGED
@@ -96,5 +96,18 @@ module.exports = {
96
96
  // Image aliases can only contain A-Z,a-z,0-9,-,_
97
97
  IMAGE_ALIAS: /^[\w-]+$/,
98
98
  // Valid Events for webhook
99
- WEBHOOK_EVENT: /^~([\w-]+)$/
99
+ WEBHOOK_EVENT: /^~([\w-]+)$/,
100
+ // Provider region. e.g. us-west-1, ap-northeast-2
101
+ REGION: /^(us(-gov)?|ap|ca|cn|eu|sa|me)-(central|(north|south)?(east|west)?)-\d$/,
102
+ // Provider account ID. Can be A-Z,a-z,0-9,_,-
103
+ // https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html
104
+ ACCOUNT_ID: /^[0-9]{12}$/,
105
+ // Provider VPC ID. Can be vpc-xxxxxx, with A-Z,a-z,0-9,_
106
+ VPC_ID: /^vpc-[\w]+$/,
107
+ // Provider Security group ID. Can be sg-xxxxxx, with A-Z,a-z,0-9,_
108
+ SECURITY_GROUP_ID: /^sg-[\w]+$/,
109
+ // Provider Subnet ID. Can be subnet-xxxxxx, with A-Z,a-z,0-9,_
110
+ SUBNET_ID: /^subnet-[\w]+$/,
111
+ // Provider Role. Can be arn:aws:iam::xxxxxx:role/some-role
112
+ ROLE_ARN: /^arn:aws:iam::\d{12}:role\/.+/
100
113
  };
@@ -0,0 +1,17 @@
1
+ /* eslint-disable new-cap */
2
+
3
+ 'use strict';
4
+
5
+ const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
6
+ const table = `${prefix}triggers`;
7
+
8
+ module.exports = {
9
+ up: async (queryInterface, Sequelize) => {
10
+ await queryInterface.sequelize.transaction(async transaction => {
11
+ await queryInterface.changeColumn(table, 'src', Sequelize.STRING(128), { transaction });
12
+ });
13
+ await queryInterface.sequelize.transaction(async transaction => {
14
+ await queryInterface.changeColumn(table, 'dest', Sequelize.STRING(128), { transaction });
15
+ });
16
+ }
17
+ };
@@ -81,7 +81,7 @@ const MODEL = {
81
81
  // in order to convert the `prChain` to `chainPR`.
82
82
  prChain: Base.prChain.description('Configuration of chainPR'),
83
83
 
84
- parameters: Parameters.parameters,
84
+ parameters: Parameters.parameters.default({}),
85
85
 
86
86
  settings: Settings.pipelineSettings,
87
87
 
package/models/trigger.js CHANGED
@@ -13,10 +13,10 @@ const MODEL = {
13
13
  .try(
14
14
  Joi.string()
15
15
  .regex(Regex.EXTERNAL_TRIGGER)
16
- .max(64),
16
+ .max(128),
17
17
  Joi.string()
18
18
  .regex(Regex.EXTERNAL_TRIGGER_AND)
19
- .max(64)
19
+ .max(128)
20
20
  )
21
21
  .example('~sd@1234:component'),
22
22
 
@@ -24,10 +24,10 @@ const MODEL = {
24
24
  .try(
25
25
  Joi.string()
26
26
  .regex(Regex.EXTERNAL_TRIGGER)
27
- .max(64),
27
+ .max(128),
28
28
  Joi.string()
29
29
  .regex(Regex.EXTERNAL_TRIGGER_AND)
30
- .max(64)
30
+ .max(128)
31
31
  )
32
32
  .example('~sd@5678:test')
33
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-data-schema",
3
- "version": "21.8.2",
3
+ "version": "21.10.1",
4
4
  "description": "Internal Data Schema of Screwdriver",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "chai": "^4.2.0",
43
- "eslint": "^7.5.0",
43
+ "eslint": "^7.32.0",
44
44
  "eslint-config-screwdriver": "^5.0.1",
45
45
  "js-yaml": "^3.14.1",
46
46
  "mocha": "^8.4.0",
@@ -55,6 +55,6 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "cron-parser": "^2.18.0",
58
- "joi": "^17.4.0"
58
+ "joi": "^17.4.2"
59
59
  }
60
60
  }
@@ -26,6 +26,7 @@ const buildSchemaObj = {
26
26
  jobName,
27
27
  jobState,
28
28
  jobArchived,
29
+ provider: Job.provider,
29
30
  annotations: Annotations.annotations,
30
31
  blockedBy: Joi.array().items(jobId),
31
32
  freezeWindows: Job.freezeWindows,
@@ -61,7 +62,8 @@ const SCHEMA_STOP = Joi.object()
61
62
  buildClusterName: models.buildCluster.base.extract('name'),
62
63
  jobId,
63
64
  token: Joi.string().label('Build JWT'),
64
- pipelineId
65
+ pipelineId,
66
+ provider: Job.provider
65
67
  })
66
68
  .required();
67
69
  const SCHEMA_STATUS = Joi.object()
@@ -69,7 +71,8 @@ const SCHEMA_STATUS = Joi.object()
69
71
  buildId,
70
72
  token: Joi.string().label('Build JWT'),
71
73
  pipelineId,
72
- jobId
74
+ jobId,
75
+ provider: Job.provider
73
76
  })
74
77
  .required();
75
78
  const SCHEMA_VERIFY = Joi.object()