Skip to content

fix: add stepaction as a valid kind in the hub resolver #8635

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

Merged
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
13 changes: 11 additions & 2 deletions pkg/remoteresolution/resolver/hub/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ func TestValidate(t *testing.T) {
version: "bar",
catalog: "baz",
hubType: ArtifactHubType,
}, {
},
{
testName: "stepaction validation",
kind: "stepaction",
resourceName: "foo",
version: "bar",
catalog: "baz",
hubType: ArtifactHubType,
},
{
testName: "tekton type validation",
kind: "task",
resourceName: "foo",
Expand Down Expand Up @@ -134,7 +143,7 @@ func TestValidateConflictingKindName(t *testing.T) {
hubType string
}{
{
kind: "not-taskpipeline",
kind: "not-taskpipelineorstepaction",
name: "foo",
version: "bar",
catalog: "baz",
Expand Down
11 changes: 9 additions & 2 deletions pkg/resolution/resolver/hub/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"io"
"net/http"
"slices"
"strings"

goversion "github.com/hashicorp/go-version"
Expand All @@ -45,6 +46,8 @@ const (
disabledError = "cannot handle resolution request, enable-hub-resolver feature flag not true"
)

var supportedKinds = []string{"task", "pipeline", "stepaction"}

// Resolver implements a framework.Resolver that can fetch files from OCI bundles.
//
// Deprecated: Use [github.com/tektoncd/pipeline/pkg/remoteresolution/resolver/hub.Resolver] instead.
Expand Down Expand Up @@ -359,8 +362,8 @@ func validateParams(ctx context.Context, paramsMap map[string]string, tektonHubU
missingParams = append(missingParams, ParamVersion)
}
if kind, ok := paramsMap[ParamKind]; ok {
if kind != "task" && kind != "pipeline" {
return errors.New("kind param must be task or pipeline")
if !isSupportedKind(kind) {
return fmt.Errorf("kind param must be one of: %s", strings.Join(supportedKinds, ", "))
}
}
if hubType, ok := paramsMap[ParamType]; ok {
Expand Down Expand Up @@ -439,3 +442,7 @@ func resolveVersionConstraint(ctx context.Context, paramsMap map[string]string,
}
return ret, nil
}

func isSupportedKind(kindValue string) bool {
return slices.Contains[[]string, string](supportedKinds, kindValue)
}
13 changes: 11 additions & 2 deletions pkg/resolution/resolver/hub/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ func TestValidateParams(t *testing.T) {
version: "bar",
catalog: "baz",
hubType: ArtifactHubType,
}, {
},
{
testName: "stepaction validation",
kind: "stepaction",
resourceName: "foo",
version: "bar",
catalog: "baz",
hubType: ArtifactHubType,
},
{
testName: "tekton type validation",
kind: "task",
resourceName: "foo",
Expand Down Expand Up @@ -148,7 +157,7 @@ func TestValidateParamsConflictingKindName(t *testing.T) {
hubType string
}{
{
kind: "not-taskpipeline",
kind: "not-taskpipelineorstepaction",
name: "foo",
version: "bar",
catalog: "baz",
Expand Down
Loading