@backstage/plugin-catalog-backend-module-gitlab 0.1.8-next.2 → 0.1.9-next.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/CHANGELOG.md +36 -0
- package/alpha/package.json +6 -0
- package/config.d.ts +55 -0
- package/dist/index.alpha.d.ts +67 -0
- package/dist/index.beta.d.ts +62 -0
- package/dist/index.cjs.js +45 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +38 -23
- package/package.json +23 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.1.9-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6bb046bcbe: Add `gitlabDiscoveryEntityProviderCatalogModule` (new backend-plugin-api, alpha).
|
|
8
|
+
- 81cedb5033: `GitlabDiscoveryEntityProvider`: Add option to configure schedule via `app-config.yaml` instead of in code.
|
|
9
|
+
|
|
10
|
+
Please find how to configure the schedule at the config at
|
|
11
|
+
https://backstage.io/docs/integrations/gitlab/discovery
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/backend-common@0.16.0-next.0
|
|
15
|
+
- @backstage/plugin-catalog-backend@1.5.1-next.0
|
|
16
|
+
- @backstage/integration@1.4.0-next.0
|
|
17
|
+
- @backstage/backend-tasks@0.3.7-next.0
|
|
18
|
+
- @backstage/catalog-model@1.1.3-next.0
|
|
19
|
+
- @backstage/types@1.0.1-next.0
|
|
20
|
+
- @backstage/backend-plugin-api@0.1.4-next.0
|
|
21
|
+
- @backstage/plugin-catalog-node@1.2.1-next.0
|
|
22
|
+
- @backstage/config@1.0.4-next.0
|
|
23
|
+
- @backstage/errors@1.1.3-next.0
|
|
24
|
+
|
|
25
|
+
## 0.1.8
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
- @backstage/catalog-model@1.1.2
|
|
31
|
+
- @backstage/backend-common@0.15.2
|
|
32
|
+
- @backstage/plugin-catalog-backend@1.5.0
|
|
33
|
+
- @backstage/backend-tasks@0.3.6
|
|
34
|
+
- @backstage/config@1.0.3
|
|
35
|
+
- @backstage/errors@1.1.2
|
|
36
|
+
- @backstage/integration@1.3.2
|
|
37
|
+
- @backstage/types@1.0.0
|
|
38
|
+
|
|
3
39
|
## 0.1.8-next.2
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 The Backstage Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { TaskScheduleDefinitionConfig } from '@backstage/backend-tasks';
|
|
18
|
+
|
|
19
|
+
export interface Config {
|
|
20
|
+
catalog?: {
|
|
21
|
+
providers?: {
|
|
22
|
+
/**
|
|
23
|
+
* GitlabDiscoveryEntityProvider configuration
|
|
24
|
+
*/
|
|
25
|
+
gitlab?: Record<
|
|
26
|
+
string,
|
|
27
|
+
{
|
|
28
|
+
/**
|
|
29
|
+
* (Required) Gitlab's host name.
|
|
30
|
+
*/
|
|
31
|
+
host: string;
|
|
32
|
+
/**
|
|
33
|
+
* (Optional) Gitlab's group[/subgroup] where the discovery is done.
|
|
34
|
+
* If not defined the whole project will be scanned.
|
|
35
|
+
*/
|
|
36
|
+
group?: string;
|
|
37
|
+
/**
|
|
38
|
+
* (Optional) Default branch to read the catalog-info.yaml file.
|
|
39
|
+
* If not set, 'master' will be used.
|
|
40
|
+
*/
|
|
41
|
+
branch?: string;
|
|
42
|
+
/**
|
|
43
|
+
* (Optional) The name used for the catalog file.
|
|
44
|
+
* If not set, 'catalog-info.yaml' will be used.
|
|
45
|
+
*/
|
|
46
|
+
entityFilename?: string;
|
|
47
|
+
/**
|
|
48
|
+
* (Optional) TaskScheduleDefinition for the refresh.
|
|
49
|
+
*/
|
|
50
|
+
schedule?: TaskScheduleDefinitionConfig;
|
|
51
|
+
}
|
|
52
|
+
>;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Backstage catalog backend module that helps integrate towards GitLab
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
8
|
+
import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
|
|
9
|
+
import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
|
|
10
|
+
import { Config } from '@backstage/config';
|
|
11
|
+
import { EntityProvider } from '@backstage/plugin-catalog-backend';
|
|
12
|
+
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
|
13
|
+
import { LocationSpec } from '@backstage/plugin-catalog-backend';
|
|
14
|
+
import { Logger } from 'winston';
|
|
15
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
16
|
+
import { TaskRunner } from '@backstage/backend-tasks';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Discovers entity definition files in the groups of a Gitlab instance.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare class GitlabDiscoveryEntityProvider implements EntityProvider {
|
|
23
|
+
private readonly config;
|
|
24
|
+
private readonly integration;
|
|
25
|
+
private readonly logger;
|
|
26
|
+
private readonly scheduleFn;
|
|
27
|
+
private connection?;
|
|
28
|
+
static fromConfig(config: Config, options: {
|
|
29
|
+
logger: Logger;
|
|
30
|
+
schedule?: TaskRunner;
|
|
31
|
+
scheduler?: PluginTaskScheduler;
|
|
32
|
+
}): GitlabDiscoveryEntityProvider[];
|
|
33
|
+
private constructor();
|
|
34
|
+
getProviderName(): string;
|
|
35
|
+
connect(connection: EntityProviderConnection): Promise<void>;
|
|
36
|
+
private createScheduleFn;
|
|
37
|
+
refresh(logger: Logger): Promise<void>;
|
|
38
|
+
private createLocationSpec;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Registers the GitlabDiscoveryEntityProvider with the catalog processing extension point.
|
|
43
|
+
*
|
|
44
|
+
* @alpha
|
|
45
|
+
*/
|
|
46
|
+
export declare const gitlabDiscoveryEntityProviderCatalogModule: (options?: undefined) => BackendFeature;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Extracts repositories out of an GitLab instance.
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export declare class GitLabDiscoveryProcessor implements CatalogProcessor {
|
|
53
|
+
private readonly integrations;
|
|
54
|
+
private readonly logger;
|
|
55
|
+
private readonly cache;
|
|
56
|
+
private readonly skipReposWithoutExactFileMatch;
|
|
57
|
+
static fromConfig(config: Config, options: {
|
|
58
|
+
logger: Logger;
|
|
59
|
+
skipReposWithoutExactFileMatch?: boolean;
|
|
60
|
+
}): GitLabDiscoveryProcessor;
|
|
61
|
+
private constructor();
|
|
62
|
+
getProcessorName(): string;
|
|
63
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
64
|
+
private getCacheKey;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { }
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Backstage catalog backend module that helps integrate towards GitLab
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
8
|
+
import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
|
|
9
|
+
import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
|
|
10
|
+
import { Config } from '@backstage/config';
|
|
11
|
+
import { EntityProvider } from '@backstage/plugin-catalog-backend';
|
|
12
|
+
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
|
13
|
+
import { LocationSpec } from '@backstage/plugin-catalog-backend';
|
|
14
|
+
import { Logger } from 'winston';
|
|
15
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
16
|
+
import { TaskRunner } from '@backstage/backend-tasks';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Discovers entity definition files in the groups of a Gitlab instance.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare class GitlabDiscoveryEntityProvider implements EntityProvider {
|
|
23
|
+
private readonly config;
|
|
24
|
+
private readonly integration;
|
|
25
|
+
private readonly logger;
|
|
26
|
+
private readonly scheduleFn;
|
|
27
|
+
private connection?;
|
|
28
|
+
static fromConfig(config: Config, options: {
|
|
29
|
+
logger: Logger;
|
|
30
|
+
schedule?: TaskRunner;
|
|
31
|
+
scheduler?: PluginTaskScheduler;
|
|
32
|
+
}): GitlabDiscoveryEntityProvider[];
|
|
33
|
+
private constructor();
|
|
34
|
+
getProviderName(): string;
|
|
35
|
+
connect(connection: EntityProviderConnection): Promise<void>;
|
|
36
|
+
private createScheduleFn;
|
|
37
|
+
refresh(logger: Logger): Promise<void>;
|
|
38
|
+
private createLocationSpec;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Excluded from this release type: gitlabDiscoveryEntityProviderCatalogModule */
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Extracts repositories out of an GitLab instance.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare class GitLabDiscoveryProcessor implements CatalogProcessor {
|
|
48
|
+
private readonly integrations;
|
|
49
|
+
private readonly logger;
|
|
50
|
+
private readonly cache;
|
|
51
|
+
private readonly skipReposWithoutExactFileMatch;
|
|
52
|
+
static fromConfig(config: Config, options: {
|
|
53
|
+
logger: Logger;
|
|
54
|
+
skipReposWithoutExactFileMatch?: boolean;
|
|
55
|
+
}): GitLabDiscoveryProcessor;
|
|
56
|
+
private constructor();
|
|
57
|
+
getProcessorName(): string;
|
|
58
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
59
|
+
private getCacheKey;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { }
|
package/dist/index.cjs.js
CHANGED
|
@@ -6,7 +6,10 @@ var backendCommon = require('@backstage/backend-common');
|
|
|
6
6
|
var integration = require('@backstage/integration');
|
|
7
7
|
var pluginCatalogBackend = require('@backstage/plugin-catalog-backend');
|
|
8
8
|
var fetch = require('node-fetch');
|
|
9
|
+
var backendTasks = require('@backstage/backend-tasks');
|
|
9
10
|
var uuid = require('uuid');
|
|
11
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
12
|
+
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
10
13
|
|
|
11
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
15
|
|
|
@@ -117,13 +120,15 @@ function readGitlabConfig(id, config) {
|
|
|
117
120
|
const projectPattern = new RegExp(
|
|
118
121
|
(_d = config.getOptionalString("projectPattern")) != null ? _d : /[\s\S]*/
|
|
119
122
|
);
|
|
123
|
+
const schedule = config.has("schedule") ? backendTasks.readTaskScheduleDefinitionFromConfig(config.getConfig("schedule")) : void 0;
|
|
120
124
|
return {
|
|
121
125
|
id,
|
|
122
126
|
group,
|
|
123
127
|
branch,
|
|
124
128
|
host,
|
|
125
129
|
catalogFile,
|
|
126
|
-
projectPattern
|
|
130
|
+
projectPattern,
|
|
131
|
+
schedule
|
|
127
132
|
};
|
|
128
133
|
}
|
|
129
134
|
function readGitlabConfigs(config) {
|
|
@@ -245,21 +250,32 @@ function parseUrl(urlString) {
|
|
|
245
250
|
|
|
246
251
|
class GitlabDiscoveryEntityProvider {
|
|
247
252
|
static fromConfig(config, options) {
|
|
253
|
+
if (!options.schedule && !options.scheduler) {
|
|
254
|
+
throw new Error("Either schedule or scheduler must be provided.");
|
|
255
|
+
}
|
|
248
256
|
const providerConfigs = readGitlabConfigs(config);
|
|
249
257
|
const integrations = integration.ScmIntegrations.fromConfig(config).gitlab;
|
|
250
258
|
const providers = [];
|
|
251
259
|
providerConfigs.forEach((providerConfig) => {
|
|
260
|
+
var _a;
|
|
252
261
|
const integration = integrations.byHost(providerConfig.host);
|
|
253
262
|
if (!integration) {
|
|
254
263
|
throw new Error(
|
|
255
264
|
`No gitlab integration found that matches host ${providerConfig.host}`
|
|
256
265
|
);
|
|
257
266
|
}
|
|
267
|
+
if (!options.schedule && !providerConfig.schedule) {
|
|
268
|
+
throw new Error(
|
|
269
|
+
`No schedule provided neither via code nor config for GitlabDiscoveryEntityProvider:${providerConfig.id}.`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
const taskRunner = (_a = options.schedule) != null ? _a : options.scheduler.createScheduledTaskRunner(providerConfig.schedule);
|
|
258
273
|
providers.push(
|
|
259
274
|
new GitlabDiscoveryEntityProvider({
|
|
260
275
|
...options,
|
|
261
276
|
config: providerConfig,
|
|
262
|
-
integration
|
|
277
|
+
integration,
|
|
278
|
+
taskRunner
|
|
263
279
|
})
|
|
264
280
|
);
|
|
265
281
|
});
|
|
@@ -271,7 +287,7 @@ class GitlabDiscoveryEntityProvider {
|
|
|
271
287
|
this.logger = options.logger.child({
|
|
272
288
|
target: this.getProviderName()
|
|
273
289
|
});
|
|
274
|
-
this.scheduleFn = this.createScheduleFn(options.
|
|
290
|
+
this.scheduleFn = this.createScheduleFn(options.taskRunner);
|
|
275
291
|
}
|
|
276
292
|
getProviderName() {
|
|
277
293
|
return `GitlabDiscoveryEntityProvider:${this.config.id}`;
|
|
@@ -280,10 +296,10 @@ class GitlabDiscoveryEntityProvider {
|
|
|
280
296
|
this.connection = connection;
|
|
281
297
|
await this.scheduleFn();
|
|
282
298
|
}
|
|
283
|
-
createScheduleFn(
|
|
299
|
+
createScheduleFn(taskRunner) {
|
|
284
300
|
return async () => {
|
|
285
301
|
const taskId = `${this.getProviderName()}:refresh`;
|
|
286
|
-
return
|
|
302
|
+
return taskRunner.run({
|
|
287
303
|
id: taskId,
|
|
288
304
|
fn: async () => {
|
|
289
305
|
const logger = this.logger.child({
|
|
@@ -364,6 +380,30 @@ class GitlabDiscoveryEntityProvider {
|
|
|
364
380
|
}
|
|
365
381
|
}
|
|
366
382
|
|
|
383
|
+
const gitlabDiscoveryEntityProviderCatalogModule = backendPluginApi.createBackendModule({
|
|
384
|
+
pluginId: "catalog",
|
|
385
|
+
moduleId: "gitlabDiscoveryEntityProvider",
|
|
386
|
+
register(env) {
|
|
387
|
+
env.registerInit({
|
|
388
|
+
deps: {
|
|
389
|
+
config: backendPluginApi.configServiceRef,
|
|
390
|
+
catalog: pluginCatalogNode.catalogProcessingExtensionPoint,
|
|
391
|
+
logger: backendPluginApi.loggerServiceRef,
|
|
392
|
+
scheduler: backendPluginApi.schedulerServiceRef
|
|
393
|
+
},
|
|
394
|
+
async init({ config, catalog, logger, scheduler }) {
|
|
395
|
+
catalog.addEntityProvider(
|
|
396
|
+
GitlabDiscoveryEntityProvider.fromConfig(config, {
|
|
397
|
+
logger: backendPluginApi.loggerToWinstonLogger(logger),
|
|
398
|
+
scheduler
|
|
399
|
+
})
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
|
|
367
406
|
exports.GitLabDiscoveryProcessor = GitLabDiscoveryProcessor;
|
|
368
407
|
exports.GitlabDiscoveryEntityProvider = GitlabDiscoveryEntityProvider;
|
|
408
|
+
exports.gitlabDiscoveryEntityProviderCatalogModule = gitlabDiscoveryEntityProviderCatalogModule;
|
|
369
409
|
//# sourceMappingURL=index.cjs.js.map
|
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';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,MAAM,YAAa,CAAA;AAAA,EAIxB,YAAY,OAA8D,EAAA;AACxE,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA,CAAA;AACtB,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA,CAAA;AAAA,GACxB;AAAA,EAKA,aAAyB,GAAA;AACvB,IAAO,OAAA,IAAA,CAAK,OAAO,IAAS,KAAA,YAAA,CAAA;AAAA,GAC9B;AAAA,EAEA,MAAM,aAAa,OAAoD,EAAA;AACrE,IAAA,IAAI,mCAAS,KAAO,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DiscoveryEntityProvider.ts","../src/service/GitlabDiscoveryEntityProviderCatalogModule.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 { readTaskScheduleDefinitionFromConfig } from '@backstage/backend-tasks';\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 const schedule = config.has('schedule')\n ? readTaskScheduleDefinitionFromConfig(config.getConfig('schedule'))\n : undefined;\n\n return {\n id,\n group,\n branch,\n host,\n catalogFile,\n projectPattern,\n schedule,\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 { PluginTaskScheduler, TaskRunner } from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { GitLabIntegration, ScmIntegrations } from '@backstage/integration';\nimport {\n EntityProvider,\n EntityProviderConnection,\n LocationSpec,\n locationSpecToLocationEntity,\n} from '@backstage/plugin-catalog-backend';\nimport * as uuid from 'uuid';\nimport { Logger } from 'winston';\nimport {\n GitLabClient,\n GitLabProject,\n GitlabProviderConfig,\n paginated,\n readGitlabConfigs,\n} from '../lib';\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: {\n logger: Logger;\n schedule?: TaskRunner;\n scheduler?: PluginTaskScheduler;\n },\n ): GitlabDiscoveryEntityProvider[] {\n if (!options.schedule && !options.scheduler) {\n throw new Error('Either schedule or scheduler must be provided.');\n }\n\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\n if (!options.schedule && !providerConfig.schedule) {\n throw new Error(\n `No schedule provided neither via code nor config for GitlabDiscoveryEntityProvider:${providerConfig.id}.`,\n );\n }\n\n const taskRunner =\n options.schedule ??\n options.scheduler!.createScheduledTaskRunner(providerConfig.schedule!);\n\n providers.push(\n new GitlabDiscoveryEntityProvider({\n ...options,\n config: providerConfig,\n integration,\n taskRunner,\n }),\n );\n });\n return providers;\n }\n\n private constructor(options: {\n config: GitlabProviderConfig;\n integration: GitLabIntegration;\n logger: Logger;\n taskRunner: 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.taskRunner);\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(taskRunner: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return taskRunner.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","/*\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 {\n createBackendModule,\n loggerToWinstonLogger,\n configServiceRef,\n loggerServiceRef,\n schedulerServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node';\nimport { GitlabDiscoveryEntityProvider } from '../providers';\n\n/**\n * Registers the GitlabDiscoveryEntityProvider with the catalog processing extension point.\n *\n * @alpha\n */\nexport const gitlabDiscoveryEntityProviderCatalogModule = createBackendModule({\n pluginId: 'catalog',\n moduleId: 'gitlabDiscoveryEntityProvider',\n register(env) {\n env.registerInit({\n deps: {\n config: configServiceRef,\n catalog: catalogProcessingExtensionPoint,\n logger: loggerServiceRef,\n scheduler: schedulerServiceRef,\n },\n async init({ config, catalog, logger, scheduler }) {\n catalog.addEntityProvider(\n GitlabDiscoveryEntityProvider.fromConfig(config, {\n logger: loggerToWinstonLogger(logger),\n scheduler,\n }),\n );\n },\n });\n },\n});\n"],"names":["fetch","getGitLabRequestOptions","readTaskScheduleDefinitionFromConfig","ScmIntegrations","CacheManager","processingResult","uuid","locationSpecToLocationEntity","createBackendModule","configServiceRef","catalogProcessingExtensionPoint","loggerServiceRef","schedulerServiceRef","loggerToWinstonLogger"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,MAAM,YAAa,CAAA;AAAA,EAIxB,YAAY,OAA8D,EAAA;AACxE,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA,CAAA;AACtB,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA,CAAA;AAAA,GACxB;AAAA,EAKA,aAAyB,GAAA;AACvB,IAAO,OAAA,IAAA,CAAK,OAAO,IAAS,KAAA,YAAA,CAAA;AAAA,GAC9B;AAAA,EAEA,MAAM,aAAa,OAAoD,EAAA;AACrE,IAAA,IAAI,mCAAS,KAAO,EAAA;AAClB,MAAA,OAAO,IAAK,CAAA,YAAA;AAAA,QACV,CAAA,QAAA,EAAW,kBAAmB,CAAA,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAS,KAAK,CAAA,CAAA,SAAA,CAAA;AAAA,QAC5C;AAAA,UACE,GAAG,OAAA;AAAA,UACH,iBA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,GAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,cAAR,KAAA,IAAA,GAAA,EAAA,GAA0B,KAAK,MAAO,CAAA,MAAA,CAAA;AAC7D,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,KAAA;AAAA,MACN,QAAQ,CAAG,EAAA,OAAA,CAAQ,OAAkB,CAAA,QAAA,EAAA,cAAA,CAAA,CAAA,EAAkB,KAAK,MAAO,CAAA,WAAA,CAAA,CAAA;AAAA,MACnE,QAAU,EAAA,UAAA;AAAA,KACZ,CAAA;AAAA,GACF;AACF;;ACtLO,MAAM,6CAA6CC,oCAAoB,CAAA;AAAA,EAC5E,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,+BAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAQ,EAAAC,iCAAA;AAAA,QACR,OAAS,EAAAC,iDAAA;AAAA,QACT,MAAQ,EAAAC,iCAAA;AAAA,QACR,SAAW,EAAAC,oCAAA;AAAA,OACb;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,QAAQ,OAAS,EAAA,MAAA,EAAQ,WAAa,EAAA;AACjD,QAAQ,OAAA,CAAA,iBAAA;AAAA,UACN,6BAAA,CAA8B,WAAW,MAAQ,EAAA;AAAA,YAC/C,MAAA,EAAQC,uCAAsB,MAAM,CAAA;AAAA,YACpC,SAAA;AAAA,WACD,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Backstage catalog backend module that helps integrate towards GitLab
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
8
|
+
import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
|
|
9
|
+
import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
|
|
1
10
|
import { Config } from '@backstage/config';
|
|
2
|
-
import {
|
|
11
|
+
import { EntityProvider } from '@backstage/plugin-catalog-backend';
|
|
12
|
+
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
|
13
|
+
import { LocationSpec } from '@backstage/plugin-catalog-backend';
|
|
3
14
|
import { Logger } from 'winston';
|
|
15
|
+
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
|
4
16
|
import { TaskRunner } from '@backstage/backend-tasks';
|
|
5
17
|
|
|
6
|
-
/**
|
|
7
|
-
* Extracts repositories out of an GitLab instance.
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
declare class GitLabDiscoveryProcessor implements CatalogProcessor {
|
|
11
|
-
private readonly integrations;
|
|
12
|
-
private readonly logger;
|
|
13
|
-
private readonly cache;
|
|
14
|
-
private readonly skipReposWithoutExactFileMatch;
|
|
15
|
-
static fromConfig(config: Config, options: {
|
|
16
|
-
logger: Logger;
|
|
17
|
-
skipReposWithoutExactFileMatch?: boolean;
|
|
18
|
-
}): GitLabDiscoveryProcessor;
|
|
19
|
-
private constructor();
|
|
20
|
-
getProcessorName(): string;
|
|
21
|
-
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
22
|
-
private getCacheKey;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
18
|
/**
|
|
26
19
|
* Discovers entity definition files in the groups of a Gitlab instance.
|
|
27
20
|
* @public
|
|
28
21
|
*/
|
|
29
|
-
declare class GitlabDiscoveryEntityProvider implements EntityProvider {
|
|
22
|
+
export declare class GitlabDiscoveryEntityProvider implements EntityProvider {
|
|
30
23
|
private readonly config;
|
|
31
24
|
private readonly integration;
|
|
32
25
|
private readonly logger;
|
|
@@ -34,7 +27,8 @@ declare class GitlabDiscoveryEntityProvider implements EntityProvider {
|
|
|
34
27
|
private connection?;
|
|
35
28
|
static fromConfig(config: Config, options: {
|
|
36
29
|
logger: Logger;
|
|
37
|
-
schedule
|
|
30
|
+
schedule?: TaskRunner;
|
|
31
|
+
scheduler?: PluginTaskScheduler;
|
|
38
32
|
}): GitlabDiscoveryEntityProvider[];
|
|
39
33
|
private constructor();
|
|
40
34
|
getProviderName(): string;
|
|
@@ -44,4 +38,25 @@ declare class GitlabDiscoveryEntityProvider implements EntityProvider {
|
|
|
44
38
|
private createLocationSpec;
|
|
45
39
|
}
|
|
46
40
|
|
|
47
|
-
|
|
41
|
+
/* Excluded from this release type: gitlabDiscoveryEntityProviderCatalogModule */
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Extracts repositories out of an GitLab instance.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare class GitLabDiscoveryProcessor implements CatalogProcessor {
|
|
48
|
+
private readonly integrations;
|
|
49
|
+
private readonly logger;
|
|
50
|
+
private readonly cache;
|
|
51
|
+
private readonly skipReposWithoutExactFileMatch;
|
|
52
|
+
static fromConfig(config: Config, options: {
|
|
53
|
+
logger: Logger;
|
|
54
|
+
skipReposWithoutExactFileMatch?: boolean;
|
|
55
|
+
}): GitLabDiscoveryProcessor;
|
|
56
|
+
private constructor();
|
|
57
|
+
getProcessorName(): string;
|
|
58
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
59
|
+
private getCacheKey;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
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.9-next.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public",
|
|
10
|
+
"alphaTypes": "dist/index.alpha.d.ts",
|
|
10
11
|
"main": "dist/index.cjs.js",
|
|
11
12
|
"types": "dist/index.d.ts"
|
|
12
13
|
},
|
|
@@ -23,23 +24,25 @@
|
|
|
23
24
|
"backstage"
|
|
24
25
|
],
|
|
25
26
|
"scripts": {
|
|
26
|
-
"
|
|
27
|
+
"start": "backstage-cli package start",
|
|
28
|
+
"build": "backstage-cli package build --experimental-type-build",
|
|
27
29
|
"lint": "backstage-cli package lint",
|
|
28
30
|
"test": "backstage-cli package test",
|
|
29
31
|
"prepack": "backstage-cli package prepack",
|
|
30
32
|
"postpack": "backstage-cli package postpack",
|
|
31
|
-
"clean": "backstage-cli package clean"
|
|
32
|
-
"start": "backstage-cli package start"
|
|
33
|
+
"clean": "backstage-cli package clean"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@backstage/backend-common": "^0.
|
|
36
|
-
"@backstage/backend-
|
|
37
|
-
"@backstage/
|
|
38
|
-
"@backstage/
|
|
39
|
-
"@backstage/
|
|
40
|
-
"@backstage/
|
|
41
|
-
"@backstage/
|
|
42
|
-
"@backstage/
|
|
36
|
+
"@backstage/backend-common": "^0.16.0-next.0",
|
|
37
|
+
"@backstage/backend-plugin-api": "^0.1.4-next.0",
|
|
38
|
+
"@backstage/backend-tasks": "^0.3.7-next.0",
|
|
39
|
+
"@backstage/catalog-model": "^1.1.3-next.0",
|
|
40
|
+
"@backstage/config": "^1.0.4-next.0",
|
|
41
|
+
"@backstage/errors": "^1.1.3-next.0",
|
|
42
|
+
"@backstage/integration": "^1.4.0-next.0",
|
|
43
|
+
"@backstage/plugin-catalog-backend": "^1.5.1-next.0",
|
|
44
|
+
"@backstage/plugin-catalog-node": "^1.2.1-next.0",
|
|
45
|
+
"@backstage/types": "^1.0.1-next.0",
|
|
43
46
|
"lodash": "^4.17.21",
|
|
44
47
|
"msw": "^0.47.0",
|
|
45
48
|
"node-fetch": "^2.6.7",
|
|
@@ -47,12 +50,16 @@
|
|
|
47
50
|
"winston": "^3.2.1"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
|
-
"@backstage/backend-test-utils": "^0.1.
|
|
51
|
-
"@backstage/cli": "^0.
|
|
53
|
+
"@backstage/backend-test-utils": "^0.1.30-next.0",
|
|
54
|
+
"@backstage/cli": "^0.21.0-next.0",
|
|
52
55
|
"@types/lodash": "^4.14.151",
|
|
53
|
-
"@types/uuid": "^8.0.0"
|
|
56
|
+
"@types/uuid": "^8.0.0",
|
|
57
|
+
"luxon": "^3.0.0"
|
|
54
58
|
},
|
|
55
59
|
"files": [
|
|
60
|
+
"alpha",
|
|
61
|
+
"config.d.ts",
|
|
56
62
|
"dist"
|
|
57
|
-
]
|
|
63
|
+
],
|
|
64
|
+
"configSchema": "config.d.ts"
|
|
58
65
|
}
|