User
User is a data type used to reference users that exist in Port.
Common user usageโ
The user property type can be used to reference any user that exists in Port, for example:
- The code owners;
- The current on-call;
- The lead maintainer;
- etc.
In this live demo example, we can see the On Call
user property. ๐ฌ
Even though the input is the same in both email
and user
formats, their presentation is different:
email
format displays the raw email string;user
format displays the user's name and avatar from Port's list of known users.
In addition, user
format distinguishes between users by their status:
User Status | Example |
---|---|
Active | |
Invited | |
Unregistered |
API definitionโ
Limit fieldโ
When creating a blueprint property of type User in the UI, use the limit field to define how many values users can select for that property.
In the property creation form, the limit field dropdown provides two options:
- 1 value: Only one value can be selected.
- List of values: Multiple values can be selected.
Selecting the list of values option will set the property's type
to array
in the JSON definition.
The limit field setting, whether it's 1 value or a list of values, is permanent and cannot be changed after the property is created. If you create a property with a single value limit, you wonโt be able to change it later to allow multiple values.
To change the limit configuration after creation, you have two options:
- Create a new property with the limit field set to a list of values.
- Use the migrate blueprint data feature.
- Basic
- Array
{
"myUserProp": {
"title": "My user",
"icon": "My icon",
"description": "My user property",
"type": "string",
"format": "user",
"default": "me@example.com"
}
}
{
"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 definitionโ
- 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 definitionโ
- Basic
- 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/v2/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
})
}