Added project pattern for GitLab provider to be able to filter projects on more granular level.
Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
@@ -35,4 +35,5 @@ export type GitlabProviderConfig = {
|
||||
id: string;
|
||||
branch: string;
|
||||
catalogFile: string;
|
||||
projectPattern: RegExp;
|
||||
};
|
||||
|
||||
@@ -147,6 +147,10 @@ export class GitlabDiscoveryEntityProvider implements EntityProvider {
|
||||
};
|
||||
|
||||
for await (const project of projects) {
|
||||
if (!this.config.projectPattern.test(project.path_with_namespace ?? '')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res.scanned++;
|
||||
|
||||
if (project.archived) {
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
|
||||
import { Config } from '@backstage/config';
|
||||
import { GitlabProviderConfig } from '../lib/types';
|
||||
import { GitlabProviderConfig } from '../lib';
|
||||
|
||||
/**
|
||||
* Extracts the gitlab config from a config object
|
||||
*
|
||||
* @public
|
||||
*
|
||||
* @param id - The provider key
|
||||
* @param config - The config object to extract from
|
||||
*/
|
||||
function readGitlabConfig(id: string, config: Config): GitlabProviderConfig {
|
||||
@@ -30,6 +31,8 @@ function readGitlabConfig(id: string, config: Config): GitlabProviderConfig {
|
||||
const branch = config.getOptionalString('branch') ?? 'master';
|
||||
const catalogFile =
|
||||
config.getOptionalString('entityFilename') ?? 'catalog-info.yaml';
|
||||
const projectPattern =
|
||||
new RegExp(config.getString('projectPattern')) ?? /[\s\S]*/;
|
||||
|
||||
return {
|
||||
id,
|
||||
@@ -37,6 +40,7 @@ function readGitlabConfig(id: string, config: Config): GitlabProviderConfig {
|
||||
branch,
|
||||
host,
|
||||
catalogFile,
|
||||
projectPattern,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user