用户
User 是一种数据类型,用于引用存在于 Port 中的用户。
💡 用户常用 Usage
例如,用户属性类型可被用来引用 Port 中存在的任何用户:
- Owners;
- 当前值班人员
- 主要维护者;
- 等等。
在live demo 示例中,我们可以看到 "On Call "用户属性。
尽管 "电子邮件 "和 "用户 "格式的输入相同,但它们的表现形式却不同:
email
格式显示原始电子邮件字符串;user
格式从 Port 的已知用户列表中显示用户名和头像。
此外,"用户 "格式还可根据用户的状态对其进行区分:
User Status | Example |
---|---|
Active | |
Invited | |
Unregistered |
API 定义
- Basic
- Array
{
"myUserProp": {
"title": "My user",
"icon": "My icon",
"description": "My user property",
"type": "string",
"format": "user",
"default": "[email protected]"
}
}
{
"myUserArray": {
"title": "My user array",
"icon": "My icon",
"description": "My user array",
"type": "array",
"items": {
"type": "string",
"format": "user"
}
}
}
Check out Port's API reference to learn more.
Terraform 定义
- Basic
- Array
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
string_props = {
myUserProp = {
title = "My user"
required = false
format = "user"
}
}
}
}
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
array_props = {
"myUserArray" = {
title = "My user array"
required = false
string_items = {
format = "user"
}
}
}
}
}
Pulumi 的定义
- Basic
- Enum - coming soon
- Python
- TypeScript
- JavaScript
- GO
"""A Python Pulumi program"""
import pulumi
from port_pulumi import Blueprint,BlueprintPropertyArgs,BlueprintPropertiesArgs
blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties=BlueprintPropertiesArgs(
string_props={
"myUserProp": BlueprintPropertyArgs(
title="My user",
required=False,
format="user",
)
}
),
relations={}
)
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",
properties: {
stringProps: {
myUserProp: {
title: "My user",
required: false,
format: "user",
},
},
},
});
"use strict";
const pulumi = require("@pulumi/pulumi");
const port = require("@port-labs/port");
const entity = new port.Blueprint("myBlueprint", {
title: "My Blueprint",
identifier: "myBlueprint",
properties: {
stringProps: {
myUserProp: {
title: "My user",
required: false,
format: "user",
},
},
},
relations: [],
});
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"),
Properties: port.BlueprintPropertiesArgs{
StringProps: port.BlueprintPropertiesStringPropsArgs{
"myUserProp": port.BlueprintPropertiesStringPropsArgs{
Title: pulumi.String("My user"),
Required: pulumi.Bool(false),
Format: pulumi.String("user"),
},
},
},
})
ctx.Export("blueprint", blueprint.Title)
if err != nil {
return err
}
return nil
})
}