相关蓝图
关系定义了蓝图之间的连接,并将其转化为软件目录中资产的依赖性反映。
什么是关系?
关系使我们能够在蓝图之间建立联系,从而将基于这些蓝图的实体连接起来。 这就为软件目录提供了逻辑上下文。
💡 共同关系
例如,关系可被用于来表示软件目录中资产之间的逻辑联系:
- 一个微服务被用于的packages;
- 一个CI作业的运行历史记录;
- 一个云账户中存在的Kubernetes集群**;
- 等等。
在live demo 示例中,我们可以看到 DevPortal 生成器页面,其中包含所有蓝图及其关系。
关系模式结构
关系对象的基本结构:
{
"myRelation": {
"title": "My title",
"target": "My target blueprint",
"required": true,
"many": false
}
}
关系中的 "relations "键下存在一个关系。Blueprint JSON schema
结构表
Field | Description | Notes |
---|---|---|
identifier | Unique identifier | The identifier is used for API calls, programmatic access and distinguishing between different relations. The identifier is the key of the relation schema object, in the schema structure above, the identifier is myRelation |
title | Relation name that will be shown in the UI | Human-readable name for the relation |
target | Target blueprint identifier | The target blueprint has to exist when defining the relation |
required | Boolean flag to define whether the target must be provided when creating a new entity of the blueprint | |
many | Boolean flag to define whether multiple target entities can be mapped to the Relation | For more information refer to many relation |
关系类型
👤 Single
单一类型关系被用来将单一目标实体映射到源实体。
💡 共同单一关系
- 将部署映射到所部署的运行服务;
- 将包版本映射到包;
- 将k8s 集群映射到它所配置的云账户;
- 等等。
在live demo 这个例子中,我们可以看到一个特定的软件包版本及其相关的核心软件包。 🎬
单一关系结构
单一类型关系由 many: false
配置区分:
- API
- Terraform
{
"myRelation": {
"title": "My title",
"target": "myTargetBlueprint",
"required": false,
"many": false
}
}
Check out Port's API reference to learn more.
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
# ...user-defined properties
relations {
identifier = "myRelation"
title = "My relation"
target = "myTargetBlueprint"
required = false
many = false
}
}
👥 许多
多类型关系被用来将多个目标实体映射到源实体。
💡 常 见的多种关系
- 映射服务之间的依赖关系;
- 映射服务被用于的packages**;
- 映射服务被用于的云资源;
- 映射在开发环境中部署的服务;
- 等等。
在这个live demo 示例中,我们可以看到一个特定的开发人员环境及其被用于的运行服务。 🎬
多关系结构
多类型关系由 many: true
配置区分:
- API
- Terraform
{
"myRelation": {
"title": "My title",
"target": "myTargetBlueprint",
"required": false,
"many": true
}
}
Check out Port's API reference to learn more.
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
# ...user-defined properties
relations {
identifier = "myRelation"
title = "My relation"
target = "myTargetBlueprint"
required = false
many = true
}
}
关系 "的 "many "和 "required "均设为 "true "时无法配置
在 Port 中配置关系
关系是blueprint 结构的一部分。
- API
- UI
- Terraform
{
"identifier": "myIdentifier",
"title": "My title",
"description": "My description",
"icon": "My icon",
"calculationProperties": {},
"schema": {
"properties": {},
"required": []
},
"relations": {
"myRelation": {
"title": "My title",
"target": "My target blueprint",
"required": true,
"many": false
}
}
}
Check out Port's API reference to learn more.
- 请访问DevPortal Builder page ;
- 单击关系的 "源 "蓝图上的铅笔图标:
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
# ...user-defined properties
relations = {
"myRelation" = {
title = "My title"
target = "My target blueprint"
required = true
many = false
}
}
}
一旦添加到蓝图定义中,您就可以apply the blueprint 到 Port