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 Tekton StepActions #3745

Merged
merged 1 commit into from
Apr 3, 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 .ct.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
helm-extra-args: --timeout 180s
chart-repos:
- stable=https://charts.helm.sh/stable
validate-maintainers: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ At the moment, the following artifacts kinds are supported *(with plans to suppo
- [Kyverno policies](https://kyverno.io)
- [OLM operators](https://github.com/operator-framework)
- [Open Policy Agent (OPA) policies](https://www.openpolicyagent.org/)
- [Tekton tasks and pipelines](https://tekton.dev/)
- [Tekton tasks, pipelines and stepactions](https://tekton.dev/)
- [Tinkerbell actions](https://tinkerbell.org/)

You can use Artifact Hub to:
Expand Down
2 changes: 1 addition & 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.17.1-0
version: 1.17.1-1
appVersion: 1.17.0
kubeVersion: ">= 1.19.0-0"
home: https://artifacthub.io
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",
"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",
"type": "array",
"items": {
"type": "string"
Expand Down
10 changes: 5 additions & 5 deletions 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: argo-template, backstage, coredns, falco, gatekeeper, headlamp, helm, helm-plugin, inspektor-gadget, kcl, keda-scaler, keptn, knative-client-plugin, krew, kubearmor, kubewarden, kyverno, olm, opa, tbaction, tekton-task, tekton-pipeline")
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, olm, opa, tbaction, tekton-task, tekton-pipeline, tekton-stepaction")
lintCmd.Flags().StringVarP(&opts.path, "path", "p", ".", "repository's packages path")
return lintCmd
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func lint(opts *lintOptions, out *output) error {
report = lintKrew(opts.path)
case hub.OLM:
report = lintOLM(opts.path)
case hub.TektonTask, hub.TektonPipeline:
case hub.TektonTask, hub.TektonPipeline, hub.TektonStepAction:
report = lintTekton(opts.path, kind)
default:
return errors.New("kind not supported yet")
Expand Down Expand Up @@ -376,9 +376,9 @@ func lintOLM(basePath string) *lintReport {
return report
}

// lintTekton checks if the Tekton tasks or pipelines available in the path
// provided are ready to be processed by the Tekton tracker source and listed
// on Artifact Hub.
// lintTekton checks if the Tekton tasks, pipelines or stepactions available in
// the path provided are ready to be processed by the Tekton tracker source and
// listed on Artifact Hub.
func lintTekton(basePath string, kind hub.RepositoryKind) *lintReport {
report := &lintReport{}
repository := &hub.Repository{
Expand Down
5 changes: 5 additions & 0 deletions database/migrations/schema/057_tekton_stepactions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
insert into repository_kind values (23, 'Tekton stepactions');

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

delete from repository_kind where repository_kind_id = 23;
3 changes: 2 additions & 1 deletion database/tests/schema/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ select results_eq(
(19, 'KubeArmor policies'),
(20, 'KCL modules'),
(21, 'Headlamp plugins'),
(22, 'Inspektor gadgets')
(22, 'Inspektor gadgets'),
(23, 'Tekton stepactions')
$$,
'Repository kinds should exist'
);
Expand Down
78 changes: 78 additions & 0 deletions docs/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,30 @@ paths:
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/tekton-stepaction/{repoName}/{packageName}":
get:
tags:
- Packages
summary: Get package details
description: Get package details
operationId: getTektonStepActionDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
responses:
"200":
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/TektonStepActionPackage"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"

"/packages/tekton-task/{repoName}/{packageName}":
get:
tags:
Expand Down Expand Up @@ -2172,6 +2196,30 @@ paths:
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/tekton-stepaction/{repoName}/{packageName}/{version}":
get:
tags:
- Packages
summary: Get package version details
description: Get package version details
operationId: getTektonStepActionVersionDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
- $ref: "#/components/parameters/VersionParam"
responses:
"200":
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/TektonStepActionPackage"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/tekton-task/{repoName}/{packageName}/{version}":
get:
tags:
Expand Down Expand Up @@ -4396,6 +4444,32 @@ components:
type: string
nullable: false
example: darwin/amd64
TektonStepActionPackage:
allOf:
- $ref: "#/components/schemas/Package"
- type: object
properties:
data:
type: object
properties:
pipelines.minVersion:
type: string
example: 2.0.0
manifestRaw:
type: string
additionalProperties:
type: string
example: "apiVersion: tekton.dev/v1beta1"
examples:
type: object
nullable: false
additionalProperties: true
platforms:
type: array
items:
type: string
nullable: false
example: darwin/amd64
TektonTaskPackage:
allOf:
- $ref: "#/components/schemas/Package"
Expand Down Expand Up @@ -4832,6 +4906,7 @@ components:
* `20` - KCL packages
* `21` - Headlamp plugins
* `22` - Inspektor gadgets
* `23` - Tekton stepactions
RepositoryKindParam:
type: string
enum:
Expand All @@ -4858,6 +4933,7 @@ components:
- kcl
- headlamp
- inspektor-gadget
- tekton-stepaction
description: |
Repository kind name:
* `helm` - Helm charts
Expand All @@ -4883,6 +4959,7 @@ components:
* `kcl` - KCL packages
* `headlamp` - Headlamp plugins
* `inspektor-gadget` - Inspektor gadgets
* `tekton-stepaction` - Tekton stepactions
RepositorySummary:
type: object
required:
Expand Down Expand Up @@ -5425,6 +5502,7 @@ components:
* `20` - KCL packages
* `21` - Headlamp plugins
* `22` - Inspektor gadgets
* `23` - Tekton stepactions
PackageNameParam:
in: path
name: packageName
Expand Down
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:
- [OPA policies repositories](https://github.com/artifacthub/hub/blob/master/docs/opa_policies_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)
- [Tinkerbell actions repositories](https://github.com/artifacthub/hub/blob/master/docs/tinkerbell_actions_repositories.md)

This guide also contains additional information about the following repositories topics:
Expand Down
4 changes: 2 additions & 2 deletions docs/security_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Artifact Hub will try to extract the containers images used by Helm charts from

The images used by an OLM operator are extracted from the `containerImage` annotation in the [CSV file metadata section](https://github.com/operator-framework/community-operators/blob/master/docs/packaging-required-fields.md), as well as from the `related images` section in the CSV spec. Most of the OLM operators currently listed in Artifact Hub provide that information already, so security reports for them are already available in Artifact Hub with no extra effort required.

### Tekton tasks and pipelines
### Tekton tasks, pipelines and stepactions

The images used by Tekton tasks and pipelines are extracted from the [`task.step.image`](https://github.com/tektoncd/pipeline/blob/main/docs/tasks.md#running-scripts-within-steps) fields of the resource yaml file. If the `image` value is specified by [`params`](https://github.com/tektoncd/pipeline/blob/main/docs/tasks.md#specifying-parameters), the default value of the params (if provided) is used to run the security report. You can find examples with explanations [here](https://github.com/tektoncd/community/blob/main/teps/0079-tekton-catalog-support-tiers.md#extract-container-images-from-catalogs). Please note that the security reports do not include user-provided container images if the default value of the image `params` are overwritten by `pipelineRun` or `taskRun` at run time.
The images used by Tekton tasks, pipelines and stepactions are extracted from the [`task.step.image`](https://github.com/tektoncd/pipeline/blob/main/docs/tasks.md#running-scripts-within-steps) fields of the resource yaml file. If the `image` value is specified by [`params`](https://github.com/tektoncd/pipeline/blob/main/docs/tasks.md#specifying-parameters), the default value of the params (if provided) is used to run the security report. You can find examples with explanations [here](https://github.com/tektoncd/community/blob/main/teps/0079-tekton-catalog-support-tiers.md#extract-container-images-from-catalogs). Please note that the security reports do not include user-provided container images if the default value of the image `params` are overwritten by `pipelineRun` or `taskRun` at run time.

### CoreDNS plugins, KEDA scalers, Keptn integrations, OPA policies and Tinkerbell actions

Expand Down
3 changes: 3 additions & 0 deletions docs/tekton_stepactions_repositories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Tekton stepactions repositories

Tekton stepactions repositories are expected to follow the same rules as Tekton tasks repositories. Please see the [Tekton tasks repositories](https://github.com/artifacthub/hub/blob/master/docs/tekton_tasks_repositories.md) documentation for more details.
6 changes: 6 additions & 0 deletions docs/www/headers/tekton_stepactions_repositories
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "Tekton stepactions"
aliases: [
"/tekton_stepactions_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$}/{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$}/{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$}/{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$}/{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 @@ -2177,6 +2177,17 @@ func TestBuildURL(t *testing.T) {
"2.0.0",
baseURL + "/packages/inspektor-gadget/repo1/pkg1/2.0.0",
},
{
&hub.Package{
NormalizedName: "pkg1",
Repository: &hub.Repository{
Kind: hub.TektonStepAction,
Name: "repo1",
},
},
"2.0.0",
baseURL + "/packages/tekton-stepaction/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 @@ -115,6 +115,9 @@ const (

// InspektorGadget represents a repository with Inspektor Gadgets.
InspektorGadget RepositoryKind = 22

// TektonStepAction represents a repository with Tekton stepactions.
TektonStepAction RepositoryKind = 23
)

// GetKindName returns the name of the provided repository kind.
Expand Down Expand Up @@ -166,6 +169,8 @@ func GetKindName(kind RepositoryKind) string {
return "tekton-pipeline"
case TektonTask:
return "tekton-task"
case TektonStepAction:
return "tekton-stepaction"
default:
return ""
}
Expand Down Expand Up @@ -221,6 +226,8 @@ func GetKindFromName(kind string) (RepositoryKind, error) {
return TektonPipeline, nil
case "tekton-task":
return TektonTask, nil
case "tekton-stepaction":
return TektonStepAction, nil
default:
return -1, errors.New("invalid kind name")
}
Expand Down
12 changes: 8 additions & 4 deletions internal/repo/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ var (
hub.TBAction,
hub.TektonPipeline,
hub.TektonTask,
hub.TektonStepAction,
}
)

Expand Down Expand Up @@ -300,7 +301,8 @@ func (m *Manager) ClaimOwnership(ctx context.Context, repoName, orgName string)
hub.OPA,
hub.TBAction,
hub.TektonPipeline,
hub.TektonTask:
hub.TektonTask,
hub.TektonStepAction:
tmpDir, packagesPath, err := m.rc.CloneRepository(ctx, r)
if err != nil {
return err
Expand Down Expand Up @@ -480,7 +482,8 @@ func (m *Manager) locateMetadataFile(r *hub.Repository, basePath string) string
hub.OPA,
hub.TBAction,
hub.TektonPipeline,
hub.TektonTask:
hub.TektonTask,
hub.TektonStepAction:
mdFile = filepath.Join(basePath, hub.RepositoryMetadataFile)
}
return mdFile
Expand Down Expand Up @@ -579,7 +582,7 @@ func (m *Manager) GetRemoteDigest(ctx context.Context, r *hub.Repository) (strin

case GitRepoURLRE.MatchString(r.URL):
// Do not track repo's digest for Tekton repos using git based versioning
if (r.Kind == hub.TektonTask || r.Kind == hub.TektonPipeline) && r.Data != nil {
if (r.Kind == hub.TektonTask || r.Kind == hub.TektonPipeline || r.Kind == hub.TektonStepAction) && r.Data != nil {
var data *hub.TektonData
if err := json.Unmarshal(r.Data, &data); err != nil {
return "", fmt.Errorf("invalid tekton repository data: %w", err)
Expand Down Expand Up @@ -844,7 +847,8 @@ func (m *Manager) validateURL(r *hub.Repository) error {
hub.OPA,
hub.TBAction,
hub.TektonPipeline,
hub.TektonTask:
hub.TektonTask,
hub.TektonStepAction:
if SchemeIsHTTP(u) && !GitRepoURLRE.MatchString(r.URL) {
return errors.New("invalid url format")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/tracker/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func SetupSource(i *hub.TrackerSourceInput) hub.TrackerSource {
hub.OPA,
hub.TBAction:
source = generic.NewTrackerSource(i)
case hub.TektonTask, hub.TektonPipeline:
case hub.TektonTask, hub.TektonPipeline, hub.TektonStepAction:
source = tekton.NewTrackerSource(i)
}
return source
Expand Down
Loading
Loading