gitlab-radiator 3.3.9 → 3.3.10
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 +1 -1
- package/public/client.js +2 -0
- package/public/client.js.LICENSE.txt +41 -0
- package/src/app.js +167 -80
- package/src/auth.js +25 -13
- package/src/config.js +44 -28
- package/src/gitlab/client.js +39 -17
- package/src/gitlab/index.js +157 -41
- package/src/gitlab/pipelines.js +247 -79
- package/src/gitlab/projects.js +118 -38
- package/src/gitlab/runners.js +76 -15
- package/src/index.js +4 -2
- package/.babelrc +0 -4
- package/.eslintrc +0 -13
- package/.github/workflows/test.yml +0 -20
- package/.nvmrc +0 -1
- package/build-npm +0 -19
- package/screenshot.png +0 -0
- package/src/client/.eslintrc +0 -21
- package/src/client/arguments.ts +0 -75
- package/src/client/gitlab-types.ts +0 -54
- package/src/client/groupedProjects.tsx +0 -40
- package/src/client/groups.tsx +0 -59
- package/src/client/index.tsx +0 -94
- package/src/client/info.tsx +0 -16
- package/src/client/jobs.tsx +0 -56
- package/src/client/projects.tsx +0 -51
- package/src/client/renderTimestamp.tsx +0 -45
- package/src/client/stages.tsx +0 -18
- package/src/dev-assets.js +0 -10
- package/test/gitlab/projects.test.js +0 -75
- package/test/gitlab-integration.js +0 -384
- package/tsconfig.json +0 -28
- package/webpack.common.js +0 -25
- package/webpack.dev.js +0 -13
- package/webpack.prod.js +0 -9
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
object-assign
|
|
3
|
+
(c) Sindre Sorhus
|
|
4
|
+
@license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Lodash <https://lodash.com/>
|
|
10
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
11
|
+
* Released under MIT license <https://lodash.com/license>
|
|
12
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
13
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** @license React v0.20.2
|
|
17
|
+
* scheduler.production.min.js
|
|
18
|
+
*
|
|
19
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
20
|
+
*
|
|
21
|
+
* This source code is licensed under the MIT license found in the
|
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** @license React v17.0.2
|
|
26
|
+
* react-dom.production.min.js
|
|
27
|
+
*
|
|
28
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the MIT license found in the
|
|
31
|
+
* LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/** @license React v17.0.2
|
|
35
|
+
* react.production.min.js
|
|
36
|
+
*
|
|
37
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the MIT license found in the
|
|
40
|
+
* LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/
|
package/src/app.js
CHANGED
|
@@ -1,100 +1,187 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
|
+
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
|
|
11
|
+
var _auth = require("./auth");
|
|
12
|
+
|
|
13
|
+
var _compression = _interopRequireDefault(require("compression"));
|
|
14
|
+
|
|
15
|
+
var _config = require("./config");
|
|
16
|
+
|
|
17
|
+
var _express = _interopRequireDefault(require("express"));
|
|
18
|
+
|
|
19
|
+
var _runners = require("./gitlab/runners");
|
|
20
|
+
|
|
21
|
+
var _http = _interopRequireDefault(require("http"));
|
|
22
|
+
|
|
23
|
+
var _lessMiddleware = _interopRequireDefault(require("less-middleware"));
|
|
24
|
+
|
|
25
|
+
var _os = _interopRequireDefault(require("os"));
|
|
26
|
+
|
|
27
|
+
var _path = _interopRequireDefault(require("path"));
|
|
28
|
+
|
|
29
|
+
var _socket = _interopRequireDefault(require("socket.io"));
|
|
30
|
+
|
|
31
|
+
var _gitlab = require("./gitlab");
|
|
32
|
+
|
|
33
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
34
|
+
|
|
35
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
36
|
+
|
|
37
|
+
var cacheDir = _path.default.join(_os.default.tmpdir(), 'gitlab-radiator-css-cache');
|
|
38
|
+
|
|
39
|
+
var app = (0, _express.default)();
|
|
40
|
+
|
|
41
|
+
var httpServer = _http.default.Server(app);
|
|
42
|
+
|
|
43
|
+
var socketIoServer = (0, _socket.default)(httpServer);
|
|
18
44
|
|
|
19
45
|
if (process.env.NODE_ENV !== 'production') {
|
|
20
46
|
// eslint-disable-next-line global-require
|
|
21
|
-
|
|
22
|
-
|
|
47
|
+
var _require = require('./dev-assets'),
|
|
48
|
+
bindDevAssets = _require.bindDevAssets;
|
|
49
|
+
|
|
50
|
+
bindDevAssets(app);
|
|
23
51
|
}
|
|
24
52
|
|
|
25
|
-
app.disable('x-powered-by')
|
|
26
|
-
app.use(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
53
|
+
app.disable('x-powered-by');
|
|
54
|
+
app.use((0, _lessMiddleware.default)("".concat(__dirname, "/../public"), {
|
|
55
|
+
dest: cacheDir,
|
|
56
|
+
preprocess: {
|
|
57
|
+
less: src => {
|
|
58
|
+
var colorLess = '';
|
|
59
|
+
Object.keys(_config.config.colors).forEach(stateName => {
|
|
60
|
+
colorLess += "@".concat(stateName, "-color:").concat(_config.config.colors[stateName], ";");
|
|
61
|
+
});
|
|
62
|
+
return src + colorLess;
|
|
36
63
|
}
|
|
37
64
|
}
|
|
38
|
-
))
|
|
39
|
-
app.use(
|
|
40
|
-
app.use(
|
|
41
|
-
app.use(
|
|
42
|
-
app.use(basicAuth(config.auth))
|
|
43
|
-
|
|
44
|
-
httpServer.listen(config.port, () => {
|
|
65
|
+
}));
|
|
66
|
+
app.use(_express.default.static(cacheDir));
|
|
67
|
+
app.use(_express.default.static("".concat(__dirname, "/../public")));
|
|
68
|
+
app.use((0, _compression.default)());
|
|
69
|
+
app.use((0, _auth.basicAuth)(_config.config.auth));
|
|
70
|
+
httpServer.listen(_config.config.port, () => {
|
|
45
71
|
// eslint-disable-next-line no-console
|
|
46
|
-
console.log(
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const globalState = {
|
|
72
|
+
console.log("Listening on port *:".concat(_config.config.port));
|
|
73
|
+
});
|
|
74
|
+
var globalState = {
|
|
50
75
|
projects: null,
|
|
51
76
|
error: null,
|
|
52
|
-
zoom: config.zoom,
|
|
53
|
-
projectsOrder: config.projectsOrder,
|
|
54
|
-
columns: config.columns,
|
|
55
|
-
groupSuccessfulProjects: config.groupSuccessfulProjects
|
|
77
|
+
zoom: _config.config.zoom,
|
|
78
|
+
projectsOrder: _config.config.projectsOrder,
|
|
79
|
+
columns: _config.config.columns,
|
|
80
|
+
groupSuccessfulProjects: _config.config.groupSuccessfulProjects
|
|
81
|
+
};
|
|
82
|
+
socketIoServer.on('connection', socket => {
|
|
83
|
+
socket.emit('state', withDate(globalState));
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
function runUpdate() {
|
|
87
|
+
return _runUpdate.apply(this, arguments);
|
|
56
88
|
}
|
|
57
89
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
90
|
+
function _runUpdate() {
|
|
91
|
+
_runUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
92
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
93
|
+
while (1) {
|
|
94
|
+
switch (_context.prev = _context.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
_context.prev = 0;
|
|
97
|
+
_context.next = 3;
|
|
98
|
+
return (0, _gitlab.update)(_config.config);
|
|
99
|
+
|
|
100
|
+
case 3:
|
|
101
|
+
globalState.projects = _context.sent;
|
|
102
|
+
_context.next = 6;
|
|
103
|
+
return errorIfRunnerOffline();
|
|
104
|
+
|
|
105
|
+
case 6:
|
|
106
|
+
globalState.error = _context.sent;
|
|
107
|
+
socketIoServer.emit('state', withDate(globalState));
|
|
108
|
+
_context.next = 15;
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
case 10:
|
|
112
|
+
_context.prev = 10;
|
|
113
|
+
_context.t0 = _context["catch"](0);
|
|
114
|
+
// eslint-disable-next-line no-console
|
|
115
|
+
console.error(_context.t0.message);
|
|
116
|
+
globalState.error = "Failed to communicate with GitLab API: ".concat(_context.t0.message);
|
|
117
|
+
socketIoServer.emit('state', withDate(globalState));
|
|
118
|
+
|
|
119
|
+
case 15:
|
|
120
|
+
setTimeout(runUpdate, _config.config.interval);
|
|
121
|
+
|
|
122
|
+
case 16:
|
|
123
|
+
case "end":
|
|
124
|
+
return _context.stop();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, _callee, null, [[0, 10]]);
|
|
128
|
+
}));
|
|
129
|
+
return _runUpdate.apply(this, arguments);
|
|
74
130
|
}
|
|
75
131
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
offline: acc.offline.concat(runner.offline),
|
|
81
|
-
totalCount: acc.totalCount + runner.totalCount
|
|
82
|
-
}
|
|
83
|
-
}, {offline: [], totalCount: 0})
|
|
132
|
+
function errorIfRunnerOffline() {
|
|
133
|
+
return _errorIfRunnerOffline.apply(this, arguments);
|
|
134
|
+
}
|
|
84
135
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
136
|
+
function _errorIfRunnerOffline() {
|
|
137
|
+
_errorIfRunnerOffline = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
138
|
+
var offlineRunnersPerGitlab, _offlineRunnersPerGit, offline, totalCount, names, counts;
|
|
139
|
+
|
|
140
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
141
|
+
while (1) {
|
|
142
|
+
switch (_context2.prev = _context2.next) {
|
|
143
|
+
case 0:
|
|
144
|
+
_context2.next = 2;
|
|
145
|
+
return Promise.all(_config.config.gitlabs.map(_runners.fetchOfflineRunners));
|
|
146
|
+
|
|
147
|
+
case 2:
|
|
148
|
+
offlineRunnersPerGitlab = _context2.sent;
|
|
149
|
+
_offlineRunnersPerGit = offlineRunnersPerGitlab.reduce((acc, runner) => {
|
|
150
|
+
return {
|
|
151
|
+
offline: acc.offline.concat(runner.offline),
|
|
152
|
+
totalCount: acc.totalCount + runner.totalCount
|
|
153
|
+
};
|
|
154
|
+
}, {
|
|
155
|
+
offline: [],
|
|
156
|
+
totalCount: 0
|
|
157
|
+
}), offline = _offlineRunnersPerGit.offline, totalCount = _offlineRunnersPerGit.totalCount;
|
|
158
|
+
|
|
159
|
+
if (!(offline.length > 0)) {
|
|
160
|
+
_context2.next = 8;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
names = offline.map(r => r.name).sort().join(', ');
|
|
165
|
+
counts = offline.length === totalCount ? 'All' : "".concat(offline.length, "/").concat(totalCount);
|
|
166
|
+
return _context2.abrupt("return", "".concat(counts, " runners offline: ").concat(names));
|
|
167
|
+
|
|
168
|
+
case 8:
|
|
169
|
+
return _context2.abrupt("return", null);
|
|
170
|
+
|
|
171
|
+
case 9:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context2.stop();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, _callee2);
|
|
177
|
+
}));
|
|
178
|
+
return _errorIfRunnerOffline.apply(this, arguments);
|
|
91
179
|
}
|
|
92
180
|
|
|
93
|
-
runUpdate()
|
|
181
|
+
runUpdate();
|
|
94
182
|
|
|
95
183
|
function withDate(state) {
|
|
96
|
-
return {
|
|
97
|
-
...state,
|
|
184
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
98
185
|
now: Date.now()
|
|
99
|
-
}
|
|
100
|
-
}
|
|
186
|
+
});
|
|
187
|
+
}
|
package/src/auth.js
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.basicAuth = basicAuth;
|
|
9
|
+
|
|
10
|
+
var _basicAuth = _interopRequireDefault(require("basic-auth"));
|
|
11
|
+
|
|
12
|
+
function basicAuth(auth) {
|
|
4
13
|
if (!auth || !auth.username || !auth.password) {
|
|
5
14
|
// eslint-disable-next-line no-console
|
|
6
|
-
console.log('No authentication configured')
|
|
7
|
-
return (req, res, next) => next()
|
|
8
|
-
}
|
|
15
|
+
console.log('No authentication configured');
|
|
16
|
+
return (req, res, next) => next();
|
|
17
|
+
} // eslint-disable-next-line no-console
|
|
9
18
|
|
|
10
|
-
|
|
11
|
-
console.log('HTTP basic auth enabled')
|
|
19
|
+
|
|
20
|
+
console.log('HTTP basic auth enabled');
|
|
12
21
|
return (req, res, next) => {
|
|
13
|
-
|
|
22
|
+
var _ref = (0, _basicAuth.default)(req) || {},
|
|
23
|
+
name = _ref.name,
|
|
24
|
+
pass = _ref.pass;
|
|
25
|
+
|
|
14
26
|
if (auth.username === name && auth.password === pass) {
|
|
15
|
-
next()
|
|
27
|
+
next();
|
|
16
28
|
} else {
|
|
17
|
-
res.setHeader('WWW-Authenticate', 'Basic realm="gitlab-radiator"')
|
|
18
|
-
res.status(401).end()
|
|
29
|
+
res.setHeader('WWW-Authenticate', 'Basic realm="gitlab-radiator"');
|
|
30
|
+
res.status(401).end();
|
|
19
31
|
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
32
|
+
};
|
|
33
|
+
}
|
package/src/config.js
CHANGED
|
@@ -1,43 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.config = void 0;
|
|
9
|
+
|
|
10
|
+
var _assert = _interopRequireDefault(require("assert"));
|
|
11
|
+
|
|
12
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
13
|
+
|
|
14
|
+
var _os = _interopRequireDefault(require("os"));
|
|
15
|
+
|
|
16
|
+
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
17
|
+
|
|
18
|
+
var configFile = expandTilde(process.env.GITLAB_RADIATOR_CONFIG || '~/.gitlab-radiator.yml');
|
|
19
|
+
|
|
20
|
+
var yamlContent = _fs.default.readFileSync(configFile, 'utf8');
|
|
21
|
+
|
|
22
|
+
var config = validate(_jsYaml.default.load(yamlContent));
|
|
23
|
+
exports.config = config;
|
|
24
|
+
config.interval = Number(config.interval || 10) * 1000;
|
|
25
|
+
config.port = Number(config.port || 3000);
|
|
26
|
+
config.zoom = Number(config.zoom || 1.0);
|
|
27
|
+
config.columns = Number(config.columns || 1);
|
|
28
|
+
config.groupSuccessfulProjects = config.groupSuccessfulProjects || false;
|
|
29
|
+
config.projectsOrder = config.projectsOrder || ['name'];
|
|
30
|
+
config.gitlabs = config.gitlabs.map(gitlab => {
|
|
17
31
|
return {
|
|
18
32
|
url: gitlab.url,
|
|
19
33
|
ignoreArchived: gitlab.ignoreArchived === undefined ? true : gitlab.ignoreArchived,
|
|
20
34
|
maxNonFailedJobsVisible: Number(gitlab.maxNonFailedJobsVisible || 999999),
|
|
21
|
-
ca: gitlab.caFile &&
|
|
35
|
+
ca: gitlab.caFile && _fs.default.existsSync(gitlab.caFile, 'utf-8') ? _fs.default.readFileSync(gitlab.caFile) : undefined,
|
|
22
36
|
'access-token': gitlab['access-token'] || process.env.GITLAB_ACCESS_TOKEN,
|
|
23
37
|
projects: {
|
|
24
38
|
excludePipelineStatus: (gitlab.projects || {}).excludePipelineStatus || [],
|
|
25
39
|
include: (gitlab.projects || {}).include || '',
|
|
26
40
|
exclude: (gitlab.projects || {}).exclude || ''
|
|
27
41
|
}
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
config.colors = config.colors || {}
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
config.colors = config.colors || {};
|
|
31
45
|
|
|
32
46
|
function expandTilde(path) {
|
|
33
|
-
return path.replace(/^~($|\/|\\)/,
|
|
47
|
+
return path.replace(/^~($|\/|\\)/, "".concat(_os.default.homedir(), "$1"));
|
|
34
48
|
}
|
|
35
49
|
|
|
36
50
|
function validate(cfg) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
51
|
+
_assert.default.ok(cfg.gitlabs, 'Mandatory gitlab properties missing from configuration file');
|
|
52
|
+
|
|
53
|
+
cfg.gitlabs.forEach(gitlab => {
|
|
54
|
+
_assert.default.ok(gitlab.url, 'Mandatory gitlab url missing from configuration file');
|
|
55
|
+
|
|
56
|
+
_assert.default.ok(gitlab['access-token'] || process.env.GITLAB_ACCESS_TOKEN, 'Mandatory gitlab access token missing from configuration (and none present at GITLAB_ACCESS_TOKEN env variable)');
|
|
57
|
+
});
|
|
58
|
+
return cfg;
|
|
59
|
+
}
|
package/src/gitlab/client.js
CHANGED
|
@@ -1,27 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
import https from 'https'
|
|
3
|
-
import url from 'url'
|
|
1
|
+
"use strict";
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.gitlabRequest = gitlabRequest;
|
|
9
|
+
|
|
10
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
11
|
+
|
|
12
|
+
var _https = _interopRequireDefault(require("https"));
|
|
13
|
+
|
|
14
|
+
var _url = _interopRequireDefault(require("url"));
|
|
15
|
+
|
|
16
|
+
function gitlabRequest(path, params, gitlab) {
|
|
17
|
+
return lazyClient(gitlab).get(path, {
|
|
18
|
+
params
|
|
19
|
+
});
|
|
7
20
|
}
|
|
8
21
|
|
|
9
|
-
|
|
22
|
+
var clients = new Map();
|
|
10
23
|
|
|
11
24
|
function lazyClient(gitlab) {
|
|
12
|
-
|
|
25
|
+
var gitlabUrl = gitlab.url;
|
|
26
|
+
|
|
13
27
|
if (gitlabUrl === undefined) {
|
|
14
28
|
// eslint-disable-next-line no-console
|
|
15
|
-
console.log('Got undefined url for ' + JSON.stringify(gitlab))
|
|
29
|
+
console.log('Got undefined url for ' + JSON.stringify(gitlab));
|
|
16
30
|
}
|
|
31
|
+
|
|
17
32
|
if (!clients.get(gitlabUrl)) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
var client = _axios.default.create({
|
|
34
|
+
baseURL: _url.default.resolve(gitlabUrl, '/api/v4/'),
|
|
35
|
+
headers: {
|
|
36
|
+
'PRIVATE-TOKEN': gitlab['access-token']
|
|
37
|
+
},
|
|
38
|
+
httpsAgent: new _https.default.Agent({
|
|
39
|
+
keepAlive: true,
|
|
40
|
+
ca: gitlab.ca
|
|
41
|
+
}),
|
|
42
|
+
timeout: 30 * 1000
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
clients.set(gitlabUrl, client);
|
|
25
46
|
}
|
|
26
|
-
|
|
27
|
-
|
|
47
|
+
|
|
48
|
+
return clients.get(gitlabUrl);
|
|
49
|
+
}
|