Skip to content

Commit

Permalink
chore: cleanup unused functions in the pipelineRun ceconciler resources
Browse files Browse the repository at this point in the history
These functions are no longer needed after the previous refactoring,
so they can be cleaned up.
  • Loading branch information
l-qing committed Mar 31, 2023
1 parent b51f08c commit 60de20d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 371 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/resources/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func replaceParamValues(params v1beta1.Params, stringReplacements map[string]str
// and omitted from the returned slice. A nil slice is returned if no results are passed in or all
// results are invalid.
func ApplyTaskResultsToPipelineResults(
ctx context.Context,
_ context.Context,
results []v1beta1.PipelineResult,
taskRunResults map[string][]v1beta1.TaskRunResult,
customTaskResults map[string][]v1beta1.CustomRunResult,
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/resources/pipelineref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func TestGetPipelineFunc(t *testing.T) {
Name: "simple",
Bundle: u.Host + "/remote-pipeline-without-defaults",
},
expected: simplePipelineWithSpecParamAndKind(v1beta1.ParamTypeString, v1beta1.NamespacedTaskKind),
expected: simplePipelineWithSpecParamAndKind(),
}}

for _, tc := range testcases {
Expand Down Expand Up @@ -886,7 +886,7 @@ func simplePipelineWithSpecAndParam(pt v1beta1.ParamType) *v1beta1.Pipeline {
return p
}

func simplePipelineWithSpecParamAndKind(pt v1beta1.ParamType, tk v1beta1.TaskKind) *v1beta1.Pipeline {
func simplePipelineWithSpecParamAndKind() *v1beta1.Pipeline {
p := simplePipelineWithBaseSpec()
p.Spec.Params = []v1beta1.ParamSpec{{
Name: "foo",
Expand Down
8 changes: 2 additions & 6 deletions pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,7 @@ func (t *ResolvedPipelineTask) resolvePipelineRunTaskWithTaskRun(
}
}

if err := t.resolveTaskResources(ctx, getTask, pipelineTask, taskRun); err != nil {
return err
}

return nil
return t.resolveTaskResources(ctx, getTask, pipelineTask, taskRun)
}

func (t *ResolvedPipelineTask) resolveTaskResources(
Expand Down Expand Up @@ -812,7 +808,7 @@ func getRunNamesFromChildRefs(childRefs []v1beta1.ChildStatusReference, ptName s

// resolvePipelineTaskResources matches PipelineResources referenced by pt inputs and outputs with the
// providedResources and returns an instance of ResolvedTask.
func resolvePipelineTaskResources(pt v1beta1.PipelineTask, ts *v1beta1.TaskSpec, taskName string, kind v1beta1.TaskKind) (*resources.ResolvedTask, error) {
func resolvePipelineTaskResources(_ v1beta1.PipelineTask, ts *v1beta1.TaskSpec, taskName string, kind v1beta1.TaskKind) (*resources.ResolvedTask, error) {
rtr := resources.ResolvedTask{
TaskName: taskName,
TaskSpec: ts,
Expand Down
23 changes: 0 additions & 23 deletions pkg/reconciler/pipelinerun/resources/resultrefresolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,6 @@ func validateArrayResultsIndex(allResolvedResultRefs ResolvedResultRefs) (Resolv
return allResolvedResultRefs, "", nil
}

// extractResultRefs resolves any ResultReference that are found in param or pipeline result
// Returns nil if none are found
func extractResultRefsForParam(pipelineRunState PipelineRunState, param v1beta1.Param) (ResolvedResultRefs, error) {
expressions, ok := v1beta1.GetVarSubstitutionExpressionsForParam(param)
if ok {
return extractResultRefs(expressions, pipelineRunState)
}
return nil, nil
}

func extractResultRefs(expressions []string, pipelineRunState PipelineRunState) (ResolvedResultRefs, error) {
resultRefs := v1beta1.NewResultRefs(expressions)
var resolvedResultRefs ResolvedResultRefs
for _, resultRef := range resultRefs {
resolvedResultRef, _, err := resolveResultRef(pipelineRunState, resultRef)
if err != nil {
return nil, err
}
resolvedResultRefs = append(resolvedResultRefs, resolvedResultRef)
}
return removeDup(resolvedResultRefs), nil
}

func removeDup(refs ResolvedResultRefs) ResolvedResultRefs {
if refs == nil {
return nil
Expand Down
Loading

0 comments on commit 60de20d

Please sign in to comment.