编号
数字是数值数据的基本输入。
💡 常用数字用法
数字输入类型可用于存储任何数字数据,例如
- 内存/存储分配;
- 副本计数;
- 保留数据的天数;
- 等等。
在live demo 自助服务中枢页面,我们可以看到scaffold new service 操作,其 K8s Replica Count
输入是一个数字输入。
应用程序接口定义
- Basic
- Select (Enum)
- Array
- Enum Array
{
"myNumberInput": {
"title": "My number input",
"icon": "My icon",
"description": "My number input",
"type": "number",
"default": 7
}
}
{
"myNumberSelectInput": {
"title": "My number select input",
"icon": "My icon",
"description": "My number select input",
"type": "number",
"enum": [1, 2, 3, 4]
}
}
{
"myNumberArrayInput": {
"title": "My number array input",
"icon": "My icon",
"description": "My number array input",
"type": "array",
"items": {
"type": "number"
}
}
}
{
"myNumberArray": {
"title": "My number-selection array input",
"icon": "My icon",
"description": "My number-selection array input",
"type": "array",
"items": {
"type": "number",
"enum": [1, 2, 3, 4],
"enumColors": {
"1": "red",
"2": "green",
"3": "blue"
}
}
}
}
Check out Port's API reference to learn more.
Terraform 定义
- Basic
- Select (Enum)
- Array
resource "port_action" "myAction" {
# ...action properties
user_properties = {
number_props = {
"myNumberInput" = {
title = "My number input"
description = "My number input"
default = 7
}
}
}
}
resource "port_action" "myAction" {
# ...action properties
user_properties = {
number_props = {
"myNumberInput" = {
title = "My number input"
description = "My number input"
enum = [1, 2, 3, 4]
}
}
}
}
resource "port_action" "myAction" {
# ...action properties
user_properties = {
array_props = {
"myNumberArrayInput" = {
title = "My number array input"
description = "My number array input"
number_items = {}
}
}
}
}
验证号码
数字验证支持以下操作符:
- 范围
使用 "最小值 "和 "最大值 "关键字(或 "独占最小值 "和 "独占最大值 "表达独占范围)的组合指定数字范围。
如果 x 是要验证的值,则以下条件必须成立:
- x ≥ `最小值
- x > `专属最小值
- x ≤ `最大值
- x < `独占最大值
- Basic
- Array
- Terraform
{
"myNumberInput": {
"title": "My number input",
"icon": "My icon",
"description": "My number input",
"type": "number",
"minimum": 0,
"maximum": 50
}
}
{
"myNumberArrayInput": {
"title": "My number array input",
"icon": "My icon",
"description": "My number array input",
"type": "array",
"items": {
"type": "number",
"exclusiveMinimum": 0,
"exclusiveMaximum": 50
}
}
}
resource "port_action" "myAction" {
# ...action properties
user_properties = {
number_props = {
"myNumberInput" = {
title = "My number input"
description = "My number input"
minimum = 0
maximum = 50
}
}
}
}