Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Radius recipes #3998

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ At the moment, the following artifacts kinds are supported *(with plans to suppo
- [OLM operators](https://github.com/operator-framework)
- [OpenCost plugins](https://www.opencost.io)
- [Open Policy Agent (OPA) policies](https://www.openpolicyagent.org/)
- [Radius Recipes](https://radapp.io)
- [Tekton tasks, pipelines and stepactions](https://tekton.dev/)
- [Tinkerbell actions](https://tinkerbell.org/)

Expand Down
3 changes: 2 additions & 1 deletion charts/artifact-hub/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: artifact-hub
description: Artifact Hub is a web-based application that enables finding, installing, and publishing Cloud Native packages.
type: application
version: 1.19.1-0
version: 1.19.1-1
appVersion: 1.19.0
kubeVersion: ">= 1.19.0-0"
home: https://artifacthub.io
Expand Down Expand Up @@ -32,6 +32,7 @@ keywords:
- inspektor gadget
- meshery
- opencost
- radius
maintainers:
- name: Sergio
email: tegioz@icloud.com
Expand Down
1 change: 1 addition & 0 deletions charts/artifact-hub/values-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ tracker:
requests:
cpu: 2
memory: 4000Mi
repositoryTimeout: 25m

trivy:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion charts/artifact-hub/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@
},
"repositoriesKinds": {
"title": "Repositories kinds to process ([] = all)",
"description": "The following kinds are supported at the moment: falco, helm, olm, opa, tbaction, krew, helm-plugin, tekton-task, keda-scaler, coredns, keptn, tekton-pipeline, container, kubewarden, gatekeeper, kyverno, knative-client-plugin, backstage, argo-template, kubearmor, kcl, headlamp, inspektor-gadget, tekton-stepaction, meshery, opencost",
"description": "The following kinds are supported at the moment: falco, helm, olm, opa, tbaction, krew, helm-plugin, tekton-task, keda-scaler, coredns, keptn, tekton-pipeline, container, kubewarden, gatekeeper, kyverno, knative-client-plugin, backstage, argo-template, kubearmor, kcl, headlamp, inspektor-gadget, tekton-stepaction, meshery, opencost, radius",
"type": "array",
"items": {
"type": "string"
Expand Down
4 changes: 3 additions & 1 deletion cmd/ah/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func newLintCmd() *cobra.Command {
return lint(opts, &output{cmd.OutOrStdout()})
},
}
lintCmd.Flags().StringVarP(&opts.kind, "kind", "k", "helm", "repository kind: argo-template, backstage, coredns, falco, gatekeeper, headlamp, helm, helm-plugin, inspektor-gadget, kcl, keda-scaler, keptn, knative-client-plugin, krew, kubearmor, kubewarden, kyverno, meshery, olm, opa, opencost, tbaction, tekton-pipeline, tekton-stepaction, tekton-task")
lintCmd.Flags().StringVarP(&opts.kind, "kind", "k", "helm", "repository kind: argo-template, backstage, coredns, falco, gatekeeper, headlamp, helm, helm-plugin, inspektor-gadget, kcl, keda-scaler, keptn, knative-client-plugin, krew, kubearmor, kubewarden, kyverno, meshery, olm, opa, opencost, radius, tbaction, tekton-pipeline, tekton-stepaction, tekton-task")
lintCmd.Flags().StringVarP(&opts.path, "path", "p", ".", "repository's packages path")
lintCmd.Flags().StringVarP(&opts.tektonVersioning, "tekton-versioning", "", hub.TektonDirBasedVersioning, "tekton versioning option: directory, git")
return lintCmd
Expand Down Expand Up @@ -134,6 +134,7 @@ func lint(opts *lintOptions, out *output) error {
hub.Meshery,
hub.OPA,
hub.OpenCost,
hub.Radius,
hub.TBAction:
report = lintGeneric(opts.path, kind)
case hub.Helm:
Expand Down Expand Up @@ -761,6 +762,7 @@ func (out *output) printPkgDetails(pkg *hub.Package) {
hub.Meshery,
hub.OPA,
hub.OpenCost,
hub.Radius,
hub.TBAction:

// Install
Expand Down
5 changes: 5 additions & 0 deletions database/migrations/schema/060_radius_recipes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
insert into repository_kind values (26, 'Radius recipes');

---- create above / drop below ----

delete from repository_kind where repository_kind_id = 26;
3 changes: 2 additions & 1 deletion database/tests/schema/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ select results_eq(
(22, 'Inspektor gadgets'),
(23, 'Tekton stepactions'),
(24, 'Meshery designs'),
(25, 'OpenCost plugins')
(25, 'OpenCost plugins'),
(26, 'Radius recipes')
$$,
'Repository kinds should exist'
);
Expand Down
63 changes: 63 additions & 0 deletions docs/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,29 @@ paths:
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/radius/{repoName}/{packageName}":
get:
tags:
- Packages
summary: Get package details
description: Get package details
operationId: getRadiusRecipeDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
responses:
"200":
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/RadiusRecipe"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/tbaction/{repoName}/{packageName}":
get:
tags:
Expand Down Expand Up @@ -2242,6 +2265,30 @@ paths:
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/radius/{repoName}/{packageName}/{version}":
get:
tags:
- Packages
summary: Get package version details
description: Get package version details
operationId: getRadiusRecipeVersionDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
- $ref: "#/components/parameters/VersionParam"
responses:
"200":
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/RadiusRecipe"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/tbaction/{repoName}/{packageName}/{version}":
get:
tags:
Expand Down Expand Up @@ -4509,6 +4556,18 @@ components:
condition: (evt.num < 0)
OpencostPlugin:
$ref: "#/components/schemas/Package"
RadiusRecipe:
allOf:
- $ref: "#/components/schemas/Package"
- type: object
properties:
data:
type: object
properties:
recipe:
type: object
nullable: false
additionalProperties: true
TBActionPackage:
$ref: "#/components/schemas/Package"
TektonPipelinePackage:
Expand Down Expand Up @@ -5019,6 +5078,7 @@ components:
* `23` - Tekton stepactions
* `24` - Meshery designs
* `25` - Opencost plugins
* `26` - Radius recipes
RepositoryKindParam:
type: string
enum:
Expand Down Expand Up @@ -5048,6 +5108,7 @@ components:
- tekton-stepaction
- meshery
- opencost
- radius
description: |
Repository kind name:
* `helm` - Helm charts
Expand Down Expand Up @@ -5076,6 +5137,7 @@ components:
* `tekton-stepaction` - Tekton stepactions
* `meshery` - Meshery designs
* `opencost` - Opencost plugins
* `radius` - Radius recipes
RepositorySummary:
type: object
required:
Expand Down Expand Up @@ -5621,6 +5683,7 @@ components:
* `23` - Tekton stepactions
* `24` - Meshery designs
* `25` - Opencost plugins
* `26` - Radius recipes
PackageNameParam:
in: path
name: packageName
Expand Down
54 changes: 54 additions & 0 deletions docs/radius_recipes_repositories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Radius recipes repositories

Radius recipes repositories are expected to be hosted in GitHub, GitLab or Bitbucket repos. When adding your repository to Artifact Hub, the url used **must** follow the following format:

- `https://github.com/user/repo[/path/to/packages]`
- `https://gitlab.com/user/repo[/path/to/packages]`
- `https://bitbucket.org/user/repo[/path/to/packages]`

By default the `master` branch is used, but it's possible to specify a different one from the UI.

*Please NOTE that the repository URL used when adding the repository to Artifact Hub **must NOT** contain the git hosting platform specific parts, like **tree/branch**, just the path to your packages like it would show in the filesystem.*

The *path/to/packages* provided can contain metadata for one or more packages. Each package version **must** be on a separate folder, and it's up to you to decide if you want to publish one or multiple versions of your package.

The structure of a repository with multiple recipes packages and versions could look something like this:

```sh
$ tree path/to/packages
path/to/packages
├── artifacthub-repo.yml
├── recipe1
│   ├── 1.0.0
│   │   ├── README.md
│   │   ├── artifacthub-pkg.yml
│   │   └── recipe.bicep
│   └── 2.0.0
│      ├── README.md
│      ├── artifacthub-pkg.yml
│   └── recipe.bicep
└── recipe2
└── 1.0.0
      ├── README.md
     ├── artifacthub-pkg.yml
     ├── main.tf
└── variables.tf
```

This structure is flexible, and in some cases where you only have a package and a version it can be greatly simplified. In the case of a single package with a single version available at a time (the publisher doesn't want to make previous ones available, for example), the structure could look like this:

```sh
$ tree path/to/packages
path/to/packages
├── artifacthub-repo.yml
└── recipe1
   ├── README.md
   ├── recipe.bicep
└── artifacthub-pkg.yml
```

In the previous case, even the `package1` directory could be omitted. The reason is that both packages names and versions are read from the `artifacthub-pkg.yml` metadata file, so directories names are not used at all.

Each package version **needs** an `artifacthub-pkg.yml` metadata file. Please see the file [spec](https://github.com/artifacthub/hub/blob/master/docs/metadata/artifacthub-pkg.yml) for more details. The [artifacthub-repo.yml](https://github.com/artifacthub/hub/blob/master/docs/metadata/artifacthub-repo.yml) repository metadata file shown above can be used to setup features like [Verified publisher](https://github.com/artifacthub/hub/blob/master/docs/repositories.md#verified-publisher) or [Ownership claim](https://github.com/artifacthub/hub/blob/master/docs/repositories.md#ownership-claim). This file must be located at `/path/to/packages`.

Once you have added your repository, you are all set up. As you add new versions of your recipes packages or new packages to your git repository, they'll be automatically indexed and listed in Artifact Hub.
1 change: 1 addition & 0 deletions docs/repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The following repositories kinds are supported at the moment:
- [OLM operators repositories](https://github.com/artifacthub/hub/blob/master/docs/olm_operators_repositories.md)
- [OPA policies repositories](https://github.com/artifacthub/hub/blob/master/docs/opa_policies_repositories.md)
- [OpenCost plugins repositories](https://github.com/artifacthub/hub/blob/master/docs/opencost_plugins_repositories.md)
- [Radius recipes repositories](https://github.com/artifacthub/hub/blob/master/docs/radius_recipes_repositories.md)
- [Tekton pipelines repositories](https://github.com/artifacthub/hub/blob/master/docs/tekton_pipelines_repositories.md)
- [Tekton tasks repositories](https://github.com/artifacthub/hub/blob/master/docs/tekton_tasks_repositories.md)
- [Tekton stepactions repositories](https://github.com/artifacthub/hub/blob/master/docs/tekton_stepactions_repositories.md)
Expand Down
6 changes: 6 additions & 0 deletions docs/www/headers/radius_recipes_repositories
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "Radius recipes"
aliases: [
"/radius_recipes_repositories",
]
---
4 changes: 2 additions & 2 deletions internal/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (h *Handlers) setupRouter() {
r.Get("/stats", h.Packages.GetStats)
r.With(corsMW).Get("/search", h.Packages.Search)
r.With(h.Users.RequireLogin).Get("/starred", h.Packages.GetStarredByUser)
r.Route("/{^helm$|^falco$|^opa$|^olm|^tbaction|^krew|^helm-plugin|^tekton-task|^keda-scaler|^coredns|^keptn|^tekton-pipeline|^container|^kubewarden|^gatekeeper|^kyverno|^knative-client-plugin|^backstage|^argo-template|^kubearmor|^kcl|^headlamp|^inspektor-gadget|^tekton-stepaction|^meshery|^opencost$}/{repoName}/{packageName}", func(r chi.Router) {
r.Route("/{^helm$|^falco$|^opa$|^olm|^tbaction|^krew|^helm-plugin|^tekton-task|^keda-scaler|^coredns|^keptn|^tekton-pipeline|^container|^kubewarden|^gatekeeper|^kyverno|^knative-client-plugin|^backstage|^argo-template|^kubearmor|^kcl|^headlamp|^inspektor-gadget|^tekton-stepaction|^meshery|^opencost|^radius$}/{repoName}/{packageName}", func(r chi.Router) {
r.Get("/feed/rss", h.Packages.RssFeed)
r.With(corsMW).Get("/summary", h.Packages.GetSummary)
r.Get("/{version}", h.Packages.Get)
Expand Down Expand Up @@ -430,7 +430,7 @@ func (h *Handlers) setupRouter() {

// Index special entry points
r.Route("/packages", func(r chi.Router) {
r.Route("/{^helm$|^falco$|^opa$|^olm|^tbaction|^krew|^helm-plugin|^tekton-task|^keda-scaler|^coredns|^keptn|^tekton-pipeline|^container|^kubewarden|^gatekeeper|^kyverno|^knative-client-plugin|^backstage|^argo-template|^kubearmor|^kcl|^headlamp|^inspektor-gadget|^tekton-stepaction|^meshery|^opencost$}/{repoName}/{packageName}", func(r chi.Router) {
r.Route("/{^helm$|^falco$|^opa$|^olm|^tbaction|^krew|^helm-plugin|^tekton-task|^keda-scaler|^coredns|^keptn|^tekton-pipeline|^container|^kubewarden|^gatekeeper|^kyverno|^knative-client-plugin|^backstage|^argo-template|^kubearmor|^kcl|^headlamp|^inspektor-gadget|^tekton-stepaction|^meshery|^opencost|^radius$}/{repoName}/{packageName}", func(r chi.Router) {
r.With(h.Packages.InjectIndexMeta).Get("/{version}", h.Static.Index)
r.With(h.Packages.InjectIndexMeta).Get("/", h.Static.Index)
})
Expand Down
11 changes: 11 additions & 0 deletions internal/handlers/pkg/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2210,6 +2210,17 @@ func TestBuildURL(t *testing.T) {
"2.0.0",
baseURL + "/packages/opencost/repo1/pkg1/2.0.0",
},
{
&hub.Package{
NormalizedName: "pkg1",
Repository: &hub.Repository{
Kind: hub.Radius,
Name: "repo1",
},
},
"2.0.0",
baseURL + "/packages/radius/repo1/pkg1/2.0.0",
},
}
for _, tc := range testCases {
tc := tc
Expand Down
7 changes: 7 additions & 0 deletions internal/hub/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ const (

// OpenCost represents a repository with OpenCost plugins.
OpenCost RepositoryKind = 25

// Radius represents a repository with Radius recipes.
Radius RepositoryKind = 26
)

// GetKindName returns the name of the provided repository kind.
Expand Down Expand Up @@ -173,6 +176,8 @@ func GetKindName(kind RepositoryKind) string {
return "opa"
case OpenCost:
return "opencost"
case Radius:
return "radius"
case TBAction:
return "tbaction"
case TektonPipeline:
Expand Down Expand Up @@ -234,6 +239,8 @@ func GetKindFromName(kind string) (RepositoryKind, error) {
return OPA, nil
case "opencost":
return OpenCost, nil
case "radius":
return Radius, nil
case "tbaction":
return TBAction, nil
case "tekton-pipeline":
Expand Down
4 changes: 4 additions & 0 deletions internal/repo/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ var (
hub.OLM,
hub.OPA,
hub.OpenCost,
hub.Radius,
hub.TBAction,
hub.TektonPipeline,
hub.TektonTask,
Expand Down Expand Up @@ -304,6 +305,7 @@ func (m *Manager) ClaimOwnership(ctx context.Context, repoName, orgName string)
hub.OLM,
hub.OPA,
hub.OpenCost,
hub.Radius,
hub.TBAction,
hub.TektonPipeline,
hub.TektonTask,
Expand Down Expand Up @@ -487,6 +489,7 @@ func (m *Manager) locateMetadataFile(r *hub.Repository, basePath string) string
hub.OLM,
hub.OPA,
hub.OpenCost,
hub.Radius,
hub.TBAction,
hub.TektonPipeline,
hub.TektonTask,
Expand Down Expand Up @@ -855,6 +858,7 @@ func (m *Manager) validateURL(r *hub.Repository) error {
hub.OLM,
hub.OPA,
hub.OpenCost,
hub.Radius,
hub.TBAction,
hub.TektonPipeline,
hub.TektonTask,
Expand Down
1 change: 1 addition & 0 deletions internal/tracker/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func SetupSource(i *hub.TrackerSourceInput) hub.TrackerSource {
hub.Meshery,
hub.OPA,
hub.OpenCost,
hub.Radius,
hub.TBAction:
source = generic.NewTrackerSource(i)
case hub.TektonTask, hub.TektonPipeline, hub.TektonStepAction:
Expand Down
Loading
Loading