@backstage/plugin-catalog-backend-module-gitlab 0.0.0-nightly-20220607024221 → 0.0.0-nightly-20220610024824
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 +15 -5
- package/dist/index.cjs.js +11 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-gitlab
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20220610024824
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- bad907d794: The `last_activity_after` timestamp is now being omitted when querying the GitLab API for the first time.
|
|
7
8
|
- 3ac4522537: do not create location object if file with component definition do not exists in project, that decrease count of request to gitlab with 404 status code. Now we can create processor with new flag to enable this logic:
|
|
8
9
|
|
|
9
10
|
```ts
|
|
@@ -17,10 +18,19 @@
|
|
|
17
18
|
|
|
18
19
|
- 8f7b1835df: Updated dependency `msw` to `^0.41.0`.
|
|
19
20
|
- Updated dependencies
|
|
20
|
-
- @backstage/backend-common@0.0.0-nightly-
|
|
21
|
-
- @backstage/integration@0.0.0-nightly-
|
|
22
|
-
- @backstage/plugin-catalog-backend@0.0.0-nightly-
|
|
23
|
-
- @backstage/catalog-model@0.0.0-nightly-
|
|
21
|
+
- @backstage/backend-common@0.0.0-nightly-20220610024824
|
|
22
|
+
- @backstage/integration@0.0.0-nightly-20220610024824
|
|
23
|
+
- @backstage/plugin-catalog-backend@0.0.0-nightly-20220610024824
|
|
24
|
+
- @backstage/catalog-model@0.0.0-nightly-20220610024824
|
|
25
|
+
|
|
26
|
+
## 0.1.4-next.2
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @backstage/backend-common@0.14.0-next.2
|
|
32
|
+
- @backstage/integration@1.2.1-next.2
|
|
33
|
+
- @backstage/plugin-catalog-backend@1.2.0-next.2
|
|
24
34
|
|
|
25
35
|
## 0.1.4-next.1
|
|
26
36
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -99,6 +99,7 @@ class GitLabDiscoveryProcessor {
|
|
|
99
99
|
if (location.type !== "gitlab-discovery") {
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
102
|
+
const startTime = new Date();
|
|
102
103
|
const { group, host, branch, catalogPath } = parseUrl(location.target);
|
|
103
104
|
const integration = this.integrations.gitlab.byUrl(`https://${host}`);
|
|
104
105
|
if (!integration) {
|
|
@@ -108,13 +109,14 @@ class GitLabDiscoveryProcessor {
|
|
|
108
109
|
config: integration.config,
|
|
109
110
|
logger: this.logger
|
|
110
111
|
});
|
|
111
|
-
const startTimestamp = Date.now();
|
|
112
112
|
this.logger.debug(`Reading GitLab projects from ${location.target}`);
|
|
113
|
-
const
|
|
113
|
+
const lastActivity = await this.cache.get(this.getCacheKey());
|
|
114
|
+
const opts = {
|
|
114
115
|
group,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
116
|
+
page: 1,
|
|
117
|
+
...lastActivity && { last_activity_after: lastActivity }
|
|
118
|
+
};
|
|
119
|
+
const projects = paginated((options) => client.listProjects(options), opts);
|
|
118
120
|
const res = {
|
|
119
121
|
scanned: 0,
|
|
120
122
|
matches: []
|
|
@@ -144,15 +146,13 @@ class GitLabDiscoveryProcessor {
|
|
|
144
146
|
presence: "optional"
|
|
145
147
|
}));
|
|
146
148
|
}
|
|
147
|
-
|
|
149
|
+
await this.cache.set(this.getCacheKey(), startTime.toISOString());
|
|
150
|
+
const duration = ((Date.now() - startTime.getTime()) / 1e3).toFixed(1);
|
|
148
151
|
this.logger.debug(`Read ${res.scanned} GitLab repositories in ${duration} seconds`);
|
|
149
152
|
return true;
|
|
150
153
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const lastActivity = await this.cache.get(cacheKey);
|
|
154
|
-
await this.cache.set(cacheKey, new Date().toISOString());
|
|
155
|
-
return lastActivity;
|
|
154
|
+
getCacheKey() {
|
|
155
|
+
return `processors/${this.getProcessorName()}/last-activity`;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
function parseUrl(urlString) {
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/lib/client.ts","../src/GitLabDiscoveryProcessor.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 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 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 { 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 const startTimestamp = Date.now();\n this.logger.debug(`Reading GitLab projects from ${location.target}`);\n\n const projects = paginated(options => client.listProjects(options), {\n group,\n last_activity_after: await this.updateLastActivity(),\n page: 1,\n });\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 const duration = ((Date.now() - startTimestamp) / 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 async updateLastActivity(): Promise<string | undefined> {\n const cacheKey = `processors/${this.getProcessorName()}/last-activity`;\n const lastActivity = await this.cache.get(cacheKey);\n await this.cache.set(cacheKey, new Date().toISOString());\n return lastActivity as string | undefined;\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"],"names":["fetch","getGitLabRequestOptions","ScmIntegrations","CacheManager","processingResult"],"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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I,OAAO;AACX,MAAM,KAAK;AACX,MAAM,IAAI,EAAE,GAAG,CAAC,IAAI;AACpB,MAAM,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;AACrD,MAAM,WAAW,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1E,KAAK,CAAC;AACN,GAAG;AACH,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;AAClD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/lib/client.ts","../src/GitLabDiscoveryProcessor.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 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 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"],"names":["fetch","getGitLabRequestOptions","ScmIntegrations","CacheManager","processingResult"],"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,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C,CAAC;AACxD,EAAE,IAAI,SAAS,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,SAAS,GAAG,CAAC,EAAE;AACvD,IAAI,MAAM,KAAK,GAAG,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;AAC9E,IAAI,OAAO;AACX,MAAM,KAAK;AACX,MAAM,IAAI,EAAE,GAAG,CAAC,IAAI;AACpB,MAAM,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;AACrD,MAAM,WAAW,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1E,KAAK,CAAC;AACN,GAAG;AACH,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;AAClD;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare class GitLabDiscoveryProcessor implements CatalogProcessor {
|
|
|
18
18
|
private constructor();
|
|
19
19
|
getProcessorName(): string;
|
|
20
20
|
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
21
|
-
private
|
|
21
|
+
private getCacheKey;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export { GitLabDiscoveryProcessor };
|
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.0.0-nightly-
|
|
4
|
+
"version": "0.0.0-nightly-20220610024824",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"start": "backstage-cli package start"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@backstage/backend-common": "^0.0.0-nightly-
|
|
37
|
-
"@backstage/catalog-model": "^0.0.0-nightly-
|
|
36
|
+
"@backstage/backend-common": "^0.0.0-nightly-20220610024824",
|
|
37
|
+
"@backstage/catalog-model": "^0.0.0-nightly-20220610024824",
|
|
38
38
|
"@backstage/config": "^1.0.1",
|
|
39
39
|
"@backstage/errors": "^1.0.0",
|
|
40
|
-
"@backstage/integration": "^0.0.0-nightly-
|
|
41
|
-
"@backstage/plugin-catalog-backend": "^0.0.0-nightly-
|
|
40
|
+
"@backstage/integration": "^0.0.0-nightly-20220610024824",
|
|
41
|
+
"@backstage/plugin-catalog-backend": "^0.0.0-nightly-20220610024824",
|
|
42
42
|
"@backstage/types": "^1.0.0",
|
|
43
43
|
"lodash": "^4.17.21",
|
|
44
44
|
"msw": "^0.42.0",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"winston": "^3.2.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@backstage/backend-test-utils": "^0.0.0-nightly-
|
|
50
|
-
"@backstage/cli": "^0.0.0-nightly-
|
|
49
|
+
"@backstage/backend-test-utils": "^0.0.0-nightly-20220610024824",
|
|
50
|
+
"@backstage/cli": "^0.0.0-nightly-20220610024824",
|
|
51
51
|
"@types/lodash": "^4.14.151"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|