How to Configure Dynamic Forms
TOC
Feature OverviewUse CasesQuick StartForm Basic ConfigurationForm LabelForm DescriptionPlaceholder HintForm Help TooltipForm Disabled StateSupported Field TypesText InputMulti-line Text InputTags InputRadioSwitchYAML EditorSelect BoxBasic Content ConfigurationAPI Dynamic Options ConfigurationParameter Default ValuesForm ValidationRequired ValidationLength ValidationNumeric Range ValidationRegular Expression ValidationUsage ExamplesConfigure Dynamic Forms in TaskConfigure Dynamic Forms in PipelineTroubleshootingFeature Overview
The dynamic form configuration feature allows you to declaratively configure a friendly interactive experience for resources such as Pipeline and Task. Without writing frontend code, simply by adding style.tekton.dev/descriptors configuration in the resource's annotations, you can achieve:
- Dynamic form generation: Automatically generate interactive forms for resource parameters, providing a better experience when orchestrating and executing Pipelines and Tasks.
- Rich component support: Provides various form components such as text boxes, selectors, switches, YAML editors, etc.
- Field validation: Built-in validation rules to ensure user input meets requirements.
- Dynamic data fetching: Supports dynamically loading option data through APIs.
Use Cases
- Pipeline orchestration/runtime: Allow users to fill in parameters such as namespace and secrets through friendly forms when orchestrating or triggering
Pipeline - Task reuse: Provide default values, dropdown options, and validation for common parameters at the
TaskorPipelinetemplate level - Multi-environment selection: Dynamically query available environments or configurations from APIs and use them as selection options
Quick Start
Basic Configuration Structure
All configurations are defined through the style.tekton.dev/descriptors field in annotations:
Configuration Description
path: Specifies the parameter path in the formatparams.parameter-namex-descriptors: Configuration item array, each configuration item starts withurn:alm:descriptor:
Simple Example
Configure a required text input box for a Task parameter:
Form Basic Configuration
Form Label
Form Description
Placeholder Hint
Form Help Tooltip
Form Disabled State
Supported Field Types
Text Input
Multi-line Text Input
Tags Input
Radio
Switch
YAML Editor
Select Box
Basic Content Configuration
API Dynamic Options Configuration
When form controls need to dynamically load available options based on the current environment (such as available namespaces, secrets, etc.), you can use API dynamic configuration to retrieve dropdown options from backend interfaces in real-time.
In this mode, API URLs are typically used in combination with context variables to dynamically construct request paths based on the user's current cluster, namespace, project, or filled parameters. For example:
Available Context Variables
In dynamic API paths, you can use ${variable} to reference runtime context information.
- General Context Variables
- Pipeline/Task Related Context Variables
These variables are typically used in combination with API URLs to dynamically construct request addresses in different environments, enabling environment-aware option loading logic. For example:
Configure Data Path for Returned Data
When the API returns a complex structure, for example:
You can use path to specify how to extract the options array from the structure.
Configure Label and Value Mapping Fields for Options
If the returned data object is complex and requires specifying inner fields as "display name" and "option value", you can use:
When the API returns a simple string[] array, this configuration is not needed.
Configure API Query Parameters
If you need to pass query parameters to the API request (such as search keywords or filters), you can use:
When user types "test" in the dropdown, the actual request will be:
Advanced Usage: Supports JavaScript expressions, for example:
Parameter Default Values
Fixed Default Value
Expression-based Dynamic Default Value
Available variables:
-
option: Option raw data -
index: Option index -
length: Total number of options -
context: Context parameters
For conditional syntax rules in complex scenarios, please refer to JavaScript syntax.
Form Validation
Supports configuring various validation rules, multiple rules can be applied simultaneously.
Required Validation
Length Validation
Numeric Range Validation
Regular Expression Validation
Combined Example: Configure a password field with complete validation
Usage Examples
Configure Dynamic Forms in Task
Example: Provide a dropdown box for selecting namespaces for the image parameter of a Task.
Effect: When users orchestrate a Pipeline or TaskRun based on the UI, the namespace parameter of this Task supports dropdown selection of namespaces.
Configure Dynamic Forms in Pipeline
Example: Provide a dropdown box for selecting namespaces for the target-namespace parameter of a Pipeline.
Effect: When users trigger a Pipeline based on the UI or need to associate this pipeline in other resources (Trigger, TriggerTemplate) and configure runtime parameters, the target-namespace parameter supports dropdown selection of namespaces.
Troubleshooting
- Form not displayed or configuration not taking effect: Check if the YAML format of
style.tekton.dev/descriptorsis correct, confirmpathis configured asparams.parameter-name, verify each descriptor starts with- urn:alm:descriptor: - Dynamic options not loading: Confirm the API path is correct, check if the current user has permission to access the specified API resource, verify
path,labelandvalueconfigurations point to fields that exist in the returned data - Default value not taking effect: Confirm fixed default value uses
expression:props.default:valueformat, expression default value uses===instead of=, check if variables (option, index, length, context) in the expression are spelled correctly - Context variables not resolved: Verify variable names are correct (e.g.,
context.namespacenotcontext.namespaces), confirm variables are used in descriptors that support expressions, check if JavaScript expression syntax has errors