Skip to content

Commit 5034528

Browse files
committed
feat: Add support for Artifact Hub
- Introduced Artifact Hub as the default catalog for remote Tasks and Pipelines (since tektonhub is deprecated) - Kept Tekton Hub support available with 'tektonhub://' prefix (but scheduled for deprecation) - Added a new `hub-catalog-type` key to the configuration to specify the catalog type (`tektonhub` or `artifacthub`) - Added warnings in documentation about Tekton Hub future deprecation - This allows users to configure multiple remote catalogs of different types - Refactored the hub fetching logic into a common client interface with separate implementations for each hub type, improving maintainability and extensibility - There is one known issue with this migration. When pinning to a specific version, this may fail in some cases because ArtifactHub expects semver and has moved all tasks to it. For example, if the user had yq:0.2, it will need to be yq:0.2.0. We can implement a workaround to support this migration in a future pull request. Jira: https://issues.redhat.com/browse/SRVKP-8207 Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent 846416e commit 5034528

32 files changed

+1568
-328
lines changed

config/302-pac-configmap.yaml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,34 @@ data:
4343
# i.e: "owner/private-repo1, org/repo2"
4444
secret-github-app-scope-extra-repos: ""
4545

46-
# Tekton HUB API urls
47-
hub-url: "https://api.hub.tekton.dev/v1"
46+
# The default hub url to use, by default it is artifacthub.
47+
hub-url: "https://artifacthub.io"
4848

49-
# Tekton HUB catalog name
50-
hub-catalog-name: "tekton"
49+
# The default hub catalog type, by default it is artifacthub.
50+
# Other supported values: tektonhub
51+
hub-catalog-type: "artifacthub"
5152

52-
# Additional Hub Catalogs is supported, for example:
53+
# Pipelines-as-code uses Artifact Hub by default. For backward
54+
# compatibility, until https://hub.tekton.dev/ is discontinued the public
55+
# Tekton Hub can also be accessed with the `tektonhub://` prefix (e.g.,
56+
# `tektonhub://git-clone`).
5357
#
54-
# catalog-1-id: anotherhub
58+
# Additional Hub Catalogs are supported, for example:
59+
#
60+
# catalog-1-id: custom
5561
# catalog-1-name: tekton
56-
# catalog-1-url: https://api.other.com/v1
62+
# catalog-1-url: https://api.custom.hub/v1
63+
# catalog-1-type: tektonhub
64+
#
65+
# With this configuration, a catalog of type "tektonhub" (or alternatively,
66+
# of type "artifacthub") named "custom" will be available at
67+
# https://api.custom.hub/v1, using the catalog named "tekton" . Users can
68+
# reference these catalogs in their templates like this:
5769
#
58-
# this configuration will have a new catalog named anotherhub on https://api.other.com/v1 endpoint and catalog name tekton
59-
# to be used by a user in their templates like this:
60-
# pipelinesascode.tekton.dev/task: "anotherhub://task"
70+
# pipelinesascode.tekton.dev/task: "custom://task"
6171
#
62-
# Increase the number of the catalog to add more of them
72+
# Increase the number of the catalogs to add more of them. catalog-2-*,
73+
# catalog-3-*, etc.
6374

6475
# Allow fetching remote tasks
6576
remote-tasks: "true"

docs/content/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ tracking using a Git workflow.
3737

3838
- Pull-request "*GitOps*" actions through comments with `/retest`, `/test <pipeline-name>` and so on.
3939

40-
- Automatic Task resolution in Pipelines (local Tasks, Tekton Hub, and remote URLs)
40+
- Automatic Task resolution in Pipelines (local Tasks, Artifact Hub, and remote URLs)
4141

4242
- Efficient use of GitHub blobs and objects API for retrieving configurations
4343

