文本
文字是文本信息的基本输入方式。
💡 常用文本 Usage
文本输入类型可被用于来存储任何基于文本的数据 ,例如:
- 镜像标签;
- 可变密钥
- 提交 SHA;
- 文件名;
- 等等。
在live demo 自助中心页面中,我们可以看到新服务脚手架操作,其 "服务名称 "输入为文本输入。
应用程序接口定义
- Basic
- Select (Enum)
- Array
- Enum Array
{
"myTextInput": {
"title": "My text input",
"icon": "My icon",
"description": "My text input",
"type": "string",
"default": "My default"
}
}
{
"myTextSelectInput": {
"title": "My text select input",
"icon": "My icon",
"description": "My text select input",
"type": "string",
"enum": ["my-option-1", "my-option-2"]
}
}
{
"myTextArrayInput": {
"title": "My text array input",
"icon": "My icon",
"description": "My text array input",
"type": "array",
"items": {
"type": "string"
}
}
}
{
"myStringArray": {
"title": "My text-selection array input",
"icon": "My icon",
"description": "My text-selection array input",
"type": "array",
"items": {
"type": "string",
"enum": ["my-option-1", "my-option-2"],
"enumColors": {
"my-option-1": "red",
"my-option-2": "green"
}
}
}
}
Check out Port's API reference to learn more.
Terraform 定义
- Basic
- Select (Enum)
- Array
resource "port_action" "myAction" {
# ...action properties
user_properties = {
string_props = {
myTextInput = {
title = "My text input"
description = "My text input"
default = "My default"
}
}
}
}
resource "port_action" "myAction" {
# ...action properties
user_properties = {
string_props = {
myTextSelectInput = {
title = "My text select input"
description = "My text select input"
enum = ["my-option-1", "my-option-2"]
}
}
}
}
resource "port_action" "myAction" {
# ...action properties
user_properties = {
array_props = {
myTextArrayInput = {
title = "My text array input"
description = "My text array input"
string_items = {}
}
}
}
}
验证文本
文本验证支持以下操作符:
minLength
- 执行最小字符串长度;maxLength
- 执行最大字符串长度;pattern
- 执行 Regex 模式。
- Basic
- Array
- Terraform
{
"myTextInput": {
"title": "My text input",
"icon": "My icon",
"description": "My text input",
"type": "string",
"minLength": 1,
"maxLength": 32,
"pattern": "^[a-zA-Z0-9-]*-service$"
}
}
{
"myTextArrayInput": {
"title": "My text array input",
"icon": "My icon",
"description": "My text array input",
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"maxLength": 32,
"pattern": "^[a-zA-Z0-9-]*-service$"
}
}
}
resource "port_action" "myAction" {
# ...action properties
user_properties = {
string_props = {
myTextInput = {
title = "My text input"
description = "My text input"
default = "My default"
minLength = 1
maxLength = 32
pattern = "^[a-zA-Z0-9-]*-service$"
}
}
}
}