screwdriver-data-schema 22.11.1 → 23.0.0

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/config/base.js CHANGED
@@ -63,7 +63,30 @@ const SCHEMA_SUBSCRIBE = Joi.object().keys({
63
63
  )
64
64
  });
65
65
 
66
- const SCHEMA_CONFIG = Joi.object()
66
+ const SCHEMA_CONFIG_PRE_TEMPLATE_MERGE = Joi.object()
67
+ .keys({
68
+ template: Joi.string().regex(Regex.FULL_TEMPLATE_NAME_WITH_NAMESPACE),
69
+ version: Joi.number().integer().min(1).max(50),
70
+ annotations: Annotations.annotations.when('template', { is: Joi.exist(), then: Joi.forbidden() }),
71
+ jobs: SCHEMA_JOBS.when('template', { is: Joi.exist(), then: Joi.forbidden(), otherwise: Joi.required() }),
72
+ shared: Joi.when('template', {
73
+ is: Joi.exist(),
74
+ then: Joi.object().keys({
75
+ image: Job.image,
76
+ environment: Job.environment,
77
+ settings: Job.settings
78
+ }),
79
+ otherwise: SCHEMA_SHARED
80
+ }),
81
+ cache: SCHEMA_CACHE.when('template', { is: Joi.exist(), then: Joi.forbidden() }),
82
+ childPipelines: SCHEMA_CHILD_PIPELINES.when('template', { is: Joi.exist(), then: Joi.forbidden() }),
83
+ stages: SCHEMA_STAGES.when('template', { is: Joi.exist(), then: Joi.forbidden() }),
84
+ subscribe: SCHEMA_SUBSCRIBE.when('template', { is: Joi.exist(), then: Joi.forbidden() }),
85
+ parameters: Parameters.parameters.default({}).when('template', { is: Joi.exist(), then: Joi.forbidden() })
86
+ })
87
+ .unknown(false);
88
+
89
+ const SCHEMA_CONFIG_POST_TEMPLATE_MERGE = Joi.object()
67
90
  .keys({
68
91
  version: Joi.number().integer().min(1).max(50),
69
92
  annotations: Annotations.annotations,
@@ -73,7 +96,8 @@ const SCHEMA_CONFIG = Joi.object()
73
96
  childPipelines: SCHEMA_CHILD_PIPELINES,
74
97
  stages: SCHEMA_STAGES,
75
98
  subscribe: SCHEMA_SUBSCRIBE,
76
- parameters: Parameters.parameters.default({})
99
+ parameters: Parameters.parameters.default({}),
100
+ templateVersionId: Joi.number().integer().positive().optional().allow(null)
77
101
  })
78
102
  .unknown(false);
79
103
 
@@ -88,7 +112,8 @@ module.exports = {
88
112
  cache: SCHEMA_CACHE,
89
113
  cachePerm: SCHEMA_CACHE_PERMUTATION,
90
114
  childPipelines: SCHEMA_CHILD_PIPELINES,
91
- config: SCHEMA_CONFIG,
115
+ configBeforeMergingTemplate: SCHEMA_CONFIG_PRE_TEMPLATE_MERGE,
116
+ configAfterMergingTemplate: SCHEMA_CONFIG_POST_TEMPLATE_MERGE,
92
117
  stageSetupTeardownJob: SCHEMA_SETUP_TEARDOWN_JOB,
93
118
  stage: SCHEMA_STAGE,
94
119
  stages: SCHEMA_STAGES,
@@ -0,0 +1,27 @@
1
+ /* eslint-disable new-cap */
2
+
3
+ 'use strict';
4
+
5
+ const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
6
+ const table = `${prefix}pipelines`;
7
+
8
+ module.exports = {
9
+ up: async (queryInterface, Sequelize) => {
10
+ await queryInterface.sequelize.transaction(async transaction => {
11
+ await queryInterface.addColumn(
12
+ table,
13
+ 'templateVersionId',
14
+ {
15
+ type: Sequelize.INTEGER.UNSIGNED
16
+ },
17
+ { transaction }
18
+ );
19
+
20
+ await queryInterface.addIndex(table, {
21
+ name: `${table}_template_version_id`,
22
+ fields: ['templateVersionId'],
23
+ transaction
24
+ });
25
+ });
26
+ }
27
+ };
@@ -112,7 +112,15 @@ const MODEL = {
112
112
  })
113
113
  .description('A list of badges that pipline has')
114
114
  .example(`{ sonar: { name: 'dashboard', uri: 'http://sonar.com/sample1' } }`)
115
+ .optional(),
116
+
117
+ templateVersionId: Joi.number()
118
+ .integer()
119
+ .positive()
120
+ .description("Identifier for this pipeline's template")
121
+ .example(123345)
115
122
  .optional()
123
+ .allow(null)
116
124
  };
117
125
 
118
126
  const UPDATE_MODEL = { ...CREATE_MODEL, settings: MODEL.settings, badges: MODEL.badges };
@@ -156,7 +164,8 @@ module.exports = {
156
164
  'parameters',
157
165
  'subscribedScmUrlsWithActions',
158
166
  'settings',
159
- 'badges'
167
+ 'badges',
168
+ 'templateVersionId'
160
169
  ]
161
170
  )
162
171
  ).label('Get Pipeline'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-data-schema",
3
- "version": "22.11.1",
3
+ "version": "23.0.0",
4
4
  "description": "Internal Data Schema of Screwdriver",
5
5
  "main": "index.js",
6
6
  "scripts": {