docs/content/docs/guide/authoringprs.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Here is a list of all the dynamic variables available in Pipelines-as-Code. The
4444
one that would be the most important to you would probably be the `revision` and `repo_url`
4545
variables, they will give you the commit SHA and the repository URL that is
4646
getting tested. You usually use this with the
47-
[git-clone](https://hub.tekton.dev/tekton/task/git-clone) task to be able to
47+
[git-clone](https://artifacthub.io/packages/tekton-task/tekton-catalog-tasks/git-clone) task to be able to
4848
check out the code that is being tested.
4949

5050
| Variable | Description | Example | Example Output |
@@ -196,12 +196,16 @@ The token value is stored in the temporary git-auth secret as generated for [pri
196196
repositories](../privaterepo/) in the key `git-provider-token`.
197197

198198
As an example, if you want to add a comment to your pull request, you can use the
199-
[github-add-comment](https://hub.tekton.dev/tekton/task/github-add-comment)
200-
task from the [Tekton Hub](https://hub.tekton.dev)
201-
using a [pipelines as code annotation](../resolver/#remote-http-url):
199+
[github-add-comment](https://artifacthub.io/packages/tekton-task/tekton-catalog-tasks/github-add-comment)
200+
task from [Artifact Hub](https://artifacthub.io) or the same task from
201+
[Tekton Hub](https://hub.tekton.dev/) using a [pipelines as code annotation](../resolver/#hub-support-for-tasks):
202202

203203
```yaml
204+
# Using Artifact Hub (default)
204205
pipelinesascode.tekton.dev/task: "github-add-comment"
206+
207+
# Or explicitly using Tekton Hub
208+
pipelinesascode.tekton.dev/task: "tektonhub://github-add-comment"
205209
```
206210

207211
you can then add the task to your [tasks section](https://tekton.dev/docs/pipelines/pipelines/#adding-tasks-to-the-pipeline) (or [finally](https://tekton.dev/docs/pipelines/pipelines/#adding-finally-to-the-pipeline) tasks) of your PipelineRun :

docs/content/docs/guide/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ current Git information if you run the command from your source code.
251251

252252
It has some basic language detection and adds extra tasks depending on the
253253
language. For example, if it detects a file named `setup.py` at the repository
254-
root it will add the [pylint task](https://hub.tekton.dev/tekton/task/pylint) to
254+
root it will add the [pylint task](https://artifacthub.io/packages/tekton-task/tekton-catalog-tasks/pylint) to
255255
the generated PipelineRun.
256256
{{< /details >}}
257257

docs/content/docs/guide/privaterepo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ weight: 7
66

77
Pipelines-as-Code allows the use of private repositories by creating or
88
updating a secret in the target namespace. This secret contains the user token
9-
required for the [git-clone](https://hub.tekton.dev/tekton/task/git-clone) task
9+
required for the [git-clone](https://artifacthub.io/packages/tekton-task/tekton-catalog-tasks/git-clone) task
1010
to clone private repositories.
1111

1212
Whenever Pipelines-as-Code creates a new PipelineRun in the target namespace,

docs/content/docs/guide/resolver.md

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,27 @@ or multiple tasks with an array :
7777
pipelinesascode.tekton.dev/task: "[git-clone, pylint]"
7878
```
7979
80-
### [Tekton Hub](https://hub.tekton.dev) Support for Tasks
80+
### Hub Support for Tasks
8181
8282
```yaml
8383
pipelinesascode.tekton.dev/task: "git-clone"
8484
```
8585
86-
The syntax above installs the
87-
[git-clone](https://github.com/tektoncd-catalog/git-clone/tree/main/task/git-clone) task
88-
from the [tekton hub](https://hub.tekton.dev) repository querying for the latest
89-
version with the tekton hub API.
86+
By default, this syntax will install the task from Artifact Hub.
87+
88+
Examples:
89+
90+
```yaml
91+
# Using Artifact Hub (default)
92+
pipelinesascode.tekton.dev/task: "git-clone"
93+
94+
# Using Tekton Hub
95+
pipelinesascode.tekton.dev/task: "tektonhub://git-clone"
96+
```
97+
98+
{{< hint danger >}}
99+
The public Tekton Hub service <https://hub.tekton.dev/> is scheduled to be deprecated in the future, so we recommend using Artifact Hub for task resolution.
100+
{{< /hint >}}
90101
91102
You can have multiple tasks in there if you separate them by a comma `,` around
92103
an array syntax with bracket:
@@ -104,29 +115,26 @@ example :
104115
pipelinesascode.tekton.dev/task-2: "tkn"
105116
```
106117

107-
By default, `Pipelines-as-Code` will interpret the string as the `latest` task to
108-
grab
109-
from [tekton hub](https://hub.tekton.dev).
110-
111118
If you want to have a specific version of the task, you can add a colon `:` to
112-
the string and a version number, like in
113-
this example :
119+
the string and a version number, like in this example:
114120

115121
```yaml
116-
pipelinesascode.tekton.dev/task: "[git-clone:0.1]" # this will install git-clone 0.1 from tekton.hub
122+
# Using specific version from Artifact Hub
123+
pipelinesascode.tekton.dev/task: "git-clone:0.9.0"
124+
125+
# Using specific version from Tekton Hub
126+
pipelinesascode.tekton.dev/task: "tektonhub://git-clone:0.1"
117127
```
118128

119-
#### Custom [Tekton Hub](https://github.com/tektoncd/hub/) Support for Tasks
129+
#### Custom Hub Support for Tasks
120130

121-
Additionally if the cluster administrator has [set-up](/docs/install/settings#tekton-hub-support) a custom Tekton Hub you
122-
are able to reference it from your template like this example:
131+
Additionally if the cluster administrator has [set-up](/docs/install/settings#remote-hub-catalogs) custom Hub catalogs beyond the default Artifact Hub and Tekton Hub, you are able to reference them from your template:
123132

124133
```yaml
125-
pipelinesascode.tekton.dev/task: "[anothercatalog://curl]" # this will install curl from the custom catalog configured by the cluster administrator as anothercatalog
134+
pipelinesascode.tekton.dev/task: "[customcatalog://curl]" # this will install curl from the custom catalog configured by the cluster administrator as customcatalog
126135
```
127136

128-
There is no fallback to the default Tekton Hub if the custom Tekton Hub does not
129-
have the task referenced it will fail.
137+
There is no fallback between different hubs. If a task is not found in the specified hub, the Pull Request will fail.
130138

131139
There is no support for custom hub from the CLI on the `tkn pac resolve` command.
132140

@@ -284,33 +292,45 @@ or from a relative path inside the repository:
284292
pipelinesascode.tekton.dev/pipeline: "./tasks/pipeline.yaml
285293
```
286294

287-
### [Tekton Hub](https://hub.tekton.dev) Support for Pipelines
295+
### Hub Support for Pipelines
288296

289297
```yaml
290-
pipelinesascode.tekton.dev/pipeline: "[buildpacks]"
298+
pipelinesascode.tekton.dev/pipeline: "buildpacks"
291299
```
292300

293-
The syntax above installs the
294-
[buildpacks](https://github.com/tektoncd/catalog/tree/main/pipeline/buildpacks) pipeline
295-
from the [tekton hub](https://hub.tekton.dev) repository querying for the latest
296-
version with the tekton hub API.
301+
By default, this syntax will install the pipeline from Artifact Hub.
302+
303+
Examples:
304+
305+
```yaml
306+
# Using Artifact Hub (default)
307+
pipelinesascode.tekton.dev/pipeline: "buildpacks"
308+
309+
# Using Tekton Hub
310+
pipelinesascode.tekton.dev/pipeline: "tektonhub://buildpacks"
311+
```
297312

298313
If you want to have a specific version of the pipeline, you can add a colon `:` to
299-
the string and a version number, like in this example :
314+
the string and a version number, like in this example:
300315

301316
```yaml
302-
pipelinesascode.tekton.dev/pipeline: "[buildpacks:0.1]" # this will install buildpacks 0.1 from tekton hub
317+
# Using specific version from Artifact Hub
318+
pipelinesascode.tekton.dev/pipeline: "buildpacks:0.1"
319+
320+
# Using specific version from Tekton Hub
321+
pipelinesascode.tekton.dev/pipeline: "tektonhub://buildpacks:0.1"
303322
```
304323

305-
#### Custom [Tekton Hub](https://github.com/tektoncd/hub/) Support for Pipelines
324+
#### Custom Hub Support for Pipelines
306325

307-
Additionally if the cluster administrator has [set-up](/docs/install/settings#tekton-hub-support) a custom Tekton Hub you
308-
are able to reference it from your template like this example:
326+
Additionally if the cluster administrator has [set-up](/docs/install/settings#remote-hub-catalogs) custom Hub catalogs beyond the default Artifact Hub and Tekton Hub, you are able to reference them from your template:
309327

310328
```yaml
311-
pipelinesascode.tekton.dev/pipeline: "[anothercatalog://buildpacks:0.1]" # this will install buildpacks from the custom catalog configured by the cluster administrator as anothercatalog
329+
pipelinesascode.tekton.dev/pipeline: "[customcatalog://buildpacks:0.1]" # this will install buildpacks from the custom catalog configured by the cluster administrator as customcatalog
312330
```
313331

332+
There is no fallback between different hubs. If a pipeline is not found in the specified hub, the Pull Request will fail.
333+
314334
### Overriding tasks from a remote pipeline on a PipelineRun
315335

316336
{{< tech_preview "Tasks from a remote Pipeline override" >}}

docs/content/docs/install/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ your cluster and create a directory called `.tekton` with a file named
223223
Note that the `tkn pac create repository` command detected that the repository
224224
is using the Go programming language and created a basic template for you to be
225225
customized tailored for the Go programming language (ie: it will add the
226-
[golangci-lint](https://hub.tekton.dev/tekton/task/golangci-lint) linter as a
226+
[golangci-lint](https://artifacthub.io/packages/tekton-task/tekton-catalog-tasks/golangci-lint) linter as a
227227
task to your PipelineRun).
228228
229229
Feel free to open the file `.tekton/pipelinerun.yaml` and inspect what it

docs/content/docs/install/operator_installation.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ On the OpenShift Pipelines Operator, the default namespace is `openshift-pipelin
1010

1111
**Note:**
1212

13-
When Pipelines-as-Code is installed through the [Tekton Operator](https://github.com/tektoncd/operator) the configurations of Pipelines-as-Code is
13+
When Pipelines-as-Code is installed through the [Tekton Operator](https://github.com/tektoncd/operator) the configuration of Pipelines-as-Code is
1414
controlled by [TektonConfig Custom Resource](https://github.com/tektoncd/operator/blob/main/docs/TektonConfig.md#openshiftpipelinesascode).
15-
That means Tekton Operator will revert the configurations changes done directly on `pipeline-as-code` configmap or `OpenShiftPipelinesAsCode` custom resource.
15+
That means Tekton Operator will revert the configuration changes done directly
16+
on `pipeline-as-code` configmap or `OpenShiftPipelinesAsCode` custom resource.
1617

17-
The default configurations for Pipelines-as-Code in `TektonConfig` looks like below
18+
The default configurations for Pipelines-as-Code in `TektonConfig` looks like
19+
below.
20+
Note that since version v0.37.0, Pipelines-as-Code defaults to using Artifact
21+
Hub rather than Tekton Hub. Tekton Hub is deprecated and will be removed in a
22+
future version. You can still use the public tekton hub instance by explicitly
23+
prefixing your task with `tektonhub://`
1824

1925
```yaml
2026
apiVersion: operator.tekton.dev/v1alpha1
@@ -36,8 +42,8 @@ spec:
3642
enable-cancel-in-progress-on-pull-requests: 'false'
3743
enable-cancel-in-progress-on-push: 'false'
3844
skip-push-event-for-pr-commits: 'true'
39-
hub-url: 'https://api.hub.tekton.dev/v1'
40-
hub-catalog-name: tekton
45+
hub-url: 'https://artifacthub.io'
46+
hub-catalog-type: 'artifacthub'
4147
error-detection-max-number-of-lines: '50'
4248
error-detection-simple-regexp: >-
4349
^(?P<filename>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+):([

docs/content/docs/install/settings.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,31 +179,47 @@ There is a few things you can configure through the config map
179179

180180
This is disabled by default.
181181

182-
### Tekton Hub support
182+
### Remote Hub Catalogs
183183

184-
Pipelines-as-Code supports fetching task with its remote annotations feature, by default it will fetch it from the [public tekton hub](https://hub.tekton.dev/) but you can configure it to point to your own with these settings:
184+
Pipelines-as-Code supports fetching tasks and pipelines with its remote annotations feature. By default, it will fetch from [Artifact Hub](https://artifacthub.io/), but you can also implicitly use the [Tekton Hub](https://hub.tekton.dev/) by using the `tektonhub://` prefix (as documented below) or point to your own custom hub with these settings:
185185

186186
* `hub-url`
187187

188-
The base URL for the [tekton hub](https://github.com/tektoncd/hub/)
189-
API. This default to the [public hub](https://hub.tekton.dev/): <https://api.hub.tekton.dev/v1>
188+
The base URL for the hub API. For Artifact Hub (default), this is set to <https://artifacthub.io>. For Tekton Hub, it would be <https://api.hub.tekton.dev/v1>.
190189

191190
* `hub-catalog-name`
192191

193-
The [tekton hub](https://github.com/tektoncd/hub/) catalog name. default to `tekton`
192+
The catalog name in the hub. For Artifact Hub, the defaults are `tekton-catalog-tasks` for tasks and `tekton-catalog-pipelines` for pipelines. For Tekton Hub, this defaults to `tekton`.
194193

195-
* Additionally you can have multiple hub configured by using the following format:
194+
* `hub-catalog-type`
195+
196+
The type of hub catalog. Supported values are:
197+
198+
* `artifacthub` - For Artifact Hub (default if not specified)
199+
* `tektonhub` - For Tekton Hub
200+
201+
* By default, both Artifact Hub and Tekton Hub are configured:
202+
203+
* Artifact Hub is the default catalog (no prefix needed, but `artifact://` can be used explicitly)
204+
* Tekton Hub is available using the `tektonhub://` prefix
205+
206+
* Additionally you can have multiple hubs configured by using the following format:
196207

197208
```yaml
198209
catalog-1-id: "custom"
199210
catalog-1-name: "tekton"
200211
catalog-1-url: "https://api.custom.hub/v1"
212+
catalog-1-type: "tektonhub"
213+
214+
catalog-2-id: "artifact"
215+
catalog-2-name: "tekton-catalog-tasks"
216+
catalog-2-url: "https://artifacthub.io"
217+
catalog-2-type: "artifacthub"
201218
```
202219

203-
Users are able to reference the custom hub by adding a `custom://` prefix to
204-
their task they want to fetch from the `custom` catalog.
220+
Users are able to reference the custom hub by adding a prefix matching the catalog ID, such as `custom://` for a task they want to fetch from the `custom` catalog.
205221

206-
You can add as many custom hub as you want by incrementing the `catalog-NUMBER` number.
222+
You can add as many custom hubs as you want by incrementing the `catalog-NUMBER` number.
207223

208224
Pipelines-as-Code will not try to fallback to the default or another custom hub
209225
if the task referenced is not found (the Pull Request will be set as failed)

hack/dev/kind/install.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,10 @@ function configure_pac() {
193193
sed -e "s,%DOMAIN_NAME%,${DOMAIN_NAME}," -e "s,%SERVICE_NAME%,${service_name}," ingress-pac.yaml | kubectl apply -f-
194194

195195
kubectl patch configmap -n pipelines-as-code -p "{\"data\":{\"bitbucket-cloud-check-source-ip\": \"false\"}}" pipelines-as-code &&
196-
kubectl patch configmap -n pipelines-as-code -p "{\"data\":{\"tekton-dashboard-url\": \"http://dashboard.${DOMAIN_NAME}\"}}" --type merge pipelines-as-code
197-
# add custom catalog so we can use it in e2e, this will points to the normal upstream hub so we can easily use it
198-
kubectl patch configmap -n pipelines-as-code -p '{"data":{"catalog-1-id": "custom", "catalog-1-name": "tekton", "catalog-1-url": "https://api.hub.tekton.dev/v1"}}' --type merge pipelines-as-code
199-
# add one more custom catalog so we can use it in e2e for multiple catalog support, this will points to the normal upstream hub so we can easily use it
200-
kubectl patch configmap -n pipelines-as-code -p '{"data":{"catalog-2-id": "custom2", "catalog-2-name": "tekton", "catalog-2-url": "https://api.hub.tekton.dev/v1"}}' --type merge pipelines-as-code
196+
kubectl patch configmap -n pipelines-as-code -p "{\"data\":{\"tekton-dashboard-url\": \"http://dashboard.${DOMAIN_NAME}\"}}" --type merge pipelines-as-code &&
197+
kubectl patch configmap -n pipelines-as-code -p \
198+
'{"data":{"catalog-1-type": "artifacthub", "catalog-1-id": "pachub", "catalog-1-name": "pipelines-as-code", "catalog-1-url": "https://artifacthub.io"}}' \
199+
--type merge pipelines-as-code
201200
set +x
202201
if [[ -n ${PAC_PASS_SECRET_FOLDER} ]]; then
203202
echo "Installing PAC secrets"

0 commit comments

Comments
 (0)