ResourceInterface
TOC
OverviewProblem It SolvesData StructureHuman-Readable informationResource CategoriesParametersAttributesExpression SyntaxDependenciesWorkspacesConnectorClassDynamic FormOverviewExtended Context VariablesDynamic Form Configuration ApproachesDirect API ConfigurationReference OpenAPI Display SchemaExamplesWhat's NextReferencesOverview
ResourceInterface is a cluster-level resource that defines standardized abstractions for external resources (like Git repositories, OCI artifacts, Maven artifacts) and how they integrate into pipeline workflows. It serves as a bridge between connectors and pipeline orchestration, enabling seamless resource integration with minimal manual configuration.
The following example defines a GitCodeRepository interface that describes Git repository access:
ResourceInterface defines the following key aspects for resource integration:
- Input parameters required for resource configuration
- Output attributes calculated from parameters and connector information
- Workspace definitions for volumes and credentials
This document provides ResourceInterface Data Structure definition and Examples to help readers understand how to customize ResourceInterface.
You don't need to understand the details of ResourceInterface unless you want to customize ResourceInterface.
Problem It Solves
When building CI/CD pipelines, users traditionally face several challenges:
Manual Resource Entry: Users cannot easily browse and add external resources like Git repositories, OCI repositories, and other external services. They must manually enter URLs and set up workspaces, which is error-prone and time-consuming.
Repetitive Execution Configuration: Every time users run a pipeline, they must manually enter version details like Git revision and target OCI tag, and repeatedly configure workspaces.
Split Attributes: Attributes from the same remote resource are often split into different parameters. For example, the git-clone task requires separate url and revision parameters, plus workspace configurations for credentials and source code.
Complex Workspace Selection: The pipeline workspace selection process lists all available options but provides little guidance on which connector type is appropriate for each workspace.
ResourceInterface addresses these issues by providing a standardized way to describe and integrate external resources into pipeline workflows, enabling users to browse and select resources through UI interfaces while automatically generating the correct configuration and credentials.
Data Structure
ResourceInterface is a cluster-level k8s resource
- Kind: ResourceInterface
- API Version: connectors.alauda.io/v1alpha1
Human-Readable information
ResourceInterface is a standard k8s resource, it can be annotated with human-readable information using annotations.
you can also use style.tekton.dev/descriptors annotation to describe the params for dynamic form.
more details please refer to dynamic-form.
Resource Categories
ResourceInterface organizes resources into categories that define common contracts and behaviors. Categories are marked using the label resourceinterface.connectors.cpaas.io/category.
Multiple ResourceInterfaces can belong to the same category (e.g., gitcoderepository and githubcoderepository both belong to the GitCodeRepository category). Resources in the same category must provide the same standard attributes and workspaces to ensure compatibility.
Parameters
Parameters define the input data required to configure the resource when integrated into a pipeline. These parameters influence the calculation of output attributes.
Parameters are defined in spec.params and follow Tekton parameter types:
- name: Parameter name
- type: Supports
string,array,object(consistent with Tekton ParamSpec types) - default: Default parameter value (optional)
- description: Parameter description for UI display (optional)
for example:
Attributes
Attributes define the output values calculated from input parameters and connector information. They can be consumed by pipeline tasks as parameters and may be elevated to pipeline-level parameters.
Attributes are defined in spec.attributes:
- name: Attribute name
- type: Value type - supports
string,array - expression: JavaScript expression for calculating the attribute value
- parameterize: Parameterization configuration
- name: Default parameter name when parameterized
- disable: Whether to disable parameterization
- dependsOn: Dependencies on parameters or connector
for example:
Expression Syntax
Expressions use JavaScript syntax and support:
- String concatenation:
params.organization + '/' + params.repository - Object property access:
connector.metadata.name - Array operations:
params.tags.map(tag => connector.spec.address + ':' + tag) - Built-in functions:
url(connector.spec.address).host: get the host of the address
and other JavaScript syntaxes are supported.
Available Context:
connector: Current connector information, the structure of connector please refer to Concept of Connectorparams: Current parameter values
the context data structure is:
Security: Frontend executes JavaScript code in a sandbox environment, allowing only safe, sandboxed functions.
Example:
{connector.spec.address + '/' + params.repository}: get the address of the repository{url(connector.spec.address).host + '/' + params.repository + ':' + params.tag}: get the address of the artifact{params.tags.map(tag => url(connector.spec.address).host + '/' + params.repository + ':' + tag)}: get the addresses of the artifacts array by iterating the tags array
Dependencies
Dependencies specify what parameters or connector information an attribute calculation depends on:
params.<param-name>: Depends on a specific parameter valueconnector: Depends on connector selection
Workspaces
Workspaces define volumes and credentials provided by the resource interface. They enable automatic provisioning of required resources for pipeline tasks.
Workspaces are defined in spec.workspaces:
- name: Workspace name
- workspaceMapping.name: Default workspace name when added to pipeline workspaces
- value: Default workspace value (follows Tekton WorkspaceBinding format), consistent with Tekton WorkspaceBinding types
for example:
Workspace values support expressions to dynamically reference parameter and connector values using the same syntax as attributes.
ConnectorClass
ConnectorClasses mark supported ResourceInterfaces through labels resourceinterface.connectors.cpaas.io/<resource-interface-name>: "true", for example:
This enables the system to match compatible connectors with ResourceInterfaces and provide appropriate parameter forms based on ResourceInterface definitions.
More about ConnectorClass please refer to Concept of ConnectorClass
Dynamic Form
Dynamic forms provide a declarative way to configure interactive UI components for Pipeline Integration. With dynamic forms, users can browse and select resources such as Git repositories and revisions directly through the connector.
Overview
Use the style.tekton.dev/descriptors annotation to define dynamic form behavior for parameters. Here is an example:
The syntax follows the Pipeline Dynamic Forms specification. Familiarity with that documentation is recommended before proceeding.
In addition to the standard capabilities, dynamic forms in ResourceInterface support:
- Extended context variables for accessing connector and ResourceInterface data
- Reference OpenAPI display schema definitions in ConnectorClass for centralized API configuration and reference the api definition when using dynamic form
Extended Context Variables
The following context variables are available in ResourceInterface dynamic forms:
Dynamic Form Configuration Approaches
There are two approaches to configure dynamic forms in ResourceInterface:
-
Direct API Configuration: Call connector APIs directly using descriptor expressions. This approach is straightforward and easy to understand. The Connectors System provides Connector API endpoints for listing repositories, git references, and more.
-
Reference OpenAPI Display Schema in ConnectorClass: Define API calls and display mappings in the ConnectorClass using
spec.api.openapi. This approach centralizes API definitions and display configurations, avoiding duplication across multiple ResourceInterfaces. When using dynamic form, you can reference the API definition in the ConnectorClass directly.
You can use either approach independently or combine them as needed.
Direct API Configuration
Example: Listing GitLab Repositories
GitLab connectors expose the native GitLab API, which can be used to populate a repository selector:
Example: Listing Git References
Git connector provides a gitrefs endpoint for listing branches and tags:
Reference OpenAPI Display Schema
To centralize API definitions and display configurations, define them in the ConnectorClass using spec.api.openapi. Dynamic forms can then reference these definitions directly, eliminating redundant configurations across ResourceInterfaces.
Prerequisites
- Define the OpenAPI specification in the ConnectorClass. See ConnectorClass OpenAPI Description for details.
- Add the
x-display-schemaextension to define how the API integrates with dynamic forms.
Display Schema Structure
The x-display-schema extension contains:
parameters[]: Defines how to populate API parameters at runtime.name: Parameter name (must match the API parameter name)value: Parameter value expression. Syntax follows Pipeline Dynamic Forms.
descriptors: Defines how API response data maps to form options. Syntax follows Pipeline Dynamic Forms.
Example: Git References API
The following ConnectorClass configuration defines the GET /git/gitrefs API with display schema:
- The
repositoryUrlparameter is set to${context.connector.spec.address + "/" + context.params.repository + ".git"}and passed as a query parameter - The
searchparameter is set to${current.search}for filtering results - The response
itemsarray is mapped to select options, usingnamefor both label and value
example:
Referencing OpenAPI in ResourceInterface
Once the API is defined in ConnectorClass, reference it in your ResourceInterface using the following syntax:
urn:alm:descriptor:widgets:selectto specify the widget typeschema:openapi:context.connectorClass.spec.api.openapi:<operationId>to reference the API definition in the ConnectorClass
for example:
With this configuration, the revision field in Pipeline Integration renders as a dropdown that fetches options from the listGitRefs API.
Examples
GitCodeRepository ResourceInterface
OCIArtifact ResourceInterface
What's Next
- Understand Pipeline Integration When you want to integrate Connector in your custom Pipeline or Task.