Skip to content

Commit

Permalink
Fix StepAction support in Cluster resolver
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Noble <[email protected]>
  • Loading branch information
AverageMarcus committed Nov 11, 2024
1 parent 7056a41 commit a09aec9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/resolution/resolver/cluster/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func populateParamsWithDefaults(ctx context.Context, origParams []pipelinev1.Par
} else {
params[KindParam] = pKind.StringVal
}
if kindVal, ok := params[KindParam]; ok && kindVal != "task" && kindVal != "pipeline" {
if kindVal, ok := params[KindParam]; ok && kindVal != "task" && kindVal != "pipeline" && kindVal != "stepaction" {
return nil, fmt.Errorf("unknown or unsupported resource kind '%s'", kindVal)
}

Expand Down
40 changes: 40 additions & 0 deletions pkg/resolution/resolver/cluster/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,28 @@ func TestResolve(t *testing.T) {
t.Fatalf("couldn't marshal pipeline: %v", err)
}

exampleStepAction := &pipelinev1beta1.StepAction{
ObjectMeta: metav1.ObjectMeta{
Name: "example-stepaction",
Namespace: "stepaction-ns",
ResourceVersion: "00003",
UID: "c123",
},
TypeMeta: metav1.TypeMeta{
Kind: "StepAction",
APIVersion: "tekton.dev/v1beta1",
},
Spec: pipelinev1beta1.StepActionSpec{},
}
stepActionChecksum, err := exampleStepAction.Checksum()
if err != nil {
t.Fatalf("couldn't checksum stepaction: %v", err)
}
stepActionAsYAML, err := yaml.Marshal(exampleStepAction)
if err != nil {
t.Fatalf("couldn't marshal stepaction: %v", err)
}

testCases := []struct {
name string
kind string
Expand Down Expand Up @@ -323,6 +345,23 @@ func TestResolve(t *testing.T) {
},
},
},
}, {
name: "successful stepaction",
kind: "stepaction",
resourceName: exampleStepAction.Name,
namespace: exampleStepAction.Namespace,
expectedStatus: &v1beta1.ResolutionRequestStatus{
Status: duckv1.Status{},
ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{
Data: base64.StdEncoding.Strict().EncodeToString(stepActionAsYAML),
RefSource: &pipelinev1.RefSource{
URI: "/apis/tekton.dev/v1/namespaces/stepaction-ns/stepaction/example-stepaction@c123",
Digest: map[string]string{
"sha256": hex.EncodeToString(stepActionChecksum),
},
},
},
},
}, {
name: "default namespace",
kind: "pipeline",
Expand Down Expand Up @@ -427,6 +466,7 @@ func TestResolve(t *testing.T) {
Pipelines: []*pipelinev1.Pipeline{examplePipeline},
ResolutionRequests: []*v1beta1.ResolutionRequest{request},
Tasks: []*pipelinev1.Task{exampleTask},
StepActions: []*pipelinev1beta1.StepAction{exampleStepAction},
}

resolver := &cluster.Resolver{}
Expand Down

0 comments on commit a09aec9

Please sign in to comment.