screwdriver-api 7.0.4 → 7.0.6
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/.prettierrc.yaml
CHANGED
package/package.json
CHANGED
|
@@ -131,6 +131,38 @@ If the deleted version was the last published, the API would set the `latest` at
|
|
|
131
131
|
* `name` - Name of the template
|
|
132
132
|
* `version` - Version of the template
|
|
133
133
|
|
|
134
|
+
##### Get Report of Pipelines that use a template version
|
|
135
|
+
|
|
136
|
+
`GET /templates/{name}/{version}/usage/pipelines`
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
###### Arguments
|
|
140
|
+
|
|
141
|
+
'name', 'version'
|
|
142
|
+
|
|
143
|
+
* `name` - Name of the template
|
|
144
|
+
* `version` - Version of the template
|
|
145
|
+
|
|
146
|
+
###### Example response
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
[
|
|
150
|
+
{
|
|
151
|
+
id: 4,
|
|
152
|
+
name: 'nathom/sd-uses-template',
|
|
153
|
+
scmRepo: {
|
|
154
|
+
branch: 'main',
|
|
155
|
+
name: 'nathom/sd-uses-template',
|
|
156
|
+
url: 'https://github.com/nathom/sd-uses-template/tree/main/pipe2',
|
|
157
|
+
rootDir: 'pipe2',
|
|
158
|
+
private: false
|
|
159
|
+
},
|
|
160
|
+
lastRun: '2023-07-31T17:15:37.510Z',
|
|
161
|
+
admins: { nathom: true }
|
|
162
|
+
},
|
|
163
|
+
]
|
|
164
|
+
```
|
|
165
|
+
|
|
134
166
|
#### Template Tag
|
|
135
167
|
Template tag allows fetching on template version by tag. For example, tag `mytemplate@1.1.0` as `stable`.
|
|
136
168
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const boom = require('@hapi/boom');
|
|
4
|
+
const joi = require('joi');
|
|
5
|
+
const schema = require('screwdriver-data-schema');
|
|
6
|
+
const nameSchema = schema.models.template.base.extract('name');
|
|
7
|
+
const versionSchema = schema.models.template.base.extract('version');
|
|
8
|
+
const tagSchema = schema.models.templateTag.base.extract('tag');
|
|
9
|
+
const getSchema = schema.api.pipelineUsage.get;
|
|
10
|
+
|
|
11
|
+
module.exports = () => ({
|
|
12
|
+
method: 'GET',
|
|
13
|
+
path: '/templates/{name}/{versionOrTag}/usage/pipelines',
|
|
14
|
+
options: {
|
|
15
|
+
description: 'Get information for the pipelines that are being used by a specific template version.',
|
|
16
|
+
notes: 'Returns information aboout the pipelines using the template version.',
|
|
17
|
+
tags: ['api', 'templates', 'pipelines', 'metrics'],
|
|
18
|
+
auth: {
|
|
19
|
+
strategies: ['token'],
|
|
20
|
+
scope: ['user', 'build']
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
handler: async (request, h) => {
|
|
24
|
+
const { templateFactory } = request.server.app;
|
|
25
|
+
const { name, versionOrTag } = request.params;
|
|
26
|
+
|
|
27
|
+
return templateFactory
|
|
28
|
+
.getPipelineUsage(`${name}@${versionOrTag}`)
|
|
29
|
+
.then(pipelines => {
|
|
30
|
+
return h.response(pipelines);
|
|
31
|
+
})
|
|
32
|
+
.catch(err => {
|
|
33
|
+
if (err.message === 'Template does not exist') {
|
|
34
|
+
throw boom.notFound(`Template ${name}@${versionOrTag} does not exist`);
|
|
35
|
+
} else {
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
response: {
|
|
41
|
+
schema: getSchema
|
|
42
|
+
},
|
|
43
|
+
validate: {
|
|
44
|
+
params: joi.object({
|
|
45
|
+
name: nameSchema,
|
|
46
|
+
versionOrTag: joi.alternatives().try(versionSchema, tagSchema)
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
@@ -13,6 +13,7 @@ const removeTagRoute = require('./removeTag');
|
|
|
13
13
|
const removeVersionRoute = require('./removeVersion');
|
|
14
14
|
const updateTrustedRoute = require('./updateTrusted');
|
|
15
15
|
const getTemplateByIdRoute = require('./getTemplateById');
|
|
16
|
+
const getPipelineUsage = require('./getPipelineUsage');
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Template API Plugin
|
|
@@ -87,7 +88,8 @@ const templatesPlugin = {
|
|
|
87
88
|
removeTagRoute(),
|
|
88
89
|
removeVersionRoute(),
|
|
89
90
|
updateTrustedRoute(),
|
|
90
|
-
getTemplateByIdRoute()
|
|
91
|
+
getTemplateByIdRoute(),
|
|
92
|
+
getPipelineUsage()
|
|
91
93
|
]);
|
|
92
94
|
}
|
|
93
95
|
};
|