Skip to content
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

chore: cleanup unused functions in the resources #6473

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
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) {
Copy link
Contributor Author

@l-qing l-qing Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two functions are currently not being used except for unit testing, so they can be cleaned up.

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