设置蓝图
定义蓝图模式,开始构建软件目录。
什么是蓝图?
蓝图(Blueprint)是 Port 中的通用构建模块,表示可在 Port 中管理的资产,如 "微服务"(Microservice)、"环境"(Environments)、"包"(Packages)、"集群"(Clusters)、"数据库"(Databases)等。
蓝图完全可以定制,支持用户选择的任意数量的属性,所有属性都可以随心所欲地修改。
💡 通用蓝图
例如,蓝图可被用于来表示软件目录中的任何资产:
- 微服务;
- 软件包;
- 软件包版本;
- CI 工作;
- k8s 集群;
- 云账户;
- 云环境;
- 开发人员环境;
- 服务部署;
- Pods
- 虚拟机;
- 等等。
在live demo 示例中,我们可以看到包含所有蓝图的 DevPortal 生成器页面。
蓝图结构
每个蓝图由Json schema 表示,如下节所示:
{
"identifier": "myIdentifier",
"title": "My title",
"description": "My description",
"icon": "My icon",
"calculationProperties": {},
"schema": {
"properties": {
"myProp1": {
"type": "my_type",
"title": "My title"
},
"myProp2": {
"type": "my_special_type",
"title": "My special title"
}
},
"required": []
},
"relations": {}
}
结构表
Field | Description | Notes |
---|---|---|
identifier | Unique identifier | Required. The identifier is used for API calls, programmatic access and distinguishing between different blueprints |
title | Name | Required. Human-readable name for the blueprint |
description | Description | The value is visible as a tooltip to users when hovering over the info icon in the UI |
icon | Icon for the blueprint and entities of the blueprint. | See the full icon list below |
calculationProperties | Contains the properties defined using calculation properties | Required |
mirrorProperties | Contains the properties defined using mirror properties | |
schema | An object containing two nested fields: properties and required . | Required. See the schema structure here |
模式对象
"schema": {
"properties": {},
"required": []
}
Schema field | Description |
---|---|
properties | See the properties section for more details. |
required | A list of the required properties, out of the properties object list. These are mandatory fields to fill in the UI form. |
在 Port 中配置蓝图
- API
- Terraform
- Pulumi
- UI
{
"identifier": "myIdentifier",
"title": "My title",
"description": "My description",
"icon": "My icon",
"calculationProperties": {},
"schema": {
"properties": {},
"required": []
},
"relations": {}
}
Check out Port's API reference to learn more.
resource "port_blueprint" "myBlueprint" {
title = "My blueprint"
icon = "My icon"
identifier = "myIdentifier"
description = "My description"
properties {
string_props = {
"myProperty" = {
type = "string"
title = "My Property"
}
"myUrlProperty" = {
title = "URL Property"
format = "url"
}
}
}
}
- Python
- TypeScript
- JavaScript
- GO
"""A Python Pulumi program"""
impor t pulumi
from port_pulumi import Blueprint
blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
icon="My icon",
description="My description",
properties=port.BlueprintPropertiesArgs(
string_props={
"myStringProp": port.BlueprintPropertiesStringPropsArgs(
title="My string", required=False
),
"myUrlProp": port.BlueprintPropertiesStringPropsArgs(
title="My url", required=False, format="url"
),
"myEmailProp": port.BlueprintPropertiesStringPropsArgs(
title="My email", required=False, format="email"
),
"myUserProp": port.BlueprintPropertiesStringPropsArgs(
title="My user", required=False, format="user"
),
"myTeamProp": port.BlueprintPropertiesStringPropsArgs(
title="My team", required=False, format="team"
),
"myDatetimeProp": port.BlueprintPropertiesStringPropsArgs(
title="My datetime", required=False, format="date-time"
),
"myTimerProp": port.BlueprintPropertiesStringPropsArgs(
title="My timer", required=False, format="timer"
),
"myYAMLProp": port.BlueprintPropertiesStringPropsArgs(
title="My yaml", required=False, format="yaml"
),
}
)
)
import * as pulumi from "@pulumi/pulumi";
import * as port from "@port-labs/port";
export const blueprint = new port.Blueprint("myBlueprint", {
identifier: "myBlueprint",
title: "My Blueprint",
icon: "My icon",
description: "My description",
properties: [
{
identifier: "language",
title: "Language",
type: "string",
required: true,
},
],
});
"use strict";
const pulumi = require("@pulumi/pulumi");
const port = require("@port-labs/port");
const entity = new port.Blueprint("myBlueprint", {
title: "My Blueprint",
identifier: "myBlueprint",
icon: "My icon",
description: "My description",
properties: [
{
name: "language",
value: "Node",
},
],
});
exports.title = entity.title;
package main
import (
"github.com/port-labs/pulumi-port/sdk/go/port"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
blueprint, err := port.NewBlueprint(ctx, "myBlueprint", &port.BlueprintArgs{
Identifier: pulumi.String("myBlueprint"),
Title: pulumi.String("My Blueprint"),
Icon: pulumi.String("My icon"),
Description: pulumi.String("My description"),
Properties: port.BlueprintPropertiesArgs{
StringProps: port.BlueprintPropertiesStringPropsMap{
"myStringProp": port.BlueprintPropertiesStringPropsArgs{
Title: pulumi.String("My string"),
Required: pulumi.Bool(false),
},
},
},
})
ctx.Export("blueprint", blueprint.Title)
if err != nil {
return err
}
return nil
})
}
- 请访问DevPortal Builder page ;
- 点击右上角的添加蓝图;
- 使用 "从 "配置您的蓝图:
完整图标列表
API, Airflow, AmazonEKS, Ansible, ApiDoc, Aqua, Argo, ArgoRollouts, Aws, Azure, BitBucket, Bucket, Buddy, CPU, CPlusPlus, CSharp, Clickup, Cloud, Cluster, Codefresh, Confluence, Coralogix, Crossplane, Datadog, Day2Operation, DeployedAt, Deployment, DevopsTool, EC2, EU, Environment, Falcosidekick, Fluxcd, GKE, GPU, Git, GitLab, GitVersion, Github, GithubActions, Go, Google, GoogleCloud, GoogleCloudPlatform, GoogleComputeEngine, Grafana, Graphql, HashiCorp, Infinity, Istio, Jenkins, Jira, Kafka, Kiali, Kotlin, Lambda, Launchdarkly, Link, Lock, LucidCharts, Matlab, Microservice, MongoDb, Moon, NewRelic, Node, NodeJS, Notion, Okta, Package, Pearl, PostgreSQL, Prometheus, Pulumi, Python, R, React, RestApi, Ruby, S3, SDK, SQL, Scala, Sentry, Server, Service, Slack, Swagger, Swift, TS, Terraform, TwoUsers, Youtrack, Zipkin, checkmarx, css3, html5, java, js, kibana, logz, pagerduty, php, port, sonarqube, spinnaker