Skip to content

Commit

Permalink
Add support for Backstage plugins (#2739)
Browse files Browse the repository at this point in the history
Closes #1509

Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
Signed-off-by: Cintia Sanchez Garcia <cynthiasg@icloud.com>
Co-authored-by: Sergio Castaño Arteaga <tegioz@icloud.com>
Co-authored-by: Cintia Sanchez Garcia <cynthiasg@icloud.com>
  • Loading branch information
tegioz and cynthia-sg authored Feb 6, 2023
1 parent cc75c86 commit f7fff24
Show file tree
Hide file tree
Showing 68 changed files with 332 additions and 60 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Discovering artifacts to use with CNCF projects can be difficult. If every CNCF

At the moment, the following artifacts kinds are supported *(with plans to support more projects to follow)*:

- [Backstage plugins](https://backstage.io)
- [Containers images](https://opencontainers.org)
- [CoreDNS plugins](https://coredns.io/)
- [Falco configurations](https://falco.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 Kubernetes packages.
type: application
version: 1.12.1-2
version: 1.12.1-3
appVersion: 1.12.0
kubeVersion: ">= 1.19.0-0"
home: https://artifacthub.io
Expand All @@ -24,6 +24,7 @@ keywords:
- gatekeeper
- kyverno
- knative
- backstage
maintainers:
- name: Sergio
email: tegioz@icloud.com
Expand Down
7 changes: 5 additions & 2 deletions charts/artifact-hub/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@
"title": "Lifetime after finished execution",
"description": "Limits the lifetime of the job after it has finished execution",
"default": null,
"type": ["null", "integer"]
"type": [
"null",
"integer"
]
}
},
"required": [
Expand Down Expand Up @@ -1066,7 +1069,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",
"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",
"type": "array",
"items": {
"type": "string"
Expand Down
10 changes: 9 additions & 1 deletion cmd/ah/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func newLintCmd() *cobra.Command {
return lint(opts, &output{cmd.OutOrStdout()})
},
}
lintCmd.Flags().StringVarP(&opts.kind, "kind", "k", "helm", "repository kind: coredns, falco, helm, helm-plugin, keda-scaler, keptn, krew, kubewarden, olm, opa, tbaction, tekton-task, tekton-pipeline")
lintCmd.Flags().StringVarP(&opts.kind, "kind", "k", "helm", "repository kind: backstage, coredns, falco, gatekeeper, helm, helm-plugin, keda-scaler, keptn, knative-client-plugin, krew, kubewarden, kyverno, olm, opa, tbaction, tekton-task, tekton-pipeline")
lintCmd.Flags().StringVarP(&opts.path, "path", "p", ".", "repository's packages path")
return lintCmd
}
Expand All @@ -109,11 +109,15 @@ func lint(opts *lintOptions, out *output) error {
var report *lintReport
switch kind {
case
hub.Backstage,
hub.CoreDNS,
hub.Falco,
hub.Gatekeeper,
hub.KedaScaler,
hub.Keptn,
hub.KnativeClientPlugin,
hub.Kubewarden,
hub.Kyverno,
hub.OPA,
hub.TBAction:
report = lintGeneric(opts.path, kind)
Expand Down Expand Up @@ -605,11 +609,15 @@ func (out *output) printPkgDetails(pkg *hub.Package) {
// Values specific to a repository kind
switch pkg.Repository.Kind {
case
hub.Backstage,
hub.CoreDNS,
hub.Falco,
hub.Gatekeeper,
hub.KedaScaler,
hub.Keptn,
hub.KnativeClientPlugin,
hub.Kubewarden,
hub.Kyverno,
hub.OPA,
hub.TBAction:

Expand Down
5 changes: 5 additions & 0 deletions database/migrations/schema/044_backstage_plugins.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
insert into repository_kind values (17, 'Backstage plugins');

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

delete from repository_kind where repository_kind_id = 17;
3 changes: 2 additions & 1 deletion database/tests/schema/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ select results_eq(
(13, 'Kubewarden policies'),
(14, 'Gatekeeper policies'),
(15, 'Kyverno policies'),
(16, 'Knative client plugins')
(16, 'Knative client plugins'),
(17, 'Backstage plugins')
$$,
'Repository kinds should exist'
);
Expand Down
55 changes: 54 additions & 1 deletion docs/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,29 @@ paths:
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/backstage/{repoName}/{packageName}":
get:
tags:
- Packages
summary: Get package details
description: Get package details
operationId: getBackstagePluginsDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
responses:
"200":
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/BackstagePlugin"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/container/{repoName}/{packageName}":
get:
tags:
Expand Down Expand Up @@ -1503,6 +1526,30 @@ paths:
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/backstage/{repoName}/{packageName}/{version}":
get:
tags:
- Packages
summary: Get package version details
description: Get package version details
operationId: getBackstagePluginsVersionDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
- $ref: "#/components/parameters/VersionParam"
responses:
"200":
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/BackstagePlugin"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/container/{repoName}/{packageName}/{version}":
get:
tags:
Expand Down Expand Up @@ -3429,6 +3476,8 @@ components:
name: user1
total: 3
filter_key: user
BackstagePlugin:
$ref: "#/components/schemas/Package"
ContainerImage:
allOf:
- $ref: "#/components/schemas/Package"
Expand Down Expand Up @@ -4311,6 +4360,7 @@ components:
* `14` - Gatekeeper policies
* `15` - Kyverno policies
* `16` - Knative client plugins
* `17` - Backstage plugins
RepositoryKindParam:
type: string
enum:
Expand All @@ -4331,6 +4381,7 @@ components:
- gatekeeper
- kyverno
- knative-client-plugin
- backstage
description: |
Repository kind name:
* `helm` - Helm charts
Expand All @@ -4350,6 +4401,7 @@ components:
* `gatekeeper` - Gatekeeper policies
* `kyverno` - Kyverno policies
* `knative-client-plugin` - Knative client plugins
* `backstage` - Backstage plugins
RepositorySummary:
type: object
required:
Expand Down Expand Up @@ -4848,7 +4900,8 @@ components:
* `13` - Kubewarden policies
* `14` - Gatekeeper policies
* `15` - Kyverno policies
* `15` - Knative client plugins
* `16` - Knative client plugins
* `17` - Backstage plugins
PackageNameParam:
in: path
name: packageName
Expand Down
49 changes: 49 additions & 0 deletions docs/backstage_plugins_repositories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## Backstage plugins repositories

Backstage plugins 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 plugins packages and versions could look something like this:

```sh
$ tree path/to/packages
path/to/packages
├── artifacthub-repo.yml
├── package1
│   ├── 1.0.0
│   │   ├── README.md
│   │   └── artifacthub-pkg.yml
│   └── 2.0.0
│      ├── README.md
│   └── artifacthub-pkg.yml
└── package2
└── 1.0.0
      ├── README.md
└── artifacthub-pkg.yml
```

This structure is flexible, and in some cases 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
└── package1
   ├── README.md
└── 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 plugins packages or even 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 @@ -4,6 +4,7 @@ Artifact Hub allows publishers to list their content in an automated way. Publis

The following repositories kinds are supported at the moment:

- [Backstage plugins repositories](https://github.com/artifacthub/hub/blob/master/docs/backstage_plugins_repositories.md)
- [Containers images repositories](https://github.com/artifacthub/hub/blob/master/docs/container_images_repositories.md)
- [CoreDNS plugins repositories](https://github.com/artifacthub/hub/blob/master/docs/coredns_plugins_repositories.md)
- [Falco rules repositories](https://github.com/artifacthub/hub/blob/master/docs/falco_rules_repositories.md)
Expand Down
6 changes: 6 additions & 0 deletions docs/www/headers/backstage_plugins_repositories
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "Backstage plugins"
aliases: [
"/backstage_plugins_repositories",
]
---
1 change: 0 additions & 1 deletion docs/www/headers/container_images_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Containers images"
weight: 1
aliases: [
"/container_images_repositories"
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/coredns_plugins_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "CoreDNS plugins"
weight: 2
aliases: [
"/coredns_plugins_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/falco_rules_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Falco rules"
weight: 3
aliases: [
"/falco_rules_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/gatekeeper_policies_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Gatekeeper policies"
weight: 4
aliases: [
"/gatekeeper_policies_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/helm_annotations
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Helm"
weight: 1
aliases: [
"/helm_annotations"
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/helm_charts_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Helm charts"
weight: 5
aliases: [
"/helm_charts_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/helm_plugins_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Helm plugins"
weight: 6
aliases: [
"/helm_plugins_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/keda_scalers_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "KEDA scalers"
weight: 7
aliases: [
"/keda_scalers_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/keptn_annotations
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Keptn"
weight: 2
aliases: [
"/keptn_annotations",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/keptn_integrations_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Keptn integrations"
weight: 8
aliases: [
"/keptn_integrations_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/knative_client_plugins_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Knative client plugins"
weight: 9
aliases: [
"/knative_client_plugins_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/krew_annotations
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Krew"
weight: 3
aliases: [
"/krew_annotations",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/krew_kubectl_plugins_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Krew kubectl plugins"
weight: 10
aliases: [
"/krew_kubectl_plugins_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/kubewarden_annotations
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Kubewarden"
weight: 4
aliases: [
"/kubewarden_annotations",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/kubewarden_policies_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Kubewarden policies"
weight: 11
aliases: [
"/kubewarden_policies_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/kyverno_annotations
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Kyverno"
weight: 5
aliases: [
"/kyverno_annotations"
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/kyverno_policies_repositories
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "Kyverno policies"
weight: 12
aliases: [
"/kyverno_policies_repositories",
]
Expand Down
1 change: 0 additions & 1 deletion docs/www/headers/olm_annotations
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "OLM"
weight: 6
aliases: [
"/olm_annotations",
]
Expand Down
Loading

0 comments on commit f7fff24

Please sign in to comment.