Skip to main content

格里特发现

Gerrit 集成有一个特殊的实体提供程序,用于从 Gerrit 资源库中发现目录实体。 该提供程序使用 Gerrit 中的 "List Projects(列出项目)"API 来获取资源库列表,并自动摄取所有项目。catalog-info.yaml文件存储在匹配项目的根目录中。

安装

由于该提供程序不是默认提供程序之一,因此首先需要安装 Gerrit 提供程序插件:

# From your Backstage root directory
yarn add --cwd packages/backend @backstage/plugin-catalog-backend-module-gerrit

然后将插件添加到插件目录中packages/backend/src/plugins/catalog.ts:

/* packages/backend/src/plugins/catalog.ts */
import { GerritEntityProvider } from '@backstage/plugin-catalog-backend-module-gerrit';
const builder = await CatalogBuilder.create(env);
/** ... other processors and/or providers ... */
builder.addEntityProvider(
GerritEntityProvider.fromConfig(env.config, {
logger: env.logger,
scheduler: env.scheduler,
}),
);

配置

要使用发现处理器,您需要与 Gerrit 集成设立然后,您可以添加任意数量的提供商。

# app-config.yaml
catalog:
providers:
gerrit:
yourProviderId: # identifies your dataset / provider independent of config changes
host: gerrit-your-company.com
branch: master # Optional
query: 'state=ACTIVE&prefix=webapps'
schedule:
# supports cron, ISO duration, "human duration" as used in code
frequency: { minutes: 30 }
# supports ISO duration, "human duration" as used in code
timeout: { minutes: 3 }
backend:
host: gerrit-your-company.com
branch: master # Optional
query: 'state=ACTIVE&prefix=backend'

提供商配置由三部分组成:

host:要使用的 Gerrit 集成的主机。 branch(可选):我们要查找目录实体的分支(默认为 "master")。 query:这个字符串直接用作 "List Project"(列出项目)API 的参数。 通常情况下,你会希望在这里设置一些过滤器,以排除那些永远不会包含任何目录文件的项目。