Text
Text is a basic input for textual information.
💡 Common text usage
The text input type can be used to store any text based data, for example:
- Image tags
- Variable keys
- Commit SHA
- File names
In the live demo self-service hub page, we can see the scaffold new service action whose Service Name
input is a text input. 🎬
API definition
- 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 definition
- 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 = {}
}
}
}
}
Validate text
Text validations support the following operators:
minLength
- enforce minimal string length;maxLength
- enforce maximal string length;pattern
- enforce Regex patterns.
- 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$"
}
}
}
}