使用 monorepos
connecting your Git provider 到 Port 后,Port 会自动为安装集成的组织中的每个存储库创建一个实体。
如果你使用的是monorepo,并希望在单个仓库中为每个微服务创建一个实体,你可以通过调整 Git 集成的映射来实现这一点:
- 访问门户网站data-sources page 。
- 在 "Exporters"(出口商)下,点击要编辑的 Git Provider,例如
3.将打开一个窗口,其中包含集成的 YAML 映射。
根据被用于的情况使用以下代码段(在 resources
数组中添加 folder
条目,或者用它替换整个 YAML):
选择要包含的 repos 和文件夹 在下面的代码段中,复制前将
path
和 repos
字段更改为所需数值。- GitHub
- GitLab
- BitBucket
resources:
- kind: folder
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
folders: # Specify the repositories and folders to include under this relative path.
- path: apps/* # Relative path to the folders within the repositories.
repos: # List of repositories to include folders from.
- backend-service
- frontend-service
port:
entity:
mappings:
identifier: ".folder.name"
title: ".folder.name"
blueprint: '"service"'
properties:
url: .repo.html_url + "/tree/" + .repo.default_branch + "/" + .folder.path
readme: file://README.md
resources:
- kind: folder
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
folders: # Specify the repositories and folders to include under this relative path.
- path: "apps/" # Relative path to the folders within the repositories.
repos: # List of repositories to include folders from.
- backend-service
- frontend-service
port:
entity:
mappings:
identifier: .folder.name
title: .folder.name
blueprint: '"service"'
properties:
url: >-
.repo.web_url + "/tree/" + .repo.default_branch + "/" +
.folder.path
language: .repo.__languages | to_entries | max_by(.value) | .key
readme: file://README.md
resources:
- kind: folder
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
folders: # Specify the repositories and folders to include under this relative path.
- path: apps/* # Relative path to the folders within the repositories.
repos: # List of repositories to include folders from.
- backend-service
- frontend-service
port:
entity:
mappings:
identifier: .folder.name
blueprint: '"service"'
properties:
url: .repo.links.html.href + "/src/" + .repo.mainbranch.name + "/" + .folder.path
readme: file://README.md
4.点击 "Resync "应用更改。 5.返回catalog ,可以看到 Port 已为指定存储库中的每个文件夹创建了一个实体,而不是为每个存储库创建一个实体。