@backstage/plugin-catalog-backend-module-gitlab 0.1.5-next.2 → 0.1.6-next.1
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/CHANGELOG.md +57 -0
- package/dist/index.cjs.js +75 -33
- package/dist/index.cjs.js.map +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.1.6-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 24979413a4: Enhancing GitLab provider with filtering projects by pattern RegExp
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
providers:
|
|
11
|
+
gitlab:
|
|
12
|
+
stg:
|
|
13
|
+
host: gitlab.stg.company.io
|
|
14
|
+
branch: main
|
|
15
|
+
projectPattern: 'john/' # new option
|
|
16
|
+
entityFilename: template.yaml
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
With the aforementioned parameter you can filter projects, and keep only who belongs to the namespace "john".
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/plugin-catalog-backend@1.3.1-next.2
|
|
23
|
+
|
|
24
|
+
## 0.1.6-next.0
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @backstage/backend-common@0.15.0-next.0
|
|
30
|
+
- @backstage/integration@1.3.0-next.0
|
|
31
|
+
- @backstage/backend-tasks@0.3.4-next.0
|
|
32
|
+
- @backstage/plugin-catalog-backend@1.3.1-next.0
|
|
33
|
+
|
|
34
|
+
## 0.1.5
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- a70869e775: Updated dependency `msw` to `^0.43.0`.
|
|
39
|
+
- 8006d0f9bf: Updated dependency `msw` to `^0.44.0`.
|
|
40
|
+
- 49ff472c0b: Add the possibility in the `GitlabDiscoveryEntityProvider` to scan the whole project instead of concrete groups. For that, use a configuration like this one, where the group parameter is omitted (not mandatory anymore):
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
catalog:
|
|
44
|
+
providers:
|
|
45
|
+
gitlab:
|
|
46
|
+
yourProviderId:
|
|
47
|
+
host: gitlab-host # Identifies one of the hosts set up in the integrations
|
|
48
|
+
branch: main # Optional. Uses `master` as default
|
|
49
|
+
entityFilename: catalog-info.yaml # Optional. Defaults to `catalog-info.yaml`
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- Updated dependencies
|
|
53
|
+
- @backstage/plugin-catalog-backend@1.3.0
|
|
54
|
+
- @backstage/backend-common@0.14.1
|
|
55
|
+
- @backstage/catalog-model@1.1.0
|
|
56
|
+
- @backstage/integration@1.2.2
|
|
57
|
+
- @backstage/backend-tasks@0.3.3
|
|
58
|
+
- @backstage/errors@1.1.0
|
|
59
|
+
|
|
3
60
|
## 0.1.5-next.2
|
|
4
61
|
|
|
5
62
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -41,15 +41,20 @@ class GitLabClient {
|
|
|
41
41
|
}
|
|
42
42
|
async listProjects(options) {
|
|
43
43
|
if (options == null ? void 0 : options.group) {
|
|
44
|
-
return this.pagedRequest(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
return this.pagedRequest(
|
|
45
|
+
`/groups/${encodeURIComponent(options == null ? void 0 : options.group)}/projects`,
|
|
46
|
+
{
|
|
47
|
+
...options,
|
|
48
|
+
include_subgroups: true
|
|
49
|
+
}
|
|
50
|
+
);
|
|
48
51
|
}
|
|
49
52
|
return this.pagedRequest(`/projects`, options);
|
|
50
53
|
}
|
|
51
54
|
async hasFile(projectPath, branch, filePath) {
|
|
52
|
-
const endpoint = `/projects/${encodeURIComponent(
|
|
55
|
+
const endpoint = `/projects/${encodeURIComponent(
|
|
56
|
+
projectPath
|
|
57
|
+
)}/repository/files/${encodeURIComponent(filePath)}`;
|
|
53
58
|
const request = new URL(`${this.config.apiBaseUrl}${endpoint}`);
|
|
54
59
|
request.searchParams.append("ref", branch);
|
|
55
60
|
const response = await fetch__default["default"](request.toString(), {
|
|
@@ -58,7 +63,9 @@ class GitLabClient {
|
|
|
58
63
|
});
|
|
59
64
|
if (!response.ok) {
|
|
60
65
|
if (response.status >= 500) {
|
|
61
|
-
this.logger.debug(
|
|
66
|
+
this.logger.debug(
|
|
67
|
+
`Unexpected response when fetching ${request.toString()}. Expected 200 but got ${response.status} - ${response.statusText}`
|
|
68
|
+
);
|
|
62
69
|
}
|
|
63
70
|
return false;
|
|
64
71
|
}
|
|
@@ -72,9 +79,14 @@ class GitLabClient {
|
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
this.logger.debug(`Fetching: ${request.toString()}`);
|
|
75
|
-
const response = await fetch__default["default"](
|
|
82
|
+
const response = await fetch__default["default"](
|
|
83
|
+
request.toString(),
|
|
84
|
+
integration.getGitLabRequestOptions(this.config)
|
|
85
|
+
);
|
|
76
86
|
if (!response.ok) {
|
|
77
|
-
throw new Error(
|
|
87
|
+
throw new Error(
|
|
88
|
+
`Unexpected response when fetching ${request.toString()}. Expected 200 but got ${response.status} - ${response.statusText}`
|
|
89
|
+
);
|
|
78
90
|
}
|
|
79
91
|
return response.json().then((items) => {
|
|
80
92
|
const nextPage = response.headers.get("x-next-page");
|
|
@@ -97,17 +109,21 @@ async function* paginated(request, options) {
|
|
|
97
109
|
}
|
|
98
110
|
|
|
99
111
|
function readGitlabConfig(id, config) {
|
|
100
|
-
var _a, _b, _c;
|
|
112
|
+
var _a, _b, _c, _d;
|
|
101
113
|
const group = (_a = config.getOptionalString("group")) != null ? _a : "";
|
|
102
114
|
const host = config.getString("host");
|
|
103
115
|
const branch = (_b = config.getOptionalString("branch")) != null ? _b : "master";
|
|
104
116
|
const catalogFile = (_c = config.getOptionalString("entityFilename")) != null ? _c : "catalog-info.yaml";
|
|
117
|
+
const projectPattern = new RegExp(
|
|
118
|
+
(_d = config.getOptionalString("projectPattern")) != null ? _d : /[\s\S]*/
|
|
119
|
+
);
|
|
105
120
|
return {
|
|
106
121
|
id,
|
|
107
122
|
group,
|
|
108
123
|
branch,
|
|
109
124
|
host,
|
|
110
|
-
catalogFile
|
|
125
|
+
catalogFile,
|
|
126
|
+
projectPattern
|
|
111
127
|
};
|
|
112
128
|
}
|
|
113
129
|
function readGitlabConfigs(config) {
|
|
@@ -149,7 +165,9 @@ class GitLabDiscoveryProcessor {
|
|
|
149
165
|
const { group, host, branch, catalogPath } = parseUrl(location.target);
|
|
150
166
|
const integration = this.integrations.gitlab.byUrl(`https://${host}`);
|
|
151
167
|
if (!integration) {
|
|
152
|
-
throw new Error(
|
|
168
|
+
throw new Error(
|
|
169
|
+
`There is no GitLab integration that matches ${host}. Please add a configuration entry for it under integrations.gitlab`
|
|
170
|
+
);
|
|
153
171
|
}
|
|
154
172
|
const client = new GitLabClient({
|
|
155
173
|
config: integration.config,
|
|
@@ -177,7 +195,11 @@ class GitLabDiscoveryProcessor {
|
|
|
177
195
|
}
|
|
178
196
|
if (this.skipReposWithoutExactFileMatch) {
|
|
179
197
|
const project_branch = branch === "*" ? project.default_branch : branch;
|
|
180
|
-
const projectHasFile = await client.hasFile(
|
|
198
|
+
const projectHasFile = await client.hasFile(
|
|
199
|
+
project.path_with_namespace,
|
|
200
|
+
project_branch,
|
|
201
|
+
catalogPath
|
|
202
|
+
);
|
|
181
203
|
if (!projectHasFile) {
|
|
182
204
|
continue;
|
|
183
205
|
}
|
|
@@ -186,15 +208,19 @@ class GitLabDiscoveryProcessor {
|
|
|
186
208
|
}
|
|
187
209
|
for (const project of res.matches) {
|
|
188
210
|
const project_branch = branch === "*" ? project.default_branch : branch;
|
|
189
|
-
emit(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
211
|
+
emit(
|
|
212
|
+
pluginCatalogBackend.processingResult.location({
|
|
213
|
+
type: "url",
|
|
214
|
+
target: `${project.web_url}/-/blob/${project_branch}/${catalogPath}`,
|
|
215
|
+
presence: "optional"
|
|
216
|
+
})
|
|
217
|
+
);
|
|
194
218
|
}
|
|
195
219
|
await this.cache.set(this.getCacheKey(), startTime.toISOString());
|
|
196
220
|
const duration = ((Date.now() - startTime.getTime()) / 1e3).toFixed(1);
|
|
197
|
-
this.logger.debug(
|
|
221
|
+
this.logger.debug(
|
|
222
|
+
`Read ${res.scanned} GitLab repositories in ${duration} seconds`
|
|
223
|
+
);
|
|
198
224
|
return true;
|
|
199
225
|
}
|
|
200
226
|
getCacheKey() {
|
|
@@ -225,13 +251,17 @@ class GitlabDiscoveryEntityProvider {
|
|
|
225
251
|
providerConfigs.forEach((providerConfig) => {
|
|
226
252
|
const integration = integrations.byHost(providerConfig.host);
|
|
227
253
|
if (!integration) {
|
|
228
|
-
throw new Error(
|
|
254
|
+
throw new Error(
|
|
255
|
+
`No gitlab integration found that matches host ${providerConfig.host}`
|
|
256
|
+
);
|
|
229
257
|
}
|
|
230
|
-
providers.push(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
258
|
+
providers.push(
|
|
259
|
+
new GitlabDiscoveryEntityProvider({
|
|
260
|
+
...options,
|
|
261
|
+
config: providerConfig,
|
|
262
|
+
integration
|
|
263
|
+
})
|
|
264
|
+
);
|
|
235
265
|
});
|
|
236
266
|
return providers;
|
|
237
267
|
}
|
|
@@ -271,24 +301,32 @@ class GitlabDiscoveryEntityProvider {
|
|
|
271
301
|
};
|
|
272
302
|
}
|
|
273
303
|
async refresh(logger) {
|
|
274
|
-
var _a, _b;
|
|
304
|
+
var _a, _b, _c;
|
|
275
305
|
if (!this.connection) {
|
|
276
|
-
throw new Error(
|
|
306
|
+
throw new Error(
|
|
307
|
+
`Gitlab discovery connection not initialized for ${this.getProviderName()}`
|
|
308
|
+
);
|
|
277
309
|
}
|
|
278
310
|
const client = new GitLabClient({
|
|
279
311
|
config: this.integration.config,
|
|
280
312
|
logger
|
|
281
313
|
});
|
|
282
|
-
const projects = paginated(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
314
|
+
const projects = paginated(
|
|
315
|
+
(options) => client.listProjects(options),
|
|
316
|
+
{
|
|
317
|
+
group: this.config.group,
|
|
318
|
+
page: 1,
|
|
319
|
+
per_page: 50
|
|
320
|
+
}
|
|
321
|
+
);
|
|
287
322
|
const res = {
|
|
288
323
|
scanned: 0,
|
|
289
324
|
matches: []
|
|
290
325
|
};
|
|
291
326
|
for await (const project of projects) {
|
|
327
|
+
if (!this.config.projectPattern.test((_a = project.path_with_namespace) != null ? _a : "")) {
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
292
330
|
res.scanned++;
|
|
293
331
|
if (project.archived) {
|
|
294
332
|
continue;
|
|
@@ -296,8 +334,12 @@ class GitlabDiscoveryEntityProvider {
|
|
|
296
334
|
if (this.config.branch === "*" && project.default_branch === void 0) {
|
|
297
335
|
continue;
|
|
298
336
|
}
|
|
299
|
-
const project_branch = (
|
|
300
|
-
const projectHasFile = await client.hasFile(
|
|
337
|
+
const project_branch = (_b = project.default_branch) != null ? _b : this.config.branch;
|
|
338
|
+
const projectHasFile = await client.hasFile(
|
|
339
|
+
(_c = project.path_with_namespace) != null ? _c : "",
|
|
340
|
+
project_branch,
|
|
341
|
+
this.config.catalogFile
|
|
342
|
+
);
|
|
301
343
|
if (projectHasFile) {
|
|
302
344
|
res.matches.push(project);
|
|
303
345
|
}
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/lib/client.ts","../src/providers/config.ts","../src/GitLabDiscoveryProcessor.ts","../src/providers/GitlabDiscoveryEntityProvider.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fetch from 'node-fetch';\nimport {\n getGitLabRequestOptions,\n GitLabIntegrationConfig,\n} from '@backstage/integration';\nimport { Logger } from 'winston';\n\nexport type ListOptions = {\n [key: string]: string | number | boolean | undefined;\n group?: string;\n per_page?: number | undefined;\n page?: number | undefined;\n};\n\nexport type PagedResponse<T> = {\n items: T[];\n nextPage?: number;\n};\n\nexport class GitLabClient {\n private readonly config: GitLabIntegrationConfig;\n private readonly logger: Logger;\n\n constructor(options: { config: GitLabIntegrationConfig; logger: Logger }) {\n this.config = options.config;\n this.logger = options.logger;\n }\n\n /**\n * Indicates whether the client is for a SaaS or self managed GitLab instance.\n */\n isSelfManaged(): boolean {\n return this.config.host !== 'gitlab.com';\n }\n\n async listProjects(options?: ListOptions): Promise<PagedResponse<any>> {\n if (options?.group) {\n return this.pagedRequest(\n `/groups/${encodeURIComponent(options?.group)}/projects`,\n {\n ...options,\n include_subgroups: true,\n },\n );\n }\n\n return this.pagedRequest(`/projects`, options);\n }\n\n /**\n * General existence check.\n *\n * @param projectPath - The path to the project\n * @param branch - The branch used to search\n * @param filePath - The path to the file\n */\n async hasFile(\n projectPath: string,\n branch: string,\n filePath: string,\n ): Promise<boolean> {\n const endpoint: string = `/projects/${encodeURIComponent(\n projectPath,\n )}/repository/files/${encodeURIComponent(filePath)}`;\n const request = new URL(`${this.config.apiBaseUrl}${endpoint}`);\n request.searchParams.append('ref', branch);\n\n const response = await fetch(request.toString(), {\n headers: getGitLabRequestOptions(this.config).headers,\n method: 'HEAD',\n });\n\n if (!response.ok) {\n if (response.status >= 500) {\n this.logger.debug(\n `Unexpected response when fetching ${request.toString()}. Expected 200 but got ${\n response.status\n } - ${response.statusText}`,\n );\n }\n return false;\n }\n\n return true;\n }\n\n /**\n * Performs a request against a given paginated GitLab endpoint.\n *\n * This method may be used to perform authenticated REST calls against any\n * paginated GitLab endpoint which uses X-NEXT-PAGE headers. The return value\n * can be be used with the {@link paginated} async-generator function to yield\n * each item from the paged request.\n *\n * @see {@link paginated}\n * @param endpoint - The request endpoint, e.g. /projects.\n * @param options - Request queryString options which may also include page variables.\n */\n async pagedRequest<T = any>(\n endpoint: string,\n options?: ListOptions,\n ): Promise<PagedResponse<T>> {\n const request = new URL(`${this.config.apiBaseUrl}${endpoint}`);\n for (const key in options) {\n if (options[key]) {\n request.searchParams.append(key, options[key]!.toString());\n }\n }\n\n this.logger.debug(`Fetching: ${request.toString()}`);\n const response = await fetch(\n request.toString(),\n getGitLabRequestOptions(this.config),\n );\n if (!response.ok) {\n throw new Error(\n `Unexpected response when fetching ${request.toString()}. Expected 200 but got ${\n response.status\n } - ${response.statusText}`,\n );\n }\n return response.json().then(items => {\n const nextPage = response.headers.get('x-next-page');\n\n return {\n items,\n nextPage: nextPage ? Number(nextPage) : null,\n } as PagedResponse<any>;\n });\n }\n}\n\n/**\n * Advances through each page and provides each item from a paginated request.\n *\n * The async generator function yields each item from repeated calls to the\n * provided request function. The generator walks through each available page by\n * setting the page key in the options passed into the request function and\n * making repeated calls until there are no more pages.\n *\n * @see {@link pagedRequest}\n * @param request - Function which returns a PagedResponse to walk through.\n * @param options - Initial ListOptions for the request function.\n */\nexport async function* paginated<T = any>(\n request: (options: ListOptions) => Promise<PagedResponse<T>>,\n options: ListOptions,\n) {\n let res;\n do {\n res = await request(options);\n options.page = res.nextPage;\n for (const item of res.items) {\n yield item;\n }\n } while (res.nextPage);\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { GitlabProviderConfig } from '../lib/types';\n\n/**\n * Extracts the gitlab config from a config object\n *\n * @public\n *\n * @param config - The config object to extract from\n */\nfunction readGitlabConfig(id: string, config: Config): GitlabProviderConfig {\n const group = config.getOptionalString('group') ?? '';\n const host = config.getString('host');\n const branch = config.getOptionalString('branch') ?? 'master';\n const catalogFile =\n config.getOptionalString('entityFilename') ?? 'catalog-info.yaml';\n\n return {\n id,\n group,\n branch,\n host,\n catalogFile,\n };\n}\n\n/**\n * Extracts the gitlab config from a config object array\n *\n * @public\n *\n * @param config - The config object to extract from\n */\nexport function readGitlabConfigs(config: Config): GitlabProviderConfig[] {\n const configs: GitlabProviderConfig[] = [];\n\n const providerConfigs = config.getOptionalConfig('catalog.providers.gitlab');\n\n if (!providerConfigs) {\n return configs;\n }\n\n for (const id of providerConfigs.keys()) {\n configs.push(readGitlabConfig(id, providerConfigs.getConfig(id)));\n }\n\n return configs;\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CacheClient,\n CacheManager,\n PluginCacheManager,\n} from '@backstage/backend-common';\nimport { Config } from '@backstage/config';\nimport {\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\nimport { Logger } from 'winston';\nimport { GitLabClient, GitLabProject, paginated } from './lib';\n\n/**\n * Extracts repositories out of an GitLab instance.\n * @public\n */\nexport class GitLabDiscoveryProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrationRegistry;\n private readonly logger: Logger;\n private readonly cache: CacheClient;\n private readonly skipReposWithoutExactFileMatch: boolean;\n\n static fromConfig(\n config: Config,\n options: { logger: Logger; skipReposWithoutExactFileMatch?: boolean },\n ): GitLabDiscoveryProcessor {\n const integrations = ScmIntegrations.fromConfig(config);\n const pluginCache =\n CacheManager.fromConfig(config).forPlugin('gitlab-discovery');\n\n return new GitLabDiscoveryProcessor({\n ...options,\n integrations,\n pluginCache,\n });\n }\n\n private constructor(options: {\n integrations: ScmIntegrationRegistry;\n pluginCache: PluginCacheManager;\n logger: Logger;\n skipReposWithoutExactFileMatch?: boolean;\n }) {\n this.integrations = options.integrations;\n this.cache = options.pluginCache.getClient();\n this.logger = options.logger;\n this.skipReposWithoutExactFileMatch =\n options.skipReposWithoutExactFileMatch || false;\n }\n\n getProcessorName(): string {\n return 'GitLabDiscoveryProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'gitlab-discovery') {\n return false;\n }\n\n const startTime = new Date();\n const { group, host, branch, catalogPath } = parseUrl(location.target);\n\n const integration = this.integrations.gitlab.byUrl(`https://${host}`);\n if (!integration) {\n throw new Error(\n `There is no GitLab integration that matches ${host}. Please add a configuration entry for it under integrations.gitlab`,\n );\n }\n\n const client = new GitLabClient({\n config: integration.config,\n logger: this.logger,\n });\n this.logger.debug(`Reading GitLab projects from ${location.target}`);\n\n const lastActivity = (await this.cache.get(this.getCacheKey())) as string;\n const opts = {\n group,\n page: 1,\n // We check for the existence of lastActivity and only set it if it's present to ensure\n // that the options doesn't include the key so that the API doesn't receive an empty query parameter.\n ...(lastActivity && { last_activity_after: lastActivity }),\n };\n\n const projects = paginated(options => client.listProjects(options), opts);\n\n const res: Result = {\n scanned: 0,\n matches: [],\n };\n for await (const project of projects) {\n res.scanned++;\n\n if (project.archived) {\n continue;\n }\n\n if (branch === '*' && project.default_branch === undefined) {\n continue;\n }\n\n if (this.skipReposWithoutExactFileMatch) {\n const project_branch = branch === '*' ? project.default_branch : branch;\n\n const projectHasFile: boolean = await client.hasFile(\n project.path_with_namespace,\n project_branch,\n catalogPath,\n );\n\n if (!projectHasFile) {\n continue;\n }\n }\n\n res.matches.push(project);\n }\n\n for (const project of res.matches) {\n const project_branch = branch === '*' ? project.default_branch : branch;\n\n emit(\n processingResult.location({\n type: 'url',\n // The format expected by the GitLabUrlReader:\n // https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n //\n // This unfortunately will trigger another API call in `getGitLabFileFetchUrl` to get the project ID.\n // The alternative is using the `buildRawUrl` function, which does not support subgroups, so providing a raw\n // URL here won't work either.\n target: `${project.web_url}/-/blob/${project_branch}/${catalogPath}`,\n presence: 'optional',\n }),\n );\n }\n\n // Save an ISO formatted string in the cache as that's what GitLab expects in the API request.\n await this.cache.set(this.getCacheKey(), startTime.toISOString());\n\n const duration = ((Date.now() - startTime.getTime()) / 1000).toFixed(1);\n this.logger.debug(\n `Read ${res.scanned} GitLab repositories in ${duration} seconds`,\n );\n\n return true;\n }\n\n private getCacheKey(): string {\n return `processors/${this.getProcessorName()}/last-activity`;\n }\n}\n\ntype Result = {\n scanned: number;\n matches: GitLabProject[];\n};\n\n/*\n * Helpers\n */\n\nexport function parseUrl(urlString: string): {\n group?: string;\n host: string;\n branch: string;\n catalogPath: string;\n} {\n const url = new URL(urlString);\n const path = url.pathname.substr(1).split('/');\n\n // (/group/subgroup)/blob/branch|*/filepath\n const blobIndex = path.findIndex(p => p === 'blob');\n if (blobIndex !== -1 && path.length > blobIndex + 2) {\n const group =\n blobIndex > 0 ? path.slice(0, blobIndex).join('/') : undefined;\n\n return {\n group,\n host: url.host,\n branch: decodeURIComponent(path[blobIndex + 1]),\n catalogPath: decodeURIComponent(path.slice(blobIndex + 2).join('/')),\n };\n }\n\n throw new Error(`Failed to parse ${urlString}`);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TaskRunner } from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { GitLabIntegration, ScmIntegrations } from '@backstage/integration';\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-backend';\nimport { LocationSpec } from '@backstage/plugin-catalog-backend';\nimport { Logger } from 'winston';\nimport {\n GitLabClient,\n GitLabProject,\n GitlabProviderConfig,\n paginated,\n readGitlabConfigs,\n} from '../lib';\nimport * as uuid from 'uuid';\nimport { locationSpecToLocationEntity } from '@backstage/plugin-catalog-backend';\n\ntype Result = {\n scanned: number;\n matches: GitLabProject[];\n};\n\n/**\n * Discovers entity definition files in the groups of a Gitlab instance.\n * @public\n */\nexport class GitlabDiscoveryEntityProvider implements EntityProvider {\n private readonly config: GitlabProviderConfig;\n private readonly integration: GitLabIntegration;\n private readonly logger: Logger;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n\n static fromConfig(\n config: Config,\n options: { logger: Logger; schedule: TaskRunner },\n ): GitlabDiscoveryEntityProvider[] {\n const providerConfigs = readGitlabConfigs(config);\n const integrations = ScmIntegrations.fromConfig(config).gitlab;\n const providers: GitlabDiscoveryEntityProvider[] = [];\n\n providerConfigs.forEach(providerConfig => {\n const integration = integrations.byHost(providerConfig.host);\n if (!integration) {\n throw new Error(\n `No gitlab integration found that matches host ${providerConfig.host}`,\n );\n }\n providers.push(\n new GitlabDiscoveryEntityProvider({\n ...options,\n config: providerConfig,\n integration,\n }),\n );\n });\n return providers;\n }\n\n private constructor(options: {\n config: GitlabProviderConfig;\n integration: GitLabIntegration;\n logger: Logger;\n schedule: TaskRunner;\n }) {\n this.config = options.config;\n this.integration = options.integration;\n this.logger = options.logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(options.schedule);\n }\n\n getProviderName(): string {\n return `GitlabDiscoveryEntityProvider:${this.config.id}`;\n }\n\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n private createScheduleFn(schedule: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return schedule.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: GitlabDiscoveryEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n\n async refresh(logger: Logger): Promise<void> {\n if (!this.connection) {\n throw new Error(\n `Gitlab discovery connection not initialized for ${this.getProviderName()}`,\n );\n }\n\n const client = new GitLabClient({\n config: this.integration.config,\n logger: logger,\n });\n\n const projects = paginated<GitLabProject>(\n options => client.listProjects(options),\n {\n group: this.config.group,\n page: 1,\n per_page: 50,\n },\n );\n\n const res: Result = {\n scanned: 0,\n matches: [],\n };\n\n for await (const project of projects) {\n res.scanned++;\n\n if (project.archived) {\n continue;\n }\n\n if (this.config.branch === '*' && project.default_branch === undefined) {\n continue;\n }\n\n const project_branch = project.default_branch ?? this.config.branch;\n\n const projectHasFile: boolean = await client.hasFile(\n project.path_with_namespace ?? '',\n project_branch,\n this.config.catalogFile,\n );\n if (projectHasFile) {\n res.matches.push(project);\n }\n }\n\n const locations = res.matches.map(p => this.createLocationSpec(p));\n await this.connection.applyMutation({\n type: 'full',\n entities: locations.map(location => ({\n locationKey: this.getProviderName(),\n entity: locationSpecToLocationEntity({ location }),\n })),\n });\n }\n\n private createLocationSpec(project: GitLabProject): LocationSpec {\n const project_branch = project.default_branch ?? this.config.branch;\n return {\n type: 'url',\n target: `${project.web_url}/-/blob/${project_branch}/${this.config.catalogFile}`,\n presence: 'optional',\n };\n }\n}\n"],"names":["fetch","getGitLabRequestOptions","ScmIntegrations","CacheManager","processingResult","uuid","locationSpecToLocationEntity"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,OAAO,EAAE;AACvB,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACjC,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACjC,GAAG;AACH,EAAE,aAAa,GAAG;AAClB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC;AAC7C,GAAG;AACH,EAAE,MAAM,YAAY,CAAC,OAAO,EAAE;AAC9B,IAAI,IAAI,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE;AAClD,MAAM,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,kBAAkB,CAAC,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,EAAE;AACnH,QAAQ,GAAG,OAAO;AAClB,QAAQ,iBAAiB,EAAE,IAAI;AAC/B,OAAO,CAAC,CAAC;AACT,KAAK;AACL,IAAI,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;AACnD,GAAG;AACH,EAAE,MAAM,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE;AAC/C,IAAI,MAAM,QAAQ,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,QAAQ,C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C,CAAC;AACzE,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;AACxC,MAAM,IAAI,EAAE,MAAM;AAClB,MAAM,QAAQ,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,MAAM;AAC7C,QAAQ,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE;AAC3C,QAAQ,MAAM,EAAEC,iDAA4B,CAAC,EAAE,QAAQ,EAAE,CAAC;AAC1D,OAAO,CAAC,CAAC;AACT,KAAK,CAAC,CAAC;AACP,GAAG;AACH,EAAE,kBAAkB,CAAC,OAAO,EAAE;AAC9B,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,MAAM,cAAc,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,cAAc,KAAK,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;AAC3F,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,KAAK;AACjB,MAAM,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACtF,MAAM,QAAQ,EAAE,UAAU;AAC1B,KAAK,CAAC;AACN,GAAG;AACH;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/lib/client.ts","../src/providers/config.ts","../src/GitLabDiscoveryProcessor.ts","../src/providers/GitlabDiscoveryEntityProvider.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fetch from 'node-fetch';\nimport {\n getGitLabRequestOptions,\n GitLabIntegrationConfig,\n} from '@backstage/integration';\nimport { Logger } from 'winston';\n\nexport type ListOptions = {\n [key: string]: string | number | boolean | undefined;\n group?: string;\n per_page?: number | undefined;\n page?: number | undefined;\n};\n\nexport type PagedResponse<T> = {\n items: T[];\n nextPage?: number;\n};\n\nexport class GitLabClient {\n private readonly config: GitLabIntegrationConfig;\n private readonly logger: Logger;\n\n constructor(options: { config: GitLabIntegrationConfig; logger: Logger }) {\n this.config = options.config;\n this.logger = options.logger;\n }\n\n /**\n * Indicates whether the client is for a SaaS or self managed GitLab instance.\n */\n isSelfManaged(): boolean {\n return this.config.host !== 'gitlab.com';\n }\n\n async listProjects(options?: ListOptions): Promise<PagedResponse<any>> {\n if (options?.group) {\n return this.pagedRequest(\n `/groups/${encodeURIComponent(options?.group)}/projects`,\n {\n ...options,\n include_subgroups: true,\n },\n );\n }\n\n return this.pagedRequest(`/projects`, options);\n }\n\n /**\n * General existence check.\n *\n * @param projectPath - The path to the project\n * @param branch - The branch used to search\n * @param filePath - The path to the file\n */\n async hasFile(\n projectPath: string,\n branch: string,\n filePath: string,\n ): Promise<boolean> {\n const endpoint: string = `/projects/${encodeURIComponent(\n projectPath,\n )}/repository/files/${encodeURIComponent(filePath)}`;\n const request = new URL(`${this.config.apiBaseUrl}${endpoint}`);\n request.searchParams.append('ref', branch);\n\n const response = await fetch(request.toString(), {\n headers: getGitLabRequestOptions(this.config).headers,\n method: 'HEAD',\n });\n\n if (!response.ok) {\n if (response.status >= 500) {\n this.logger.debug(\n `Unexpected response when fetching ${request.toString()}. Expected 200 but got ${\n response.status\n } - ${response.statusText}`,\n );\n }\n return false;\n }\n\n return true;\n }\n\n /**\n * Performs a request against a given paginated GitLab endpoint.\n *\n * This method may be used to perform authenticated REST calls against any\n * paginated GitLab endpoint which uses X-NEXT-PAGE headers. The return value\n * can be be used with the {@link paginated} async-generator function to yield\n * each item from the paged request.\n *\n * @see {@link paginated}\n * @param endpoint - The request endpoint, e.g. /projects.\n * @param options - Request queryString options which may also include page variables.\n */\n async pagedRequest<T = any>(\n endpoint: string,\n options?: ListOptions,\n ): Promise<PagedResponse<T>> {\n const request = new URL(`${this.config.apiBaseUrl}${endpoint}`);\n for (const key in options) {\n if (options[key]) {\n request.searchParams.append(key, options[key]!.toString());\n }\n }\n\n this.logger.debug(`Fetching: ${request.toString()}`);\n const response = await fetch(\n request.toString(),\n getGitLabRequestOptions(this.config),\n );\n if (!response.ok) {\n throw new Error(\n `Unexpected response when fetching ${request.toString()}. Expected 200 but got ${\n response.status\n } - ${response.statusText}`,\n );\n }\n return response.json().then(items => {\n const nextPage = response.headers.get('x-next-page');\n\n return {\n items,\n nextPage: nextPage ? Number(nextPage) : null,\n } as PagedResponse<any>;\n });\n }\n}\n\n/**\n * Advances through each page and provides each item from a paginated request.\n *\n * The async generator function yields each item from repeated calls to the\n * provided request function. The generator walks through each available page by\n * setting the page key in the options passed into the request function and\n * making repeated calls until there are no more pages.\n *\n * @see {@link pagedRequest}\n * @param request - Function which returns a PagedResponse to walk through.\n * @param options - Initial ListOptions for the request function.\n */\nexport async function* paginated<T = any>(\n request: (options: ListOptions) => Promise<PagedResponse<T>>,\n options: ListOptions,\n) {\n let res;\n do {\n res = await request(options);\n options.page = res.nextPage;\n for (const item of res.items) {\n yield item;\n }\n } while (res.nextPage);\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { GitlabProviderConfig } from '../lib';\n\n/**\n * Extracts the gitlab config from a config object\n *\n * @public\n *\n * @param id - The provider key\n * @param config - The config object to extract from\n */\nfunction readGitlabConfig(id: string, config: Config): GitlabProviderConfig {\n const group = config.getOptionalString('group') ?? '';\n const host = config.getString('host');\n const branch = config.getOptionalString('branch') ?? 'master';\n const catalogFile =\n config.getOptionalString('entityFilename') ?? 'catalog-info.yaml';\n const projectPattern = new RegExp(\n config.getOptionalString('projectPattern') ?? /[\\s\\S]*/,\n );\n\n return {\n id,\n group,\n branch,\n host,\n catalogFile,\n projectPattern,\n };\n}\n\n/**\n * Extracts the gitlab config from a config object array\n *\n * @public\n *\n * @param config - The config object to extract from\n */\nexport function readGitlabConfigs(config: Config): GitlabProviderConfig[] {\n const configs: GitlabProviderConfig[] = [];\n\n const providerConfigs = config.getOptionalConfig('catalog.providers.gitlab');\n\n if (!providerConfigs) {\n return configs;\n }\n\n for (const id of providerConfigs.keys()) {\n configs.push(readGitlabConfig(id, providerConfigs.getConfig(id)));\n }\n\n return configs;\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CacheClient,\n CacheManager,\n PluginCacheManager,\n} from '@backstage/backend-common';\nimport { Config } from '@backstage/config';\nimport {\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\nimport { Logger } from 'winston';\nimport { GitLabClient, GitLabProject, paginated } from './lib';\n\n/**\n * Extracts repositories out of an GitLab instance.\n * @public\n */\nexport class GitLabDiscoveryProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrationRegistry;\n private readonly logger: Logger;\n private readonly cache: CacheClient;\n private readonly skipReposWithoutExactFileMatch: boolean;\n\n static fromConfig(\n config: Config,\n options: { logger: Logger; skipReposWithoutExactFileMatch?: boolean },\n ): GitLabDiscoveryProcessor {\n const integrations = ScmIntegrations.fromConfig(config);\n const pluginCache =\n CacheManager.fromConfig(config).forPlugin('gitlab-discovery');\n\n return new GitLabDiscoveryProcessor({\n ...options,\n integrations,\n pluginCache,\n });\n }\n\n private constructor(options: {\n integrations: ScmIntegrationRegistry;\n pluginCache: PluginCacheManager;\n logger: Logger;\n skipReposWithoutExactFileMatch?: boolean;\n }) {\n this.integrations = options.integrations;\n this.cache = options.pluginCache.getClient();\n this.logger = options.logger;\n this.skipReposWithoutExactFileMatch =\n options.skipReposWithoutExactFileMatch || false;\n }\n\n getProcessorName(): string {\n return 'GitLabDiscoveryProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'gitlab-discovery') {\n return false;\n }\n\n const startTime = new Date();\n const { group, host, branch, catalogPath } = parseUrl(location.target);\n\n const integration = this.integrations.gitlab.byUrl(`https://${host}`);\n if (!integration) {\n throw new Error(\n `There is no GitLab integration that matches ${host}. Please add a configuration entry for it under integrations.gitlab`,\n );\n }\n\n const client = new GitLabClient({\n config: integration.config,\n logger: this.logger,\n });\n this.logger.debug(`Reading GitLab projects from ${location.target}`);\n\n const lastActivity = (await this.cache.get(this.getCacheKey())) as string;\n const opts = {\n group,\n page: 1,\n // We check for the existence of lastActivity and only set it if it's present to ensure\n // that the options doesn't include the key so that the API doesn't receive an empty query parameter.\n ...(lastActivity && { last_activity_after: lastActivity }),\n };\n\n const projects = paginated(options => client.listProjects(options), opts);\n\n const res: Result = {\n scanned: 0,\n matches: [],\n };\n for await (const project of projects) {\n res.scanned++;\n\n if (project.archived) {\n continue;\n }\n\n if (branch === '*' && project.default_branch === undefined) {\n continue;\n }\n\n if (this.skipReposWithoutExactFileMatch) {\n const project_branch = branch === '*' ? project.default_branch : branch;\n\n const projectHasFile: boolean = await client.hasFile(\n project.path_with_namespace,\n project_branch,\n catalogPath,\n );\n\n if (!projectHasFile) {\n continue;\n }\n }\n\n res.matches.push(project);\n }\n\n for (const project of res.matches) {\n const project_branch = branch === '*' ? project.default_branch : branch;\n\n emit(\n processingResult.location({\n type: 'url',\n // The format expected by the GitLabUrlReader:\n // https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n //\n // This unfortunately will trigger another API call in `getGitLabFileFetchUrl` to get the project ID.\n // The alternative is using the `buildRawUrl` function, which does not support subgroups, so providing a raw\n // URL here won't work either.\n target: `${project.web_url}/-/blob/${project_branch}/${catalogPath}`,\n presence: 'optional',\n }),\n );\n }\n\n // Save an ISO formatted string in the cache as that's what GitLab expects in the API request.\n await this.cache.set(this.getCacheKey(), startTime.toISOString());\n\n const duration = ((Date.now() - startTime.getTime()) / 1000).toFixed(1);\n this.logger.debug(\n `Read ${res.scanned} GitLab repositories in ${duration} seconds`,\n );\n\n return true;\n }\n\n private getCacheKey(): string {\n return `processors/${this.getProcessorName()}/last-activity`;\n }\n}\n\ntype Result = {\n scanned: number;\n matches: GitLabProject[];\n};\n\n/*\n * Helpers\n */\n\nexport function parseUrl(urlString: string): {\n group?: string;\n host: string;\n branch: string;\n catalogPath: string;\n} {\n const url = new URL(urlString);\n const path = url.pathname.substr(1).split('/');\n\n // (/group/subgroup)/blob/branch|*/filepath\n const blobIndex = path.findIndex(p => p === 'blob');\n if (blobIndex !== -1 && path.length > blobIndex + 2) {\n const group =\n blobIndex > 0 ? path.slice(0, blobIndex).join('/') : undefined;\n\n return {\n group,\n host: url.host,\n branch: decodeURIComponent(path[blobIndex + 1]),\n catalogPath: decodeURIComponent(path.slice(blobIndex + 2).join('/')),\n };\n }\n\n throw new Error(`Failed to parse ${urlString}`);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TaskRunner } from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { GitLabIntegration, ScmIntegrations } from '@backstage/integration';\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-backend';\nimport { LocationSpec } from '@backstage/plugin-catalog-backend';\nimport { Logger } from 'winston';\nimport {\n GitLabClient,\n GitLabProject,\n GitlabProviderConfig,\n paginated,\n readGitlabConfigs,\n} from '../lib';\nimport * as uuid from 'uuid';\nimport { locationSpecToLocationEntity } from '@backstage/plugin-catalog-backend';\n\ntype Result = {\n scanned: number;\n matches: GitLabProject[];\n};\n\n/**\n * Discovers entity definition files in the groups of a Gitlab instance.\n * @public\n */\nexport class GitlabDiscoveryEntityProvider implements EntityProvider {\n private readonly config: GitlabProviderConfig;\n private readonly integration: GitLabIntegration;\n private readonly logger: Logger;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n\n static fromConfig(\n config: Config,\n options: { logger: Logger; schedule: TaskRunner },\n ): GitlabDiscoveryEntityProvider[] {\n const providerConfigs = readGitlabConfigs(config);\n const integrations = ScmIntegrations.fromConfig(config).gitlab;\n const providers: GitlabDiscoveryEntityProvider[] = [];\n\n providerConfigs.forEach(providerConfig => {\n const integration = integrations.byHost(providerConfig.host);\n if (!integration) {\n throw new Error(\n `No gitlab integration found that matches host ${providerConfig.host}`,\n );\n }\n providers.push(\n new GitlabDiscoveryEntityProvider({\n ...options,\n config: providerConfig,\n integration,\n }),\n );\n });\n return providers;\n }\n\n private constructor(options: {\n config: GitlabProviderConfig;\n integration: GitLabIntegration;\n logger: Logger;\n schedule: TaskRunner;\n }) {\n this.config = options.config;\n this.integration = options.integration;\n this.logger = options.logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(options.schedule);\n }\n\n getProviderName(): string {\n return `GitlabDiscoveryEntityProvider:${this.config.id}`;\n }\n\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n private createScheduleFn(schedule: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return schedule.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: GitlabDiscoveryEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n\n async refresh(logger: Logger): Promise<void> {\n if (!this.connection) {\n throw new Error(\n `Gitlab discovery connection not initialized for ${this.getProviderName()}`,\n );\n }\n\n const client = new GitLabClient({\n config: this.integration.config,\n logger: logger,\n });\n\n const projects = paginated<GitLabProject>(\n options => client.listProjects(options),\n {\n group: this.config.group,\n page: 1,\n per_page: 50,\n },\n );\n\n const res: Result = {\n scanned: 0,\n matches: [],\n };\n\n for await (const project of projects) {\n if (!this.config.projectPattern.test(project.path_with_namespace ?? '')) {\n continue;\n }\n\n res.scanned++;\n\n if (project.archived) {\n continue;\n }\n\n if (this.config.branch === '*' && project.default_branch === undefined) {\n continue;\n }\n\n const project_branch = project.default_branch ?? this.config.branch;\n\n const projectHasFile: boolean = await client.hasFile(\n project.path_with_namespace ?? '',\n project_branch,\n this.config.catalogFile,\n );\n if (projectHasFile) {\n res.matches.push(project);\n }\n }\n\n const locations = res.matches.map(p => this.createLocationSpec(p));\n await this.connection.applyMutation({\n type: 'full',\n entities: locations.map(location => ({\n locationKey: this.getProviderName(),\n entity: locationSpecToLocationEntity({ location }),\n })),\n });\n }\n\n private createLocationSpec(project: GitLabProject): LocationSpec {\n const project_branch = project.default_branch ?? this.config.branch;\n return {\n type: 'url',\n target: `${project.web_url}/-/blob/${project_branch}/${this.config.catalogFile}`,\n presence: 'optional',\n };\n }\n}\n"],"names":["fetch","getGitLabRequestOptions","ScmIntegrations","CacheManager","processingResult","uuid","locationSpecToLocationEntity"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,OAAO,EAAE;AACvB,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACjC,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACjC,GAAG;AACH,EAAE,aAAa,GAAG;AAClB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC;AAC7C,GAAG;AACH,EAAE,MAAM,YAAY,CAAC,OAAO,EAAE;AAC9B,IAAI,IAAI,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE;AAClD,MAAM,OAAO,IAAI,CAAC,YAAY;AAC9B,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC;AAC1F,QAAQ;AACR,UAAU,GAAG,OAAO;AACpB,UAAU,iBAAiB,EAAE,IAAI;AACjC,SAAS;AACT,OAAO,CAAC;AACR,KAAK;AACL,IAAI,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;AACnD,GAAG;AACH,EAAE,MAAM,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE;AAC/C,IAAI,MAAM,QAAQ,GAAG,CAAC,UAAU,EAAE,kBAAkB;AACpD,MAAM,WAAW;AACjB,KAAK,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACzD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C,MAAM,CAAC,WAAW,CAAC,CAAC;AACtF,MAAM,QAAQ,EAAE,UAAU;AAC1B,KAAK,CAAC;AACN,GAAG;AACH;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-backend-module-gitlab",
|
|
3
3
|
"description": "A Backstage catalog backend module that helps integrate towards GitLab",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.6-next.1",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -33,28 +33,28 @@
|
|
|
33
33
|
"start": "backstage-cli package start"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@backstage/backend-common": "^0.
|
|
37
|
-
"@backstage/backend-tasks": "^0.3.
|
|
38
|
-
"@backstage/catalog-model": "^1.1.0
|
|
36
|
+
"@backstage/backend-common": "^0.15.0-next.0",
|
|
37
|
+
"@backstage/backend-tasks": "^0.3.4-next.0",
|
|
38
|
+
"@backstage/catalog-model": "^1.1.0",
|
|
39
39
|
"@backstage/config": "^1.0.1",
|
|
40
|
-
"@backstage/errors": "^1.1.0
|
|
41
|
-
"@backstage/integration": "^1.
|
|
42
|
-
"@backstage/plugin-catalog-backend": "^1.3.
|
|
40
|
+
"@backstage/errors": "^1.1.0",
|
|
41
|
+
"@backstage/integration": "^1.3.0-next.0",
|
|
42
|
+
"@backstage/plugin-catalog-backend": "^1.3.1-next.2",
|
|
43
43
|
"@backstage/types": "^1.0.0",
|
|
44
44
|
"lodash": "^4.17.21",
|
|
45
|
-
"msw": "^0.
|
|
45
|
+
"msw": "^0.44.0",
|
|
46
46
|
"node-fetch": "^2.6.7",
|
|
47
47
|
"uuid": "^8.0.0",
|
|
48
48
|
"winston": "^3.2.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@backstage/backend-test-utils": "^0.1.
|
|
52
|
-
"@backstage/cli": "^0.18.
|
|
51
|
+
"@backstage/backend-test-utils": "^0.1.27-next.0",
|
|
52
|
+
"@backstage/cli": "^0.18.1-next.1",
|
|
53
53
|
"@types/lodash": "^4.14.151",
|
|
54
54
|
"@types/uuid": "^8.0.0"
|
|
55
55
|
},
|
|
56
56
|
"files": [
|
|
57
57
|
"dist"
|
|
58
58
|
],
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "9b7d23351cdbe29fb16060f6f9e8442932d3fa29"
|
|
60
60
|
}
|