Skip to content

Commit

Permalink
revert change
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongxuanzhang committed Nov 2, 2023
1 parent c79c103 commit 2fe69be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions pkg/reconciler/taskrun/resources/taskref.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ func GetStepActionFunc(tekton clientset.Interface, k8s kubernetes.Interface, req
if step.Ref != nil && step.Ref.Resolver != "" && requester != nil {
// Return an inline function that implements GetTask by calling Resolver.Get with the specified task type and
// casting it to a TaskObject.
return func(ctx context.Context, ref *v1.Ref) (*v1alpha1.StepAction, *v1.RefSource, error) {
resolver := resolution.NewResolver(requester, tr, string(ref.Resolver), trName, namespace, v1.Params{})
return resolveStepAction(ctx, resolver, ref.Name, namespace, kind, k8s, tekton)
return func(ctx context.Context, name string) (*v1alpha1.StepAction, *v1.RefSource, error) {
resolver := resolution.NewResolver(requester, tr, string(step.Ref.Resolver), trName, namespace, v1.Params{})
return resolveStepAction(ctx, resolver, name, namespace, kind, k8s, tekton)
}
}
local := &LocalStepActionRefResolver{
Expand Down Expand Up @@ -262,12 +262,12 @@ type LocalStepActionRefResolver struct {

// GetStepAction will resolve a StepAction from the local cluster using a versioned Tekton client.
// It will return an error if it can't find an appropriate StepAction for any reason.
func (l *LocalStepActionRefResolver) GetStepAction(ctx context.Context, ref *v1.Ref) (*v1alpha1.StepAction, *v1.RefSource, error) {
func (l *LocalStepActionRefResolver) GetStepAction(ctx context.Context, name string) (*v1alpha1.StepAction, *v1.RefSource, error) {
// If we are going to resolve this reference locally, we need a namespace scope.
if l.Namespace == "" {
return nil, nil, fmt.Errorf("must specify namespace to resolve reference to step action %s", ref.Name)
return nil, nil, fmt.Errorf("must specify namespace to resolve reference to step action %s", name)
}
stepAction, err := l.Tektonclient.TektonV1alpha1().StepActions(l.Namespace).Get(ctx, ref.Name, metav1.GetOptions{})
stepAction, err := l.Tektonclient.TektonV1alpha1().StepActions(l.Namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return nil, nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/reconciler/taskrun/resources/taskref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func TestStepActionRef(t *testing.T) {
Tektonclient: tektonclient,
}

task, refSource, err := lc.GetStepAction(ctx, tc.ref)
task, refSource, err := lc.GetStepAction(ctx, tc.ref.Name)
if err != nil {
t.Fatalf("Received unexpected error ( %#v )", err)
}
Expand Down Expand Up @@ -435,7 +435,7 @@ func TestStepActionRef_Error(t *testing.T) {
Tektonclient: tektonclient,
}

_, _, err := lc.GetStepAction(ctx, tc.ref)
_, _, err := lc.GetStepAction(ctx, tc.ref.Name)
if err == nil {
t.Fatal("Expected error but found nil instead")
}
Expand Down Expand Up @@ -591,7 +591,7 @@ func TestGetStepActionFunc_Local(t *testing.T) {
tektonclient := fake.NewSimpleClientset(tc.localStepActions...)
fn := resources.GetStepActionFunc(tektonclient, nil, nil, tc.taskRun, &tc.taskRun.Spec.TaskSpec.Steps[0])

stepAction, refSource, err := fn(ctx, tc.taskRun.Spec.TaskSpec.Steps[0].Ref)
stepAction, refSource, err := fn(ctx, tc.taskRun.Spec.TaskSpec.Steps[0].Ref.Name)
if err != nil {
t.Fatalf("failed to call stepActionfn: %s", err.Error())
}
Expand Down Expand Up @@ -644,7 +644,7 @@ func TestGetStepActionFunc_RemoteResolution(t *testing.T) {
tektonclient := fake.NewSimpleClientset()
fn := resources.GetStepActionFunc(tektonclient, nil, requester, tr, &tr.Spec.TaskSpec.Steps[0])

resolvedStepAction, resolvedRefSource, err := fn(ctx, tr.Spec.TaskSpec.Steps[0].Ref)
resolvedStepAction, resolvedRefSource, err := fn(ctx, tr.Spec.TaskSpec.Steps[0].Ref.Name)
if tc.wantErr {
if err == nil {
t.Fatalf("expected an error when calling GetStepActionFunc but got none")
Expand Down Expand Up @@ -703,7 +703,7 @@ func TestGetStepActionFunc_RemoteResolutionInvalidData(t *testing.T) {
}
tektonclient := fake.NewSimpleClientset()
fn := resources.GetStepActionFunc(tektonclient, nil, requester, tr, &tr.Spec.TaskSpec.Steps[0])
if _, _, err := fn(ctx, tr.Spec.TaskSpec.Steps[0].Ref); err == nil {
if _, _, err := fn(ctx, tr.Spec.TaskSpec.Steps[0].Ref.Name); err == nil {
t.Fatalf("expected error due to invalid pipeline data but saw none")
}
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/taskrun/resources/taskspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type ResolvedTask struct {
}

// GetStepAction is a function used to retrieve StepActions.
type GetStepAction func(context.Context, *v1.Ref) (*v1alpha1.StepAction, *v1.RefSource, error)
type GetStepAction func(context.Context, string) (*v1alpha1.StepAction, *v1.RefSource, error)

// GetTask is a function used to retrieve Tasks.
// VerificationResult is the result from trusted resources if the feature is enabled.
Expand Down Expand Up @@ -108,7 +108,7 @@ func GetStepActionsData(ctx context.Context, taskSpec v1.TaskSpec, taskRun *v1.T
if step.Ref != nil {
s.Ref = nil
getStepAction := GetStepActionFunc(tekton, k8s, requester, taskRun, &step)
stepAction, _, err := getStepAction(ctx, step.Ref)
stepAction, _, err := getStepAction(ctx, step.Ref.Name)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2fe69be

Please sign in to comment.