screwdriver-api 6.0.26 → 6.0.28
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
|
@@ -26,39 +26,17 @@ module.exports = () => ({
|
|
|
26
26
|
|
|
27
27
|
// Check permissions
|
|
28
28
|
// Must be Screwdriver admin to add Screwdriver build cluster
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const adminDetails = request.server.plugins.banners.screwdriverAdminDetails(username, scmDisplayName);
|
|
29
|
+
const scmDisplayName = bannerFactory.scm.getDisplayName({ scmContext: payload.scmContext });
|
|
30
|
+
const adminDetails = request.server.plugins.banners.screwdriverAdminDetails(username, scmDisplayName);
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
if (!adminDetails.isAdmin) {
|
|
33
|
+
return boom.forbidden(
|
|
34
|
+
`User ${adminDetails.userDisplayName}
|
|
36
35
|
does not have Screwdriver administrative privileges.`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
buildClusterFactory
|
|
42
|
-
.create(payload)
|
|
43
|
-
.then(buildCluster => {
|
|
44
|
-
// everything succeeded, inform the user
|
|
45
|
-
const location = urlLib.format({
|
|
46
|
-
host: request.headers.host,
|
|
47
|
-
port: request.headers.port,
|
|
48
|
-
protocol: request.server.info.protocol,
|
|
49
|
-
pathname: `${request.path}/${buildCluster.id}`
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return h.response(buildCluster.toJson()).header('Location', location).code(201);
|
|
53
|
-
})
|
|
54
|
-
// something was botched
|
|
55
|
-
.catch(err => {
|
|
56
|
-
throw err;
|
|
57
|
-
})
|
|
58
36
|
);
|
|
59
37
|
}
|
|
60
|
-
// Must provide scmOrganizations if not a Screwdriver cluster
|
|
61
|
-
if (scmOrganizations && scmOrganizations.length === 0) {
|
|
38
|
+
// Must provide scmOrganizations if not a Screwdriver managed cluster
|
|
39
|
+
if (!managedByScrewdriver && scmOrganizations && scmOrganizations.length === 0) {
|
|
62
40
|
return boom.badData(`No scmOrganizations provided for build cluster ${name}.`);
|
|
63
41
|
}
|
|
64
42
|
|
|
@@ -28,46 +28,18 @@ module.exports = () => ({
|
|
|
28
28
|
|
|
29
29
|
// Check permissions
|
|
30
30
|
// Must be Screwdriver admin to update Screwdriver build cluster
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const adminDetails = request.server.plugins.banners.screwdriverAdminDetails(username, scmDisplayName);
|
|
31
|
+
const scmDisplayName = bannerFactory.scm.getDisplayName({ scmContext: userContext });
|
|
32
|
+
const adminDetails = request.server.plugins.banners.screwdriverAdminDetails(username, scmDisplayName);
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if (!adminDetails.isAdmin) {
|
|
35
|
+
return boom.forbidden(
|
|
36
|
+
`User ${adminDetails.userDisplayName}
|
|
38
37
|
does not have Screwdriver administrative privileges.`
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return buildClusterFactory
|
|
43
|
-
.list({
|
|
44
|
-
params: {
|
|
45
|
-
name,
|
|
46
|
-
scmContext: userContext
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
.then(buildClusters => {
|
|
50
|
-
if (!Array.isArray(buildClusters)) {
|
|
51
|
-
throw boom.badData('Build cluster list returned non-array.');
|
|
52
|
-
}
|
|
53
|
-
if (buildClusters.length === 0) {
|
|
54
|
-
throw boom.notFound(
|
|
55
|
-
`Build cluster ${name}, scmContext ${payload.scmContext} does not exist`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
Object.assign(buildClusters[0], request.payload);
|
|
60
|
-
|
|
61
|
-
return buildClusters[0]
|
|
62
|
-
.update()
|
|
63
|
-
.then(updatedBuildCluster => h.response(updatedBuildCluster.toJson()).code(200));
|
|
64
|
-
})
|
|
65
|
-
.catch(err => {
|
|
66
|
-
throw err;
|
|
67
|
-
});
|
|
38
|
+
);
|
|
68
39
|
}
|
|
69
|
-
|
|
70
|
-
|
|
40
|
+
|
|
41
|
+
// Must provide scmOrganizations if not a Screwdriver managed cluster
|
|
42
|
+
if (!managedByScrewdriver && scmOrganizations && scmOrganizations.length === 0) {
|
|
71
43
|
return boom.badData(`No scmOrganizations provided for build cluster ${name}.`);
|
|
72
44
|
}
|
|
73
45
|
|
|
@@ -75,7 +47,7 @@ module.exports = () => ({
|
|
|
75
47
|
.list({
|
|
76
48
|
params: {
|
|
77
49
|
name,
|
|
78
|
-
scmContext:
|
|
50
|
+
scmContext: userContext
|
|
79
51
|
}
|
|
80
52
|
})
|
|
81
53
|
.then(buildClusters => {
|
|
@@ -83,13 +55,12 @@ module.exports = () => ({
|
|
|
83
55
|
throw boom.badData('Build cluster list returned non-array.');
|
|
84
56
|
}
|
|
85
57
|
if (buildClusters.length === 0) {
|
|
86
|
-
throw boom.notFound(`Build cluster ${name} scmContext ${
|
|
58
|
+
throw boom.notFound(`Build cluster ${name}, scmContext ${userContext} does not exist`);
|
|
87
59
|
}
|
|
88
|
-
const buildCluster = buildClusters[0];
|
|
89
60
|
|
|
90
|
-
Object.assign(
|
|
61
|
+
Object.assign(buildClusters[0], request.payload);
|
|
91
62
|
|
|
92
|
-
return
|
|
63
|
+
return buildClusters[0]
|
|
93
64
|
.update()
|
|
94
65
|
.then(updatedBuildCluster => h.response(updatedBuildCluster.toJson()).code(200));
|
|
95
66
|
})
|