--- title: "ADR 0066: Hub resources are fetched from Artifact Hub by catalog name" --- * Status: accepted * Code: [`pkg/hub/hub.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/hub/hub.go), [`pkg/hub/artifacthub.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/hub/artifacthub.go), [`pkg/hub/get.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/hub/get.go) ## Context Pipeline annotations name a Tekton task or pipeline and optionally a catalog. `hub.NewClient` looks the catalog up in `cs.Info.Pac.HubCatalogs` and returns a `Client`. The only implementation in the package is the Artifact Hub one. The code does not show why Artifact Hub is the sole backend; the `Client` interface is the only seam. ## Decision * `NewClient` returns an error when the catalog name is missing from `HubCatalogs` or the stored value is not a `settings.HubCatalog`. * `newArtifactHubClient` trims a trailing slash and appends `/api/v1` unless the URL already ends with it. * `GetResource` calls `getSpecificVersion` when the resource contains `:` and `getLatestVersion` otherwise. Both use the paths `packages/<type>/<catalog>/<resource>` and, for a version, `/<version>` (e.g. `.../tekton-catalog-tasks/git-clone/0.9.0`). * `getArtifactHubTypeByKind` maps `task` to `tekton-task` and `pipeline` to `tekton-pipeline`; for those kinds a catalog name of `default` or empty becomes `tekton-catalog-tasks` or `tekton-catalog-pipelines`. Any other kind returns an empty package type and the catalog name unchanged. * The response is decoded from `data.manifestRaw`, the raw manifest string of the package. ## Consequences * Supporting another hub means a new `Client` and a branch in `NewClient`, which today has none. * An unknown kind yields an empty package type, so the request path is malformed rather than rejected up front.