Skip to content

Commit

Permalink
ResolvePipelineRunTask to ResolvePipelineTask 🧹
Browse files Browse the repository at this point in the history
In #5025, we renamed
ResolvedPipelineRunTask to ResolvedPipelineTask. In this change,
we rename the function that creates it to align with the new
type name.
  • Loading branch information
jerop authored and tekton-robot committed Jun 23, 2022
1 parent 3fd7138 commit 3aab18c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (c *Reconciler) resolvePipelineState(
return nil, controller.NewPermanentError(err)
}

resolvedTask, err := resources.ResolvePipelineRunTask(ctx,
resolvedTask, err := resources.ResolvePipelineTask(ctx,
*pr,
fn,
func(name string) (*v1beta1.TaskRun, error) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ func isCustomTask(ctx context.Context, rpt ResolvedPipelineTask) bool {
return cfg.FeatureFlags.EnableCustomTasks && !invalidSpec && (isTaskRefCustomTask || isTaskSpecCustomTask)
}

// ResolvePipelineRunTask retrieves a single Task's instance using the getTask to fetch
// ResolvePipelineTask retrieves a single Task's instance using the getTask to fetch
// the spec. If it is unable to retrieve an instance of a referenced Task, it will return
// an error, otherwise it returns a list of all the Tasks retrieved. It will retrieve
// the Resources needed for the TaskRun using the mapping of providedResources.
func ResolvePipelineRunTask(
// the Resources needed for the TaskRuns or Runs using the mapping of providedResources.
func ResolvePipelineTask(
ctx context.Context,
pipelineRun v1beta1.PipelineRun,
getTask resources.GetTask,
Expand Down
26 changes: 13 additions & 13 deletions pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ func TestResolvePipelineRun(t *testing.T) {

pipelineState := PipelineRunState{}
for _, task := range p.Spec.Tasks {
ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, task, providedResources)
ps, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, task, providedResources)
if err != nil {
t.Fatalf("Error getting tasks for fake pipeline %s: %s", p.ObjectMeta.Name, err)
}
Expand Down Expand Up @@ -1659,9 +1659,9 @@ func TestResolvePipelineRun_CustomTask(t *testing.T) {
})
ctx = cfg.ToContext(ctx)
for _, task := range pts {
ps, err := ResolvePipelineRunTask(ctx, pr, nopGetTask, nopGetTaskRun, getRun, task, nil)
ps, err := ResolvePipelineTask(ctx, pr, nopGetTask, nopGetTaskRun, getRun, task, nil)
if err != nil {
t.Fatalf("ResolvePipelineRunTask: %v", err)
t.Fatalf("ResolvePipelineTask: %v", err)
}
pipelineState = append(pipelineState, ps)
}
Expand Down Expand Up @@ -1709,7 +1709,7 @@ func TestResolvePipelineRun_PipelineTaskHasNoResources(t *testing.T) {
}
pipelineState := PipelineRunState{}
for _, task := range pts {
ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, task, providedResources)
ps, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, task, providedResources)
if err != nil {
t.Errorf("Error getting tasks for fake pipeline %s: %s", p.ObjectMeta.Name, err)
}
Expand Down Expand Up @@ -1762,7 +1762,7 @@ func TestResolvePipelineRun_TaskDoesntExist(t *testing.T) {
},
}
for _, pt := range pts {
_, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, pt, providedResources)
_, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, pt, providedResources)
switch err := err.(type) {
case nil:
t.Fatalf("Expected error getting non-existent Tasks for Pipeline %s but got none", p.Name)
Expand Down Expand Up @@ -1830,7 +1830,7 @@ func TestResolvePipelineRun_ResourceBindingsDontExist(t *testing.T) {
},
}
pipelineState := PipelineRunState{}
ps, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, tt.p.Spec.Tasks[0], providedResources)
ps, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, tt.p.Spec.Tasks[0], providedResources)
if err == nil {
t.Fatalf("Expected error when bindings are in incorrect state for Pipeline %s but got none: %s", p.ObjectMeta.Name, err)
}
Expand Down Expand Up @@ -1891,7 +1891,7 @@ func TestResolvePipelineRun_withExistingTaskRuns(t *testing.T) {
// that is not done as part of Run resolution
getTask := func(_ context.Context, name string) (v1beta1.TaskObject, error) { return task, nil }
getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil }
resolvedTask, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, p.Spec.Tasks[0], providedResources)
resolvedTask, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, p.Spec.Tasks[0], providedResources)
if err != nil {
t.Fatalf("Error getting tasks for fake pipeline %s: %s", p.ObjectMeta.Name, err)
}
Expand Down Expand Up @@ -1958,7 +1958,7 @@ func TestResolvedPipelineRun_PipelineTaskHasOptionalResources(t *testing.T) {
}
getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil }

actualTask, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, p.Spec.Tasks[0], providedResources)
actualTask, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, p.Spec.Tasks[0], providedResources)
if err != nil {
t.Fatalf("Error getting tasks for fake pipeline %s: %s", p.ObjectMeta.Name, err)
}
Expand Down Expand Up @@ -2310,7 +2310,7 @@ func TestResolvePipeline_WhenExpressions(t *testing.T) {
}

t.Run("When Expressions exist", func(t *testing.T) {
_, err := ResolvePipelineRunTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, pt, providedResources)
_, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, pt, providedResources)
if err != nil {
t.Fatalf("Did not expect error when resolving PipelineRun: %v", err)
}
Expand Down Expand Up @@ -2431,7 +2431,7 @@ func TestIsCustomTask(t *testing.T) {
},
})
ctx = cfg.ToContext(ctx)
rpt, err := ResolvePipelineRunTask(ctx, pr, getTask, getTaskRun, getRun, tc.pt, nil)
rpt, err := ResolvePipelineTask(ctx, pr, getTask, getTaskRun, getRun, tc.pt, nil)
if err != nil {
t.Fatalf("Did not expect error when resolving PipelineRun: %v", err)
}
Expand Down Expand Up @@ -3035,7 +3035,7 @@ func TestIsMatrixed(t *testing.T) {
},
})
ctx = cfg.ToContext(ctx)
rpt, err := ResolvePipelineRunTask(ctx, pr, getTask, getTaskRun, getRun, tc.pt, nil)
rpt, err := ResolvePipelineTask(ctx, pr, getTask, getTaskRun, getRun, tc.pt, nil)
if err != nil {
t.Fatalf("Did not expect error when resolving PipelineRun: %v", err)
}
Expand Down Expand Up @@ -3141,12 +3141,12 @@ func TestResolvePipelineRunTask_WithMatrix(t *testing.T) {
},
})
ctx = cfg.ToContext(ctx)
rpt, err := ResolvePipelineRunTask(ctx, pr, getTask, getTaskRun, getRun, tc.pt, nil)
rpt, err := ResolvePipelineTask(ctx, pr, getTask, getTaskRun, getRun, tc.pt, nil)
if err != nil {
t.Fatalf("Did not expect error when resolving PipelineRun: %v", err)
}
if d := cmp.Diff(tc.want, rpt); d != "" {
t.Errorf("Did not get expected ResolvePipelineRunTask with Matrix: %s", diff.PrintWantGot(d))
t.Errorf("Did not get expected ResolvePipelineTask with Matrix: %s", diff.PrintWantGot(d))
}
})
}
Expand Down

0 comments on commit 3aab18c

Please sign in to comment.