screwdriver-data-schema 22.5.0 → 22.6.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/index.js +2 -0
- package/config/pipelineTemplate.js +41 -0
- package/migrations/20230727160105-add_column_templateType_to_templateTags.js +23 -0
- package/migrations/20230727160440-initdb-pipelineTemplateVersions.js +64 -0
- package/migrations/20230727160522-initdb-templateMeta.js +79 -0
- package/models/index.js +4 -0
- package/models/pipelineTemplateVersions.js +89 -0
- package/models/templateMeta.js +113 -0
- package/models/templateTag.js +11 -2
- package/package.json +1 -1
package/config/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const command = require('./command');
|
|
|
6
6
|
const commandFormat = require('./commandFormat');
|
|
7
7
|
const job = require('./job');
|
|
8
8
|
const parameters = require('./parameters');
|
|
9
|
+
const pipelineTemplate = require('./pipelineTemplate');
|
|
9
10
|
const regex = require('./regex');
|
|
10
11
|
const settings = require('./settings');
|
|
11
12
|
const template = require('./template');
|
|
@@ -19,6 +20,7 @@ module.exports = {
|
|
|
19
20
|
commandFormat,
|
|
20
21
|
job,
|
|
21
22
|
parameters,
|
|
23
|
+
pipelineTemplate,
|
|
22
24
|
regex,
|
|
23
25
|
settings,
|
|
24
26
|
template,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Joi = require('joi');
|
|
4
|
+
const JobsSchema = require('./base').jobs;
|
|
5
|
+
const Shared = require('./base').shared;
|
|
6
|
+
const Parameters = require('./parameters');
|
|
7
|
+
const Template = require('./template');
|
|
8
|
+
const Regex = require('./regex');
|
|
9
|
+
|
|
10
|
+
const SCHEMA_CONFIG = Joi.object()
|
|
11
|
+
.keys({
|
|
12
|
+
jobs: JobsSchema.required(),
|
|
13
|
+
shared: Shared,
|
|
14
|
+
parameters: Parameters.parameters.default({})
|
|
15
|
+
})
|
|
16
|
+
.unknown(false);
|
|
17
|
+
|
|
18
|
+
const SCHEMA_TEMPLATE = Joi.object()
|
|
19
|
+
.keys({
|
|
20
|
+
namespace: Template.namespace.required(),
|
|
21
|
+
name: Joi.string()
|
|
22
|
+
.regex(Regex.TEMPLATE_NAME_NO_SLASH)
|
|
23
|
+
.max(64)
|
|
24
|
+
.description('Name of the template')
|
|
25
|
+
.example('nodePipeline')
|
|
26
|
+
.required(),
|
|
27
|
+
version: Template.version.required(),
|
|
28
|
+
description: Template.description.required(),
|
|
29
|
+
maintainer: Template.maintainer.required(),
|
|
30
|
+
config: SCHEMA_CONFIG.required()
|
|
31
|
+
})
|
|
32
|
+
.unknown(false);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The definition of the Template pieces
|
|
36
|
+
* @type {Object}
|
|
37
|
+
*/
|
|
38
|
+
module.exports = {
|
|
39
|
+
template: SCHEMA_TEMPLATE,
|
|
40
|
+
config: SCHEMA_CONFIG
|
|
41
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable new-cap */
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
|
|
6
|
+
const table = `${prefix}templateTags`;
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
up: async (queryInterface, Sequelize) => {
|
|
10
|
+
await queryInterface.sequelize.transaction(async transaction => {
|
|
11
|
+
await queryInterface.addColumn(
|
|
12
|
+
table,
|
|
13
|
+
'templateType',
|
|
14
|
+
{
|
|
15
|
+
type: Sequelize.STRING(16),
|
|
16
|
+
defaultValue: 'JOB',
|
|
17
|
+
allowNull: false
|
|
18
|
+
},
|
|
19
|
+
{ transaction }
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* eslint-disable new-cap */
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
/** @type {import('sequelize-cli').Migration} */
|
|
6
|
+
const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
|
|
7
|
+
const table = `${prefix}pipelineTemplateVersions`;
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
up: async (queryInterface, Sequelize) => {
|
|
11
|
+
await queryInterface.sequelize.transaction(async transaction => {
|
|
12
|
+
await queryInterface.createTable(
|
|
13
|
+
table,
|
|
14
|
+
{
|
|
15
|
+
id: {
|
|
16
|
+
allowNull: false,
|
|
17
|
+
autoIncrement: true,
|
|
18
|
+
primaryKey: true,
|
|
19
|
+
type: Sequelize.INTEGER.UNSIGNED
|
|
20
|
+
},
|
|
21
|
+
templateId: {
|
|
22
|
+
type: Sequelize.DOUBLE,
|
|
23
|
+
allowNull: false
|
|
24
|
+
},
|
|
25
|
+
description: {
|
|
26
|
+
type: Sequelize.STRING(256)
|
|
27
|
+
},
|
|
28
|
+
version: {
|
|
29
|
+
type: Sequelize.STRING(16),
|
|
30
|
+
allowNull: false
|
|
31
|
+
},
|
|
32
|
+
config: {
|
|
33
|
+
type: Sequelize.TEXT,
|
|
34
|
+
allowNull: false
|
|
35
|
+
},
|
|
36
|
+
createTime: {
|
|
37
|
+
type: Sequelize.STRING(32),
|
|
38
|
+
allowNull: false
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{ transaction }
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
await queryInterface.addConstraint(table, {
|
|
45
|
+
name: `${table}_templateId_version_key`,
|
|
46
|
+
fields: ['templateId', 'version'],
|
|
47
|
+
type: 'unique',
|
|
48
|
+
transaction
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
await queryInterface.addIndex(table, {
|
|
52
|
+
name: `${table}_templateId`,
|
|
53
|
+
fields: ['templateId'],
|
|
54
|
+
transaction
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
await queryInterface.addIndex(table, {
|
|
58
|
+
name: `${table}_version`,
|
|
59
|
+
fields: ['version'],
|
|
60
|
+
transaction
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable new-cap */
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
/** @type {import('sequelize-cli').Migration} */
|
|
6
|
+
const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
|
|
7
|
+
const table = `${prefix}templateMeta`;
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
up: async (queryInterface, Sequelize) => {
|
|
11
|
+
await queryInterface.sequelize.transaction(async transaction => {
|
|
12
|
+
await queryInterface.createTable(
|
|
13
|
+
table,
|
|
14
|
+
{
|
|
15
|
+
id: {
|
|
16
|
+
allowNull: false,
|
|
17
|
+
autoIncrement: true,
|
|
18
|
+
primaryKey: true,
|
|
19
|
+
type: Sequelize.INTEGER.UNSIGNED
|
|
20
|
+
},
|
|
21
|
+
pipelineId: {
|
|
22
|
+
type: Sequelize.DOUBLE,
|
|
23
|
+
allowNull: false
|
|
24
|
+
},
|
|
25
|
+
namespace: {
|
|
26
|
+
type: Sequelize.STRING(64),
|
|
27
|
+
allowNull: false
|
|
28
|
+
},
|
|
29
|
+
name: {
|
|
30
|
+
type: Sequelize.STRING(64),
|
|
31
|
+
allowNull: false
|
|
32
|
+
},
|
|
33
|
+
maintainer: {
|
|
34
|
+
type: Sequelize.STRING(64),
|
|
35
|
+
allowNull: false
|
|
36
|
+
},
|
|
37
|
+
trustedSinceVersion: {
|
|
38
|
+
type: Sequelize.STRING(16)
|
|
39
|
+
},
|
|
40
|
+
latestVersion: {
|
|
41
|
+
type: Sequelize.STRING(16)
|
|
42
|
+
},
|
|
43
|
+
createTime: {
|
|
44
|
+
type: Sequelize.STRING(32),
|
|
45
|
+
allowNull: false
|
|
46
|
+
},
|
|
47
|
+
updateTime: {
|
|
48
|
+
type: Sequelize.STRING(32),
|
|
49
|
+
allowNull: false
|
|
50
|
+
},
|
|
51
|
+
templateType: {
|
|
52
|
+
type: Sequelize.STRING(16),
|
|
53
|
+
allowNull: false
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{ transaction }
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
await queryInterface.addConstraint(table, {
|
|
60
|
+
name: `${table}_namespace_name_key`,
|
|
61
|
+
fields: ['name', 'namespace', 'templateType'],
|
|
62
|
+
type: 'unique',
|
|
63
|
+
transaction
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
await queryInterface.addIndex(table, {
|
|
67
|
+
name: `${table}_name`,
|
|
68
|
+
fields: ['name'],
|
|
69
|
+
transaction
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await queryInterface.addIndex(table, {
|
|
73
|
+
name: `${table}_namespace`,
|
|
74
|
+
fields: ['namespace'],
|
|
75
|
+
transaction
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
package/models/index.js
CHANGED
|
@@ -7,11 +7,13 @@ const step = require('./step');
|
|
|
7
7
|
const event = require('./event');
|
|
8
8
|
const job = require('./job');
|
|
9
9
|
const pipeline = require('./pipeline');
|
|
10
|
+
const pipelineTemplateVersions = require('./pipelineTemplateVersions');
|
|
10
11
|
const user = require('./user');
|
|
11
12
|
const secret = require('./secret');
|
|
12
13
|
const stage = require('./stage');
|
|
13
14
|
const stageBuild = require('./stageBuild');
|
|
14
15
|
const template = require('./template');
|
|
16
|
+
const templateMeta = require('./templateMeta');
|
|
15
17
|
const templateTag = require('./templateTag');
|
|
16
18
|
const token = require('./token');
|
|
17
19
|
const trigger = require('./trigger');
|
|
@@ -27,11 +29,13 @@ module.exports = {
|
|
|
27
29
|
event,
|
|
28
30
|
job,
|
|
29
31
|
pipeline,
|
|
32
|
+
pipelineTemplateVersions,
|
|
30
33
|
user,
|
|
31
34
|
secret,
|
|
32
35
|
stage,
|
|
33
36
|
stageBuild,
|
|
34
37
|
template,
|
|
38
|
+
templateMeta,
|
|
35
39
|
templateTag,
|
|
36
40
|
token,
|
|
37
41
|
trigger,
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Joi = require('joi');
|
|
4
|
+
const mutate = require('../lib/mutate');
|
|
5
|
+
const pipelineTemplateVersions = require('../config/pipelineTemplate');
|
|
6
|
+
const JobTemplateConfig = require('../config/template');
|
|
7
|
+
const templateId = require('./templateMeta').base.extract('id');
|
|
8
|
+
|
|
9
|
+
const MODEL = {
|
|
10
|
+
id: Joi.number().integer().positive().description('Identifier of this template').example(123345).required(),
|
|
11
|
+
templateId,
|
|
12
|
+
description: pipelineTemplateVersions.template.extract('description'),
|
|
13
|
+
version: JobTemplateConfig.exactVersion.description('Exact version of the template').required(),
|
|
14
|
+
config: pipelineTemplateVersions.config,
|
|
15
|
+
createTime: Joi.string()
|
|
16
|
+
.isoDate()
|
|
17
|
+
.max(32)
|
|
18
|
+
.description('When this template was created')
|
|
19
|
+
.example('2038-01-19T03:14:08.131Z')
|
|
20
|
+
.required()
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
/**
|
|
25
|
+
* All the available properties of Template
|
|
26
|
+
*
|
|
27
|
+
* @property base
|
|
28
|
+
* @type {Joi}
|
|
29
|
+
*/
|
|
30
|
+
base: Joi.object(MODEL).label('pipelineTemplateVersions'),
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* All the available properties of pipelineTemplateVersions
|
|
34
|
+
*
|
|
35
|
+
* @property fields
|
|
36
|
+
* @type {Object}
|
|
37
|
+
*/
|
|
38
|
+
fields: MODEL,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Properties for template that will come back during a GET request
|
|
42
|
+
*
|
|
43
|
+
* @property get
|
|
44
|
+
* @type {Joi}
|
|
45
|
+
*/
|
|
46
|
+
get: Joi.object(mutate(MODEL, ['id', 'templateId', 'version'], ['description', 'config', 'createTime'])).label(
|
|
47
|
+
'Get Template'
|
|
48
|
+
),
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* List of fields that determine a unique row
|
|
52
|
+
*
|
|
53
|
+
* @property keys
|
|
54
|
+
* @type {Array}
|
|
55
|
+
*/
|
|
56
|
+
keys: ['templateId', 'version'],
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* List of all fields in the model
|
|
60
|
+
* @property allKeys
|
|
61
|
+
* @type {Array}
|
|
62
|
+
*/
|
|
63
|
+
allKeys: Object.keys(MODEL),
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Primary column to sort queries by.
|
|
67
|
+
* This defines queries to optionally sort a query result set by id.
|
|
68
|
+
* Each range key matches up with an element in the indexes property
|
|
69
|
+
*
|
|
70
|
+
* @property rangeKeys
|
|
71
|
+
* @type {Array}
|
|
72
|
+
*/
|
|
73
|
+
rangeKeys: ['templateId', 'version'],
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Tablename to be used in the datastore
|
|
77
|
+
*
|
|
78
|
+
* @property tableName
|
|
79
|
+
* @type {String}
|
|
80
|
+
*/
|
|
81
|
+
tableName: 'pipelineTemplateVersions',
|
|
82
|
+
/**
|
|
83
|
+
* List of indexes to create in the datastore
|
|
84
|
+
*
|
|
85
|
+
* @property indexes
|
|
86
|
+
* @type {Array}
|
|
87
|
+
*/
|
|
88
|
+
indexes: [{ fields: ['templateId'] }, { fields: ['version'] }]
|
|
89
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Joi = require('joi');
|
|
4
|
+
const mutate = require('../lib/mutate');
|
|
5
|
+
const pipelineTemplateConfig = require('../config/pipelineTemplate');
|
|
6
|
+
const pipelineId = require('./pipeline').base.extract('id');
|
|
7
|
+
const JobTemplateConfig = require('../config/template');
|
|
8
|
+
|
|
9
|
+
const TEMPLATE_TYPES = ['JOB', 'PIPELINE'];
|
|
10
|
+
|
|
11
|
+
const MODEL = {
|
|
12
|
+
id: Joi.number().integer().positive().description('Identifier of this template').example(123345).required(),
|
|
13
|
+
pipelineId,
|
|
14
|
+
namespace: pipelineTemplateConfig.template.extract('namespace'),
|
|
15
|
+
name: pipelineTemplateConfig.template.extract('name'),
|
|
16
|
+
maintainer: pipelineTemplateConfig.template.extract('maintainer'),
|
|
17
|
+
trustedSinceVersion: JobTemplateConfig.exactVersion
|
|
18
|
+
.description('The version since the template is marked as trusted')
|
|
19
|
+
.example('1.2.3'),
|
|
20
|
+
latestVersion: JobTemplateConfig.exactVersion.description('Latest version of the template'),
|
|
21
|
+
createTime: Joi.string()
|
|
22
|
+
.isoDate()
|
|
23
|
+
.max(32)
|
|
24
|
+
.description('When this template was created')
|
|
25
|
+
.example('2038-01-19T03:14:08.131Z')
|
|
26
|
+
.required(),
|
|
27
|
+
updateTime: Joi.string()
|
|
28
|
+
.isoDate()
|
|
29
|
+
.max(32)
|
|
30
|
+
.description('When this template was updated')
|
|
31
|
+
.example('2038-01-19T03:14:08.131Z')
|
|
32
|
+
.required(),
|
|
33
|
+
templateType: Joi.string()
|
|
34
|
+
.valid(...TEMPLATE_TYPES)
|
|
35
|
+
.max(16)
|
|
36
|
+
.description('Template Type')
|
|
37
|
+
.example('PIPELINE')
|
|
38
|
+
.required()
|
|
39
|
+
.default('JOB')
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
/**
|
|
44
|
+
* All the available properties of Template
|
|
45
|
+
*
|
|
46
|
+
* @property base
|
|
47
|
+
* @type {Joi}
|
|
48
|
+
*/
|
|
49
|
+
base: Joi.object(MODEL).label('templateMeta'),
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* All the available properties of TemplateMeta
|
|
53
|
+
*
|
|
54
|
+
* @property fields
|
|
55
|
+
* @type {Object}
|
|
56
|
+
*/
|
|
57
|
+
fields: MODEL,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Properties for template that will come back during a GET request
|
|
61
|
+
*
|
|
62
|
+
* @property get
|
|
63
|
+
* @type {Joi}
|
|
64
|
+
*/
|
|
65
|
+
get: Joi.object(
|
|
66
|
+
// eslint-disable-next-line no-sparse-arrays
|
|
67
|
+
mutate(
|
|
68
|
+
MODEL,
|
|
69
|
+
['id', 'pipelineId', 'namespace', 'name', 'maintainer', 'templateType'],
|
|
70
|
+
['trustedSinceVersion', 'latestVersion', 'createTime', 'updateTime']
|
|
71
|
+
)
|
|
72
|
+
).label('Get Template'),
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* List of fields that determine a unique row
|
|
76
|
+
*
|
|
77
|
+
* @property keys
|
|
78
|
+
* @type {Array}
|
|
79
|
+
*/
|
|
80
|
+
keys: ['namespace', 'name', 'templateType'],
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* List of all fields in the model
|
|
84
|
+
* @property allKeys
|
|
85
|
+
* @type {Array}
|
|
86
|
+
*/
|
|
87
|
+
allKeys: Object.keys(MODEL),
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Primary column to sort queries by.
|
|
91
|
+
* This defines queries to optionally sort a query result set by id.
|
|
92
|
+
* Each range key matches up with an element in the indexes property
|
|
93
|
+
*
|
|
94
|
+
* @property rangeKeys
|
|
95
|
+
* @type {Array}
|
|
96
|
+
*/
|
|
97
|
+
rangeKeys: ['namespace', 'name'],
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Tablename to be used in the datastore
|
|
101
|
+
*
|
|
102
|
+
* @property tableName
|
|
103
|
+
* @type {String}
|
|
104
|
+
*/
|
|
105
|
+
tableName: 'templateMeta',
|
|
106
|
+
/**
|
|
107
|
+
* List of indexes to create in the datastore
|
|
108
|
+
*
|
|
109
|
+
* @property indexes
|
|
110
|
+
* @type {Array}
|
|
111
|
+
*/
|
|
112
|
+
indexes: [{ fields: ['namespace'] }, { fields: ['name'] }]
|
|
113
|
+
};
|
package/models/templateTag.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const Joi = require('joi');
|
|
4
4
|
const Template = require('../config/template');
|
|
5
5
|
|
|
6
|
+
const TEMPLATE_TYPES = ['JOB', 'PIPELINE'];
|
|
7
|
+
|
|
6
8
|
const MODEL = {
|
|
7
9
|
id: Joi.number().integer().positive().description('Identifier of this template tag').example(123345),
|
|
8
10
|
createTime: Joi.string()
|
|
@@ -13,7 +15,14 @@ const MODEL = {
|
|
|
13
15
|
namespace: Template.namespace,
|
|
14
16
|
name: Joi.string().max(64).description('Template name').example('nodejs/lib'),
|
|
15
17
|
tag: Template.templateTag,
|
|
16
|
-
version: Template.exactVersion
|
|
18
|
+
version: Template.exactVersion,
|
|
19
|
+
templateType: Joi.string()
|
|
20
|
+
.valid(...TEMPLATE_TYPES)
|
|
21
|
+
.max(16)
|
|
22
|
+
.description('Template Type')
|
|
23
|
+
.example('PIPELINE')
|
|
24
|
+
.required()
|
|
25
|
+
.default('JOB')
|
|
17
26
|
};
|
|
18
27
|
|
|
19
28
|
module.exports = {
|
|
@@ -39,7 +48,7 @@ module.exports = {
|
|
|
39
48
|
* @property keys
|
|
40
49
|
* @type {Array}
|
|
41
50
|
*/
|
|
42
|
-
keys: ['namespace', 'name', 'tag'],
|
|
51
|
+
keys: ['namespace', 'name', 'tag', 'templateType'],
|
|
43
52
|
|
|
44
53
|
/**
|
|
45
54
|
* List of all fields in the model
|