From ee3c22c6384bd1374de19de6a724ea101ea4e44f Mon Sep 17 00:00:00 2001 From: Lee Bernick Date: Wed, 24 May 2023 17:02:42 -0400 Subject: [PATCH] Cleanup: Use CustomRun instead of RunObject v1alpha1 Runs are no longer supported by the PipelineRun reconciler. The PipelineRun reconciler currently operates on RunObjects (an interface which is implemented by v1alpha1.Run and v1beta1.CustomRun). However, this code is misleading, since retry behavior differs between v1alpha1.Run and v1beta1.CustomRun, but the controller only supports the behavior of v1beta1.CustomRuns. This commit replaces usages of RunObject with CustomRun, and renames references to runs/runObjects to customRuns for clarity. No functional changes. --- pkg/reconciler/pipelinerun/pipelinerun.go | 77 ++-- .../pipelinerun_updatestatus_test.go | 40 +- .../resources/pipelinerunresolution.go | 83 ++-- .../resources/pipelinerunresolution_test.go | 356 +++++++++--------- .../pipelinerun/resources/pipelinerunstate.go | 26 +- .../resources/pipelinerunstate_test.go | 154 ++++---- .../resources/resultrefresolution.go | 13 +- .../resources/resultrefresolution_test.go | 14 +- .../resources/validate_dependencies_test.go | 2 +- test/custom_task_test.go | 54 ++- 10 files changed, 401 insertions(+), 418 deletions(-) diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 38b2427a3d1..406b04ae21e 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -333,16 +333,11 @@ func (c *Reconciler) resolvePipelineState( } fn := tresources.GetTaskFunc(ctx, c.KubeClientSet, c.PipelineClientSet, c.resolutionRequester, pr, task.TaskRef, trName, pr.Namespace, pr.Spec.ServiceAccountName, vp) - getRunObjectFunc := func(name string) (v1beta1.RunObject, error) { + getCustomRunFunc := func(name string) (*v1beta1.CustomRun, error) { r, err := c.customRunLister.CustomRuns(pr.Namespace).Get(name) if err != nil { return nil, err } - // If we just return c.customRunLister.CustomRuns(...).Get(...) and there is no run, we end up returning - // a v1beta1.RunObject that won't == nil, so do an explicit check. - if r == nil { - return nil, nil - } return r, nil } @@ -352,7 +347,7 @@ func (c *Reconciler) resolvePipelineState( func(name string) (*v1beta1.TaskRun, error) { return c.taskRunLister.TaskRuns(pr.Namespace).Get(name) }, - getRunObjectFunc, + getCustomRunFunc, task, ) if err != nil { @@ -778,10 +773,10 @@ func (c *Reconciler) runNextSchedulableTask(ctx context.Context, pr *v1beta1.Pip }() if rpt.IsCustomTask() { - rpt.RunObjects, err = c.createRunObjects(ctx, rpt, pr) + rpt.CustomRuns, err = c.createCustomRuns(ctx, rpt, pr) if err != nil { - recorder.Eventf(pr, corev1.EventTypeWarning, "RunsCreationFailed", "Failed to create Runs %q: %v", rpt.RunObjectNames, err) - err = fmt.Errorf("error creating Runs called %s for PipelineTask %s from PipelineRun %s: %w", rpt.RunObjectNames, rpt.PipelineTask.Name, pr.Name, err) + recorder.Eventf(pr, corev1.EventTypeWarning, "RunsCreationFailed", "Failed to create CustomRuns %q: %v", rpt.CustomRunNames, err) + err = fmt.Errorf("error creating CustomRuns called %s for PipelineTask %s from PipelineRun %s: %w", rpt.CustomRunNames, rpt.PipelineTask.Name, pr.Name, err) return err } } else { @@ -887,9 +882,9 @@ func (c *Reconciler) createTaskRun(ctx context.Context, taskRunName string, para return c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).Create(ctx, tr, metav1.CreateOptions{}) } -func (c *Reconciler) createRunObjects(ctx context.Context, rpt *resources.ResolvedPipelineTask, pr *v1beta1.PipelineRun) ([]v1beta1.RunObject, error) { - var runObjects []v1beta1.RunObject - ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createRunObjects") +func (c *Reconciler) createCustomRuns(ctx context.Context, rpt *resources.ResolvedPipelineTask, pr *v1beta1.PipelineRun) ([]*v1beta1.CustomRun, error) { + var customRuns []*v1beta1.CustomRun + ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createCustomRuns") defer span.End() var matrixCombinations []v1beta1.Params @@ -897,22 +892,22 @@ func (c *Reconciler) createRunObjects(ctx context.Context, rpt *resources.Resolv matrixCombinations = rpt.PipelineTask.Matrix.FanOut() } - for i, runObjectName := range rpt.RunObjectNames { + for i, customRunName := range rpt.CustomRunNames { var params v1beta1.Params if len(matrixCombinations) > i { params = matrixCombinations[i] } - runObject, err := c.createRunObject(ctx, runObjectName, params, rpt, pr) + customRun, err := c.createCustomRun(ctx, customRunName, params, rpt, pr) if err != nil { return nil, err } - runObjects = append(runObjects, runObject) + customRuns = append(customRuns, customRun) } - return runObjects, nil + return customRuns, nil } -func (c *Reconciler) createRunObject(ctx context.Context, runName string, params v1beta1.Params, rpt *resources.ResolvedPipelineTask, pr *v1beta1.PipelineRun) (v1beta1.RunObject, error) { - ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createRunObject") +func (c *Reconciler) createCustomRun(ctx context.Context, runName string, params v1beta1.Params, rpt *resources.ResolvedPipelineTask, pr *v1beta1.PipelineRun) (*v1beta1.CustomRun, error) { + ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createCustomRun") defer span.End() logger := logging.FromContext(ctx) rpt.PipelineTask = resources.ApplyPipelineTaskContexts(rpt.PipelineTask) @@ -1269,22 +1264,17 @@ func (c *Reconciler) updatePipelineRunStatusFromInformer(ctx context.Context, pr logger.Errorf("could not list TaskRuns %#v", err) return err } - var runObjects []v1beta1.RunObject customRuns, err := c.customRunLister.CustomRuns(pr.Namespace).List(k8slabels.SelectorFromSet(pipelineRunLabels)) if err != nil { logger.Errorf("could not list CustomRuns %#v", err) return err } - for _, cr := range customRuns { - runObjects = append(runObjects, cr) - } - - return updatePipelineRunStatusFromChildObjects(ctx, logger, pr, taskRuns, runObjects) + return updatePipelineRunStatusFromChildObjects(ctx, logger, pr, taskRuns, customRuns) } -func updatePipelineRunStatusFromChildObjects(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, taskRuns []*v1beta1.TaskRun, runObjects []v1beta1.RunObject) error { - updatePipelineRunStatusFromChildRefs(logger, pr, taskRuns, runObjects) +func updatePipelineRunStatusFromChildObjects(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, taskRuns []*v1beta1.TaskRun, customRuns []*v1beta1.CustomRun) error { + updatePipelineRunStatusFromChildRefs(logger, pr, taskRuns, customRuns) return validateChildObjectsInPipelineRunStatus(ctx, pr.Status) } @@ -1321,38 +1311,37 @@ func filterTaskRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1beta1.P return ownedTaskRuns } -// filterRunsForPipelineRunStatus filters the given slice of run objects, returning information only those owned by the given PipelineRun. -func filterRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, runObjects []v1beta1.RunObject) ([]string, []string, []schema.GroupVersionKind, []*v1beta1.CustomRunStatus) { +// filterCustomRunsForPipelineRunStatus filters the given slice of customRuns, returning information only those owned by the given PipelineRun. +func filterCustomRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, customRuns []*v1beta1.CustomRun) ([]string, []string, []schema.GroupVersionKind, []*v1beta1.CustomRunStatus) { var names []string var taskLabels []string var gvks []schema.GroupVersionKind var statuses []*v1beta1.CustomRunStatus - // Loop over all the run objects associated to Tasks - for _, runObj := range runObjects { - // Only process run objects that are owned by this PipelineRun. - // This skips Runs that are indirectly created by the PipelineRun (e.g. by custom tasks). - if len(runObj.GetObjectMeta().GetOwnerReferences()) < 1 || runObj.GetObjectMeta().GetOwnerReferences()[0].UID != pr.ObjectMeta.UID { - logger.Debugf("Found a %s %s that is not owned by this PipelineRun", runObj.GetObjectKind().GroupVersionKind().Kind, runObj.GetObjectMeta().GetName()) + // Loop over all the customRuns associated to Tasks + for _, cr := range customRuns { + // Only process customRuns that are owned by this PipelineRun. + // This skips customRuns that are indirectly created by the PipelineRun (e.g. by custom tasks). + if len(cr.GetObjectMeta().GetOwnerReferences()) < 1 || cr.GetObjectMeta().GetOwnerReferences()[0].UID != pr.ObjectMeta.UID { + logger.Debugf("Found a %s %s that is not owned by this PipelineRun", cr.GetObjectKind().GroupVersionKind().Kind, cr.GetObjectMeta().GetName()) continue } - names = append(names, runObj.GetObjectMeta().GetName()) - taskLabels = append(taskLabels, runObj.GetObjectMeta().GetLabels()[pipeline.PipelineTaskLabelKey]) + names = append(names, cr.GetObjectMeta().GetName()) + taskLabels = append(taskLabels, cr.GetObjectMeta().GetLabels()[pipeline.PipelineTaskLabelKey]) - r := runObj.(*v1beta1.CustomRun) - statuses = append(statuses, &r.Status) - // We can't just get the gvk from the run's TypeMeta because that isn't populated for resources created through the fake client. + statuses = append(statuses, &cr.Status) + // We can't just get the gvk from the customRun's TypeMeta because that isn't populated for resources created through the fake client. gvks = append(gvks, v1beta1.SchemeGroupVersion.WithKind(customRun)) } return names, taskLabels, gvks, statuses } -func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun, runObjects []v1beta1.RunObject) { - // If no TaskRun or RunObject was found, nothing to be done. We never remove child references from the status. +func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun, customRuns []*v1beta1.CustomRun) { + // If no TaskRun or CustomRun was found, nothing to be done. We never remove child references from the status. // We do still return an empty map of TaskRun/Run names keyed by PipelineTask name for later functions. - if len(trs) == 0 && len(runObjects) == 0 { + if len(trs) == 0 && len(customRuns) == 0 { return } @@ -1388,7 +1377,7 @@ func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1 } // Get the names, their task label values, and their group/version/kind info for all CustomRuns or Runs associated with the PipelineRun - names, taskLabels, gvks, _ := filterRunsForPipelineRunStatus(logger, pr, runObjects) + names, taskLabels, gvks, _ := filterCustomRunsForPipelineRunStatus(logger, pr, customRuns) // Loop over that data and populate the child references for idx := range names { diff --git a/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go b/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go index 0a4196d1e2c..202540ed7d4 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go @@ -299,9 +299,9 @@ func TestUpdatePipelineRunStatusFromChildRefs(t *testing.T) { }, } - allTaskRuns, taskRunsFromAnotherPR, taskRunsWithNoOwner, _, runsFromAnotherPR, runsWithNoOwner := getTestTaskRunsAndRuns(t) + allTaskRuns, taskRunsFromAnotherPR, taskRunsWithNoOwner, _, runsFromAnotherPR, runsWithNoOwner := getTestTaskRunsAndCustomRuns(t) - singleRun := []v1beta1.RunObject{parse.MustParseCustomRun(t, ` + singleRun := []*v1beta1.CustomRun{parse.MustParseCustomRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-6 @@ -314,20 +314,20 @@ metadata: prName string prStatus v1beta1.PipelineRunStatus trs []*v1beta1.TaskRun - runs []v1beta1.RunObject + customRuns []*v1beta1.CustomRun expectedPrStatus v1beta1.PipelineRunStatus }{ { prName: "no-status-no-taskruns-or-runs", prStatus: v1beta1.PipelineRunStatus{}, trs: nil, - runs: nil, + customRuns: nil, expectedPrStatus: v1beta1.PipelineRunStatus{}, }, { prName: "status-no-taskruns-or-runs", prStatus: prStatusWithNoTaskRuns, trs: nil, - runs: nil, + customRuns: nil, expectedPrStatus: prStatusWithNoTaskRuns, }, { prName: "status-nil-taskruns", @@ -344,7 +344,7 @@ metadata: }, { prName: "status-nil-runs", prStatus: prStatusWithEmptyChildRefs, - runs: singleRun, + customRuns: singleRun, expectedPrStatus: prStatusRecoveredSimpleWithRun, }, { prName: "status-missing-taskruns", @@ -363,7 +363,7 @@ metadata: }, { prName: "status-missing-runs", prStatus: prStatusMissingRun, - runs: singleRun, + customRuns: singleRun, expectedPrStatus: prStatusWithNoTaskRuns, }, { prName: "status-matching-taskruns-pr", @@ -374,19 +374,19 @@ metadata: prName: "orphaned-taskruns-pr", prStatus: prStatusWithOrphans, trs: allTaskRuns, - runs: singleRun, + customRuns: singleRun, expectedPrStatus: prStatusRecovered, }, { prName: "tr-and-run-from-another-pr", prStatus: prStatusWithEmptyChildRefs, trs: taskRunsFromAnotherPR, - runs: runsFromAnotherPR, + customRuns: runsFromAnotherPR, expectedPrStatus: prStatusWithEmptyChildRefs, }, { prName: "tr-and-run-with-no-owner", prStatus: prStatusWithEmptyChildRefs, trs: taskRunsWithNoOwner, - runs: runsWithNoOwner, + customRuns: runsWithNoOwner, expectedPrStatus: prStatusWithEmptyChildRefs, }, { prName: "matrixed-taskruns-pr", @@ -409,7 +409,7 @@ metadata: - uid: 11111111-1111-1111-1111-111111111111 `), }, - runs: nil, + customRuns: nil, expectedPrStatus: v1beta1.PipelineRunStatus{ Status: prRunningStatus, PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ @@ -441,7 +441,7 @@ pipelineTaskName: task Status: tc.prStatus, } - updatePipelineRunStatusFromChildRefs(logger, pr, tc.trs, tc.runs) + updatePipelineRunStatusFromChildRefs(logger, pr, tc.trs, tc.customRuns) actualPrStatus := pr.Status @@ -501,9 +501,9 @@ func TestUpdatePipelineRunStatusFromChildObjects(t *testing.T) { } } - allTaskRuns, _, _, _, _, _ := getTestTaskRunsAndRuns(t) + allTaskRuns, _, _, _, _, _ := getTestTaskRunsAndCustomRuns(t) - singleCustomRun := []v1beta1.RunObject{parse.MustParseCustomRun(t, ` + singleCustomRun := []*v1beta1.CustomRun{parse.MustParseCustomRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-6 @@ -516,7 +516,7 @@ metadata: prName string prStatus func() v1beta1.PipelineRunStatus trs []*v1beta1.TaskRun - runs []v1beta1.RunObject + runs []*v1beta1.CustomRun expectedStatusTRs map[string]*v1beta1.PipelineRunTaskRunStatus expectedStatusRuns map[string]*v1beta1.PipelineRunRunStatus expectedStatusCRs []v1beta1.ChildStatusReference @@ -698,7 +698,7 @@ func prStatusFromInputs(status duckv1.Status, taskRuns map[string]*v1beta1.Pipel return prs } -func getTestTaskRunsAndRuns(t *testing.T) ([]*v1beta1.TaskRun, []*v1beta1.TaskRun, []*v1beta1.TaskRun, []v1beta1.RunObject, []v1beta1.RunObject, []v1beta1.RunObject) { +func getTestTaskRunsAndCustomRuns(t *testing.T) ([]*v1beta1.TaskRun, []*v1beta1.TaskRun, []*v1beta1.TaskRun, []*v1beta1.CustomRun, []*v1beta1.CustomRun, []*v1beta1.CustomRun) { t.Helper() allTaskRuns := []*v1beta1.TaskRun{ parse.MustParseV1beta1TaskRun(t, ` @@ -735,7 +735,7 @@ metadata: name: pr-task-1-xxyyy `)} - allRuns := []v1beta1.RunObject{ + allCustomRuns := []*v1beta1.CustomRun{ parse.MustParseCustomRun(t, ` metadata: labels: @@ -762,7 +762,7 @@ metadata: `), } - runsFromAnotherPR := []v1beta1.RunObject{parse.MustParseCustomRun(t, ` + customRunsFromAnotherPR := []*v1beta1.CustomRun{parse.MustParseCustomRun(t, ` metadata: labels: tekton.dev/pipelineTask: run-1 @@ -771,14 +771,14 @@ metadata: - uid: 22222222-2222-2222-2222-222222222222 `)} - runsWithNoOwner := []v1beta1.RunObject{parse.MustParseCustomRun(t, ` + customRunsWithNoOwner := []*v1beta1.CustomRun{parse.MustParseCustomRun(t, ` metadata: labels: tekton.dev/pipelineTask: run-1 name: pr-run-1-xxyyy `)} - return allTaskRuns, taskRunsFromAnotherPR, taskRunsWithNoOwner, allRuns, runsFromAnotherPR, runsWithNoOwner + return allTaskRuns, taskRunsFromAnotherPR, taskRunsWithNoOwner, allCustomRuns, customRunsFromAnotherPR, customRunsWithNoOwner } func mustParsePipelineRunTaskRunStatus(t *testing.T, yamlStr string) *v1beta1.PipelineRunTaskRunStatus { diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go index 60bf1e276ea..7c5827daa27 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go @@ -53,14 +53,14 @@ func (e *TaskNotFoundError) Error() string { return fmt.Sprintf("Couldn't retrieve Task %q: %s", e.Name, e.Msg) } -// ResolvedPipelineTask contains a PipelineTask and its associated TaskRun(s) or RunObjects, if they exist. +// ResolvedPipelineTask contains a PipelineTask and its associated TaskRun(s) or CustomRuns, if they exist. type ResolvedPipelineTask struct { TaskRunNames []string TaskRuns []*v1beta1.TaskRun - // If the PipelineTask is a Custom Task, RunObjectName and RunObject will be set. + // If the PipelineTask is a Custom Task, CustomRunName and CustomRun will be set. CustomTask bool - RunObjectNames []string - RunObjects []v1beta1.RunObject + CustomRunNames []string + CustomRuns []*v1beta1.CustomRun PipelineTask *v1beta1.PipelineTask ResolvedTask *resources.ResolvedTask } @@ -72,7 +72,7 @@ func (t ResolvedPipelineTask) isDone(facts *PipelineRunFacts) bool { // IsRunning returns true only if the task is neither succeeded, cancelled nor failed func (t ResolvedPipelineTask) IsRunning() bool { - if t.IsCustomTask() && len(t.RunObjects) == 0 { + if t.IsCustomTask() && len(t.CustomRuns) == 0 { return false } if !t.IsCustomTask() && len(t.TaskRuns) == 0 { @@ -90,10 +90,10 @@ func (t ResolvedPipelineTask) IsCustomTask() bool { // If the PipelineTask has a Matrix, isSuccessful returns true if all runs have completed successfully func (t ResolvedPipelineTask) isSuccessful() bool { if t.IsCustomTask() { - if len(t.RunObjects) == 0 { + if len(t.CustomRuns) == 0 { return false } - for _, run := range t.RunObjects { + for _, run := range t.CustomRuns { if !run.IsSuccessful() { return false } @@ -126,12 +126,12 @@ func (t ResolvedPipelineTask) isFailure() bool { } var isDone bool if t.IsCustomTask() { - if len(t.RunObjects) == 0 { + if len(t.CustomRuns) == 0 { return false } isDone = true atLeastOneFailed := false - for _, run := range t.RunObjects { + for _, run := range t.CustomRuns { isDone = isDone && run.IsDone() runFailed := run.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsFalse() atLeastOneFailed = atLeastOneFailed || runFailed @@ -155,12 +155,12 @@ func (t ResolvedPipelineTask) isFailure() bool { // If the PipelineTask has a Matrix, isCancelled returns true if any run is cancelled due to PipelineRun-controlled timeout and all other runs are done. func (t ResolvedPipelineTask) isCancelledForTimeOut() bool { if t.IsCustomTask() { - if len(t.RunObjects) == 0 { + if len(t.CustomRuns) == 0 { return false } isDone := true atLeastOneCancelled := false - for _, run := range t.RunObjects { + for _, run := range t.CustomRuns { isDone = isDone && run.IsDone() c := run.GetStatusCondition().GetCondition(apis.ConditionSucceeded) runCancelled := c.IsFalse() && @@ -190,12 +190,12 @@ func (t ResolvedPipelineTask) isCancelledForTimeOut() bool { // If the PipelineTask has a Matrix, isCancelled returns true if any run is cancelled and all other runs are done. func (t ResolvedPipelineTask) isCancelled() bool { if t.IsCustomTask() { - if len(t.RunObjects) == 0 { + if len(t.CustomRuns) == 0 { return false } isDone := true atLeastOneCancelled := false - for _, run := range t.RunObjects { + for _, run := range t.CustomRuns { isDone = isDone && run.IsDone() c := run.GetStatusCondition().GetCondition(apis.ConditionSucceeded) runCancelled := c.IsFalse() && c.Reason == v1beta1.CustomRunReasonCancelled.String() @@ -221,7 +221,7 @@ func (t ResolvedPipelineTask) isCancelled() bool { // or a singular TaskRun/CustomRun associated. func (t ResolvedPipelineTask) isScheduled() bool { if t.IsCustomTask() { - return len(t.RunObjects) > 0 + return len(t.CustomRuns) > 0 } return len(t.TaskRuns) > 0 } @@ -236,10 +236,10 @@ func (t ResolvedPipelineTask) hasTaskRunsStarted() bool { return false } -// hasRunObjectsStarted returns true only if any RunObject that has a Succeeded-type condition. -func (t ResolvedPipelineTask) hasRunObjectsStarted() bool { - for _, runObject := range t.RunObjects { - if runObject.GetStatusCondition().GetCondition(apis.ConditionSucceeded) != nil { +// hasCustomRunsStarted returns true only if any CustomRun that has a Succeeded-type condition. +func (t ResolvedPipelineTask) hasCustomRunsStarted() bool { + for _, CustomRun := range t.CustomRuns { + if CustomRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded) != nil { return true } } @@ -250,7 +250,7 @@ func (t ResolvedPipelineTask) hasRunObjectsStarted() bool { // it includes task failed after retries are exhausted, cancelled tasks, and time outs func (t ResolvedPipelineTask) isConditionStatusFalse() bool { if t.IsCustomTask() { - return t.areRunObjectsConditionStatusFalse() + return t.areCustomRunsConditionStatusFalse() } return t.areTaskRunsConditionStatusFalse() } @@ -268,12 +268,12 @@ func (t ResolvedPipelineTask) areTaskRunsConditionStatusFalse() bool { return false } -// areRunObjectsConditionStatusFalse returns true when a RunObject has succeeded condition with status set to false +// areCustomRunsConditionStatusFalse returns true when a CustomRun has succeeded condition with status set to false // it includes task failed after retries are exhausted, cancelled tasks, and time outs -func (t ResolvedPipelineTask) areRunObjectsConditionStatusFalse() bool { - if t.hasRunObjectsStarted() { - for _, runObject := range t.RunObjects { - if runObject.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsFalse() { +func (t ResolvedPipelineTask) areCustomRunsConditionStatusFalse() bool { + if t.hasCustomRunsStarted() { + for _, CustomRun := range t.CustomRuns { + if CustomRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsFalse() { return true } } @@ -485,8 +485,8 @@ func (t *ResolvedPipelineTask) IsFinallySkipped(facts *PipelineRunFacts) TaskSki } } -// GetRun is a function that will retrieve a Run by name. -type GetRun func(name string) (v1beta1.RunObject, error) +// GetRun is a function that will retrieve a CustomRun by name. +type GetRun func(name string) (*v1beta1.CustomRun, error) // ValidateWorkspaceBindings validates that the Workspaces expected by a Pipeline are provided by a PipelineRun. func ValidateWorkspaceBindings(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) error { @@ -551,14 +551,14 @@ func ResolvePipelineTask( numCombinations = pipelineTask.Matrix.CountCombinations() } if rpt.IsCustomTask() { - rpt.RunObjectNames = getNamesOfRuns(pipelineRun.Status.ChildReferences, pipelineTask.Name, pipelineRun.Name, numCombinations) - for _, runName := range rpt.RunObjectNames { + rpt.CustomRunNames = getNamesOfCustomRuns(pipelineRun.Status.ChildReferences, pipelineTask.Name, pipelineRun.Name, numCombinations) + for _, runName := range rpt.CustomRunNames { run, err := getRun(runName) if err != nil && !kerrors.IsNotFound(err) { - return nil, fmt.Errorf("error retrieving RunObject %s: %w", runName, err) + return nil, fmt.Errorf("error retrieving CustomRun %s: %w", runName, err) } if run != nil { - rpt.RunObjects = append(rpt.RunObjects, run) + rpt.CustomRuns = append(rpt.CustomRuns, run) } } } else { @@ -657,7 +657,7 @@ func GetNamesOfTaskRuns(childRefs []v1beta1.ChildStatusReference, ptName, prName if taskRunNames := getTaskRunNamesFromChildRefs(childRefs, ptName); taskRunNames != nil { return taskRunNames } - return getNewTaskRunNames(ptName, prName, numberOfTaskRuns) + return getNewRunNames(ptName, prName, numberOfTaskRuns) } // getTaskRunNamesFromChildRefs returns the names of TaskRuns defined in childRefs that are associated with the named Pipeline Task. @@ -671,9 +671,9 @@ func getTaskRunNamesFromChildRefs(childRefs []v1beta1.ChildStatusReference, ptNa return taskRunNames } -func getNewTaskRunNames(ptName, prName string, numberOfRuns int) []string { +func getNewRunNames(ptName, prName string, numberOfRuns int) []string { var taskRunNames []string - // If it is a singular TaskRun, we only append the ptName + // If it is a singular TaskRun/CustomRun, we only append the ptName if numberOfRuns == 1 { taskRunName := kmeta.ChildName(prName, fmt.Sprintf("-%s", ptName)) return append(taskRunNames, taskRunName) @@ -686,9 +686,9 @@ func getNewTaskRunNames(ptName, prName string, numberOfRuns int) []string { return taskRunNames } -// getRunName should return a unique name for a `Run` if one has not already +// getCustomRunName should return a unique name for a `Run` if one has not already // been defined, and the existing one otherwise. -func getRunName(childRefs []v1beta1.ChildStatusReference, ptName, prName string) string { +func getCustomRunName(childRefs []v1beta1.ChildStatusReference, ptName, prName string) string { for _, cr := range childRefs { if cr.PipelineTaskName == ptName { if cr.Kind == pipeline.CustomRunControllerName { @@ -700,13 +700,13 @@ func getRunName(childRefs []v1beta1.ChildStatusReference, ptName, prName string) return kmeta.ChildName(prName, fmt.Sprintf("-%s", ptName)) } -// getNamesOfRuns should return a unique names for `RunObjects` if they have not already been defined, +// getNamesOfCustomRuns should return a unique names for `CustomRuns` if they have not already been defined, // and the existing ones otherwise. -func getNamesOfRuns(childRefs []v1beta1.ChildStatusReference, ptName, prName string, numberOfRuns int) []string { - if runNames := getRunNamesFromChildRefs(childRefs, ptName); runNames != nil { - return runNames +func getNamesOfCustomRuns(childRefs []v1beta1.ChildStatusReference, ptName, prName string, numberOfRuns int) []string { + if customRunNames := getRunNamesFromChildRefs(childRefs, ptName); customRunNames != nil { + return customRunNames } - return getNewTaskRunNames(ptName, prName, numberOfRuns) + return getNewRunNames(ptName, prName, numberOfRuns) } // getRunNamesFromChildRefs returns the names of CustomRuns defined in childRefs that are associated with the named Pipeline Task. @@ -744,7 +744,6 @@ func (t *ResolvedPipelineTask) hasResultReferences() bool { return false } -func isCustomRunCancelledByPipelineRunTimeout(ro v1beta1.RunObject) bool { - cr := ro.(*v1beta1.CustomRun) +func isCustomRunCancelledByPipelineRunTimeout(cr *v1beta1.CustomRun) bool { return cr.Spec.StatusMessage == v1beta1.CustomRunCancelledByPipelineTimeoutMsg } diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go index 3cb4ed6c1ee..a48939121a5 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go @@ -43,7 +43,7 @@ import ( logtesting "knative.dev/pkg/logging/testing" ) -func nopGetRun(string) (v1beta1.RunObject, error) { +func nopGetCustomRun(string) (*v1beta1.CustomRun, error) { return nil, errors.New("GetRun should not be called") } func nopGetTask(context.Context, string) (*v1beta1.Task, *v1beta1.RefSource, *trustedresources.VerificationResult, error) { @@ -479,49 +479,49 @@ var allFinishedState = PipelineRunState{{ var noCustomRunStartedState = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: nil, }, { PipelineTask: &pts[13], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask14"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-mytask14"}, + CustomRuns: nil, }} var oneCustomRunStartedState = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }, { PipelineTask: &pts[13], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask14"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-mytask14"}, + CustomRuns: nil, }} var oneCustomRunFinishedState = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, }, { PipelineTask: &pts[13], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask14"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-mytask14"}, + CustomRuns: nil, }} var oneCustomRunFailedState = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, { PipelineTask: &pts[13], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask14"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-mytask14"}, + CustomRuns: nil, }} var taskCancelled = PipelineRunState{{ @@ -535,8 +535,8 @@ var taskCancelled = PipelineRunState{{ var customRunCancelled = PipelineRunState{{ PipelineTask: &pts[12], - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0]))}, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0]))}, }} var noneStartedStateMatrix = PipelineRunState{{ @@ -638,37 +638,37 @@ var allFinishedStateMatrix = PipelineRunState{{ var noCustomRunStartedStateMatrix = PipelineRunState{{ PipelineTask: &pts[18], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: nil, }, { PipelineTask: &pts[19], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: nil, }} var oneCustomRunStartedStateMatrix = PipelineRunState{{ PipelineTask: &pts[18], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }, { PipelineTask: &pts[19], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask14"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-mytask14"}, + CustomRuns: nil, }} var oneCustomRunFailedStateMatrix = PipelineRunState{{ PipelineTask: &pts[18], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, { PipelineTask: &pts[19], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask14"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-mytask14"}, + CustomRuns: nil, }} var taskCancelledMatrix = PipelineRunState{{ @@ -1246,7 +1246,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }, want: false, }, { @@ -1261,7 +1261,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, }, want: false, }, { @@ -1276,7 +1276,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, want: true, }, { @@ -1284,7 +1284,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, want: true, }, { @@ -1299,7 +1299,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunRetries(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunRetries(makeCustomRunFailed(customRuns[0]))}, }, want: true, }, { @@ -1327,7 +1327,7 @@ func TestIsFailure(t *testing.T) { name: "customrun cancelled", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, CustomTask: true, }, want: true, @@ -1335,7 +1335,7 @@ func TestIsFailure(t *testing.T) { name: "customrun cancelled for timeout", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0]))}, CustomTask: true, }, want: true, @@ -1343,7 +1343,7 @@ func TestIsFailure(t *testing.T) { name: "customrun cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0]))}, CustomTask: true, }, want: false, @@ -1358,7 +1358,7 @@ func TestIsFailure(t *testing.T) { name: "customrun cancelled: retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, CustomTask: true, }, want: true, @@ -1373,7 +1373,7 @@ func TestIsFailure(t *testing.T) { name: "custom run cancelled: retried", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0])))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0])))}, CustomTask: true, }, want: true, @@ -1402,7 +1402,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -1417,7 +1417,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, }, want: false, }, { @@ -1439,7 +1439,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -1454,7 +1454,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, }, want: true, }, { @@ -1469,7 +1469,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -1484,7 +1484,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, }, want: true, }, { @@ -1499,7 +1499,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, }, want: true, }, { @@ -1507,7 +1507,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunRetries(makeCustomRunFailed(customRuns[0])), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunRetries(makeCustomRunFailed(customRuns[0])), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, }, want: true, }, { @@ -1522,7 +1522,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, }, want: true, }, { @@ -1537,7 +1537,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -1552,7 +1552,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0])), withCustomRunCancelled(newCustomRun(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0])), withCustomRunCancelled(newCustomRun(customRuns[1]))}, }, want: false, }, { @@ -1567,7 +1567,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -1582,7 +1582,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, }, want: true, }, { @@ -1597,7 +1597,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -1612,7 +1612,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[1])))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[1])))}, }, want: true, }, { @@ -1627,7 +1627,7 @@ func TestIsFailure(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), makeCustomRunStarted(customRuns[1])}, }, want: false, }} { @@ -1696,56 +1696,56 @@ func TestIsCancelled(t *testing.T) { name: "customruns not started", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{}, + CustomRuns: []*v1beta1.CustomRun{}, }, want: false, }, { name: "customrun not done", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }, want: false, }, { name: "customrun succeeded but not cancelled", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{(makeCustomRunSucceeded(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{(makeCustomRunSucceeded(customRuns[0]))}, }, want: false, }, { name: "customrun failed but not cancelled", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{(makeCustomRunFailed(customRuns[0]))}, }, want: false, }, { name: "customrun cancelled and failed", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, }, want: true, }, { name: "customrun cancelled but still running", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunStarted(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunStarted(customRuns[0]))}, }, want: false, }, { name: "one customrun cancelled, one not done", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { name: "one customrun cancelled, one done but not cancelled", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunSucceeded(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunSucceeded(customRuns[1])}, }, want: true, }} @@ -1821,63 +1821,63 @@ func TestIsCancelledForTimeout(t *testing.T) { name: "customruns not started", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{}, + CustomRuns: []*v1beta1.CustomRun{}, }, want: false, }, { name: "customrun not done", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }, want: false, }, { name: "customrun succeeded but not cancelled", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{(makeCustomRunSucceeded(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{(makeCustomRunSucceeded(customRuns[0]))}, }, want: false, }, { name: "customrun failed but not cancelled", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{(makeCustomRunFailed(customRuns[0]))}, }, want: false, }, { name: "customrun cancelled by spec and failed", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunCancelledBySpec(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelledBySpec(makeCustomRunFailed(customRuns[0]))}, }, want: false, }, { name: "customrun cancelled for timeout and failed", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0]))}, }, want: true, }, { name: "customrun cancelled for timeout but still running", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunCancelledForTimeout(makeCustomRunStarted(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelledForTimeout(makeCustomRunStarted(customRuns[0]))}, }, want: false, }, { name: "one customrun cancelled for timeout, one not done", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { name: "one customrun cancelled for timeout, one done but not cancelled", rpt: ResolvedPipelineTask{ CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0])), makeCustomRunSucceeded(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0])), makeCustomRunSucceeded(customRuns[1])}, }, want: true, }} @@ -1972,7 +1972,7 @@ func TestHasTaskRunsStarted(t *testing.T) { } } -func TestHasRunObjectsStarted(t *testing.T) { +func TestHasCustomRunsStarted(t *testing.T) { for _, tc := range []struct { name string rpt ResolvedPipelineTask @@ -1989,7 +1989,7 @@ func TestHasRunObjectsStarted(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }, want: true, }, { @@ -1997,7 +1997,7 @@ func TestHasRunObjectsStarted(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, }, want: true, }, { @@ -2005,7 +2005,7 @@ func TestHasRunObjectsStarted(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, want: true, }, { @@ -2020,7 +2020,7 @@ func TestHasRunObjectsStarted(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: true, }, { @@ -2028,7 +2028,7 @@ func TestHasRunObjectsStarted(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, }, want: true, }, { @@ -2036,7 +2036,7 @@ func TestHasRunObjectsStarted(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: true, }, { @@ -2044,19 +2044,19 @@ func TestHasRunObjectsStarted(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, }, want: true, }} { t.Run(tc.name, func(t *testing.T) { - if got := tc.rpt.hasRunObjectsStarted(); got != tc.want { + if got := tc.rpt.hasCustomRunsStarted(); got != tc.want { t.Errorf("expected isStarted: %t but got %t", tc.want, got) } }) } } -func TestAreRunObjectsConditionStatusFalse(t *testing.T) { +func TestAreCustomRunsConditionStatusFalse(t *testing.T) { for _, tc := range []struct { name string rpt ResolvedPipelineTask @@ -2073,7 +2073,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }, want: false, }, { @@ -2081,7 +2081,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, }, want: false, }, { @@ -2089,14 +2089,14 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, want: true, }, { name: "customrun cancelled", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, CustomTask: true, }, want: true, @@ -2104,7 +2104,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { name: "customrun cancelled for timeout", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelledForTimeout(makeCustomRunFailed(customRuns[0]))}, CustomTask: true, }, want: true, @@ -2112,7 +2112,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { name: "customrun cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0]))}, CustomTask: true, }, want: false, @@ -2128,7 +2128,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -2136,7 +2136,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, }, want: false, }, { @@ -2144,7 +2144,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -2152,7 +2152,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, }, want: true, }, { @@ -2160,7 +2160,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: true, }, { @@ -2168,7 +2168,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, }, want: true, }, { @@ -2176,7 +2176,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: true, }, { @@ -2184,7 +2184,7 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0])), withCustomRunCancelled(newCustomRun(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0])), withCustomRunCancelled(newCustomRun(customRuns[1]))}, }, want: false, }, { @@ -2192,13 +2192,13 @@ func TestAreRunObjectsConditionStatusFalse(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: false, }} { t.Run(tc.name, func(t *testing.T) { - if got := tc.rpt.areRunObjectsConditionStatusFalse(); got != tc.want { - t.Errorf("expected areRunObjectsConditionStatusFalse: %t but got %t", tc.want, got) + if got := tc.rpt.areCustomRunsConditionStatusFalse(); got != tc.want { + t.Errorf("expected areCustomRunsConditionStatusFalse: %t but got %t", tc.want, got) } }) } @@ -2501,7 +2501,7 @@ func TestResolvePipelineRun_CustomTask(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "pipelinerun"}, } run := &v1beta1.CustomRun{ObjectMeta: metav1.ObjectMeta{Name: "run-exists-abcde"}} - getRun := func(name string) (v1beta1.RunObject, error) { + getRun := func(name string) (*v1beta1.CustomRun, error) { if name == "pipelinerun-run-exists" { return run, nil } @@ -2522,18 +2522,18 @@ func TestResolvePipelineRun_CustomTask(t *testing.T) { expectedState := PipelineRunState{{ PipelineTask: &pts[0], CustomTask: true, - RunObjectNames: []string{"pipelinerun-customtask"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-customtask"}, + CustomRuns: nil, }, { PipelineTask: &pts[1], CustomTask: true, - RunObjectNames: []string{"pipelinerun-customtask-spec"}, - RunObjects: nil, + CustomRunNames: []string{"pipelinerun-customtask-spec"}, + CustomRuns: nil, }, { PipelineTask: &pts[2], CustomTask: true, - RunObjectNames: []string{"pipelinerun-run-exists"}, - RunObjects: []v1beta1.RunObject{run}, + CustomRunNames: []string{"pipelinerun-run-exists"}, + CustomRuns: []*v1beta1.CustomRun{run}, }} if d := cmp.Diff(expectedState, pipelineState); d != "" { t.Errorf("Unexpected pipeline state: %s", diff.PrintWantGot(d)) @@ -2563,7 +2563,7 @@ func TestResolvePipelineRun_PipelineTaskHasNoResources(t *testing.T) { } pipelineState := PipelineRunState{} for _, task := range pts { - ps, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, task) + ps, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetCustomRun, task) if err != nil { t.Errorf("Error getting tasks for fake pipeline %s: %s", p.ObjectMeta.Name, err) } @@ -2614,7 +2614,7 @@ func TestResolvePipelineRun_TaskDoesntExist(t *testing.T) { }, } for _, pt := range pts { - _, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, pt) + _, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetCustomRun, pt) var tnf *TaskNotFoundError switch { case err == nil: @@ -2654,7 +2654,7 @@ func TestResolvePipelineRun_VerificationFailed(t *testing.T) { }, } for _, pt := range pts { - rt, _ := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, pt) + rt, _ := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetCustomRun, pt) if d := cmp.Diff(verificationResult, rt.ResolvedTask.VerificationResult, cmpopts.EquateErrors()); d != "" { t.Errorf(diff.PrintWantGot(d)) } @@ -2898,7 +2898,7 @@ func TestResolvePipeline_WhenExpressions(t *testing.T) { } t.Run("When Expressions exist", func(t *testing.T) { - _, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetRun, pt) + _, err := ResolvePipelineTask(context.Background(), pr, getTask, getTaskRun, nopGetCustomRun, pt) if err != nil { t.Fatalf("Did not expect error when resolving PipelineRun: %v", err) } @@ -2915,7 +2915,7 @@ func TestIsCustomTask(t *testing.T) { return task, nil, nil, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } //nolint:nilnil - getRun := func(name string) (v1beta1.RunObject, error) { return nil, nil } + getRun := func(name string) (*v1beta1.CustomRun, error) { return nil, nil } //nolint:nilnil for _, tc := range []struct { name string @@ -3610,7 +3610,7 @@ func TestGetNamesOfRuns(t *testing.T) { if tc.prName != "" { testPrName = tc.prName } - namesOfRunsFromChildRefs := getNamesOfRuns(childRefs, tc.ptName, testPrName, 2) + namesOfRunsFromChildRefs := getNamesOfCustomRuns(childRefs, tc.ptName, testPrName, 2) sort.Strings(namesOfRunsFromChildRefs) if d := cmp.Diff(tc.wantRunNames, namesOfRunsFromChildRefs); d != "" { t.Errorf("getRunName: %s", diff.PrintWantGot(d)) @@ -3660,11 +3660,11 @@ func TestGetRunName(t *testing.T) { if tc.prName != "" { testPrName = tc.prName } - rnFromChildRefs := getRunName(childRefs, tc.ptName, testPrName) + rnFromChildRefs := getCustomRunName(childRefs, tc.ptName, testPrName) if d := cmp.Diff(tc.wantTrName, rnFromChildRefs); d != "" { t.Errorf("GetTaskRunName: %s", diff.PrintWantGot(d)) } - rnFromBoth := getRunName(childRefs, tc.ptName, testPrName) + rnFromBoth := getCustomRunName(childRefs, tc.ptName, testPrName) if d := cmp.Diff(tc.wantTrName, rnFromBoth); d != "" { t.Errorf("GetTaskRunName: %s", diff.PrintWantGot(d)) } @@ -3682,7 +3682,7 @@ func TestIsMatrixed(t *testing.T) { return task, nil, nil, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return &trs[0], nil } - getRun := func(name string) (v1beta1.RunObject, error) { return &customRuns[0], nil } + getRun := func(name string) (*v1beta1.CustomRun, error) { return &customRuns[0], nil } for _, tc := range []struct { name string @@ -3816,7 +3816,7 @@ func TestResolvePipelineRunTask_WithMatrix(t *testing.T) { return task, nil, nil, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return taskRunsMap[name], nil } - getRun := func(name string) (v1beta1.RunObject, error) { return &customRuns[0], nil } + getRun := func(name string) (*v1beta1.CustomRun, error) { return &customRuns[0], nil } for _, tc := range []struct { name string @@ -3872,7 +3872,7 @@ func TestResolvePipelineRunTask_WithMatrixedCustomTask(t *testing.T) { }, } - var runs []v1beta1.RunObject + var runs []*v1beta1.CustomRun var runNames []string runsMap := map[string]*v1beta1.CustomRun{} for i := 0; i < 9; i++ { @@ -3920,7 +3920,7 @@ func TestResolvePipelineRunTask_WithMatrixedCustomTask(t *testing.T) { return task, nil, nil, nil } getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return &trs[0], nil } - getRun := func(name string) (v1beta1.RunObject, error) { return runsMap[name], nil } + getRun := func(name string) (*v1beta1.CustomRun, error) { return runsMap[name], nil } for _, tc := range []struct { name string @@ -3932,8 +3932,8 @@ func TestResolvePipelineRunTask_WithMatrixedCustomTask(t *testing.T) { pt: pts[0], want: &ResolvedPipelineTask{ CustomTask: true, - RunObjectNames: runNames[:3], - RunObjects: runs[:3], + CustomRunNames: runNames[:3], + CustomRuns: runs[:3], PipelineTask: &pts[0], }, }, { @@ -3941,20 +3941,20 @@ func TestResolvePipelineRunTask_WithMatrixedCustomTask(t *testing.T) { pt: pts[1], want: &ResolvedPipelineTask{ CustomTask: true, - RunObjectNames: runNames, - RunObjects: runs, + CustomRunNames: runNames, + CustomRuns: runs, PipelineTask: &pts[1], }, }, { name: "custom task with matrix - nil run", pt: pts[1], - getRun: func(name string) (v1beta1.RunObject, error) { + getRun: func(name string) (*v1beta1.CustomRun, error) { return nil, kerrors.NewNotFound(v1beta1.Resource("run"), name) }, want: &ResolvedPipelineTask{ CustomTask: true, - RunObjectNames: runNames, - RunObjects: nil, + CustomRunNames: runNames, + CustomRuns: nil, PipelineTask: &pts[1], }, }} { @@ -4012,7 +4012,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }, want: false, }, { @@ -4027,7 +4027,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, }, want: true, }, { @@ -4042,7 +4042,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, want: false, }, { @@ -4057,7 +4057,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, want: false, }, { @@ -4065,7 +4065,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunRetries(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunRetries(makeCustomRunFailed(customRuns[0]))}, }, want: false, }, { @@ -4086,7 +4086,7 @@ func TestIsSuccessful(t *testing.T) { name: "run cancelled", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, CustomTask: true, }, want: false, @@ -4094,7 +4094,7 @@ func TestIsSuccessful(t *testing.T) { name: "run cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0]))}, CustomTask: true, }, want: false, @@ -4109,7 +4109,7 @@ func TestIsSuccessful(t *testing.T) { name: "run cancelled: retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, CustomTask: true, }, want: false, @@ -4124,7 +4124,7 @@ func TestIsSuccessful(t *testing.T) { name: "run cancelled: retried", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0])))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0])))}, CustomTask: true, }, want: false, @@ -4153,7 +4153,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -4168,7 +4168,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, }, want: false, }, { @@ -4183,7 +4183,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, }, want: true, }, { @@ -4198,7 +4198,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -4213,7 +4213,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, }, want: false, }, { @@ -4228,7 +4228,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -4243,7 +4243,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, }, want: false, }, { @@ -4258,7 +4258,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, }, want: false, }, { @@ -4266,7 +4266,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunRetries(makeCustomRunFailed(customRuns[0])), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunRetries(makeCustomRunFailed(customRuns[0])), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, }, want: false, }, { @@ -4281,7 +4281,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, }, want: false, }, { @@ -4296,7 +4296,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -4311,7 +4311,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0])), withCustomRunCancelled(newCustomRun(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0])), withCustomRunCancelled(newCustomRun(customRuns[1]))}, }, want: false, }, { @@ -4326,7 +4326,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -4341,7 +4341,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, }, want: false, }, { @@ -4356,7 +4356,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: false, }, { @@ -4371,7 +4371,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[1])))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[1])))}, }, want: false, }, { @@ -4386,7 +4386,7 @@ func TestIsSuccessful(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), makeCustomRunStarted(customRuns[1])}, }, want: false, }} { @@ -4428,7 +4428,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }, want: true, }, { @@ -4443,7 +4443,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, }, want: false, }, { @@ -4458,7 +4458,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, want: false, }, { @@ -4473,7 +4473,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }, want: false, }, { @@ -4481,7 +4481,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, - RunObjects: []v1beta1.RunObject{withCustomRunRetries(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunRetries(makeCustomRunFailed(customRuns[0]))}, }, want: false, }, { @@ -4502,7 +4502,7 @@ func TestIsRunning(t *testing.T) { name: "run cancelled", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, CustomTask: true, }, want: false, @@ -4510,7 +4510,7 @@ func TestIsRunning(t *testing.T) { name: "run cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0]))}, CustomTask: true, }, want: true, @@ -4525,7 +4525,7 @@ func TestIsRunning(t *testing.T) { name: "run cancelled: retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0]))}, CustomTask: true, }, want: false, @@ -4540,7 +4540,7 @@ func TestIsRunning(t *testing.T) { name: "run cancelled: retried", rpt: ResolvedPipelineTask{ PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0])))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0])))}, CustomTask: true, }, want: false, @@ -4569,7 +4569,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: true, }, { @@ -4584,7 +4584,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, }, want: true, }, { @@ -4599,7 +4599,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0]), makeCustomRunSucceeded(customRuns[1])}, }, want: false, }, { @@ -4614,7 +4614,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, }, want: false, }, { @@ -4629,7 +4629,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunStarted(customRuns[1])}, }, want: true, }, { @@ -4644,7 +4644,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), makeCustomRunFailed(customRuns[1])}, }, want: false, }, { @@ -4659,7 +4659,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0]), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0]), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, }, want: false, }, { @@ -4667,7 +4667,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunRetries(makeCustomRunFailed(customRuns[0])), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunRetries(makeCustomRunFailed(customRuns[0])), withCustomRunRetries(makeCustomRunFailed(customRuns[1]))}, }, want: false, }, { @@ -4682,7 +4682,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, }, want: false, }, { @@ -4697,7 +4697,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: true, }, { @@ -4712,7 +4712,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0])), withCustomRunCancelled(newCustomRun(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0])), withCustomRunCancelled(newCustomRun(customRuns[1]))}, }, want: true, }, { @@ -4727,7 +4727,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: matrixedPipelineTask, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(newCustomRun(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(newCustomRun(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: true, }, { @@ -4742,7 +4742,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), withCustomRunCancelled(makeCustomRunFailed(customRuns[1]))}, }, want: false, }, { @@ -4757,7 +4757,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(makeCustomRunFailed(customRuns[0])), makeCustomRunStarted(customRuns[1])}, }, want: true, }, { @@ -4772,7 +4772,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[1])))}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[1])))}, }, want: false, }, { @@ -4787,7 +4787,7 @@ func TestIsRunning(t *testing.T) { rpt: ResolvedPipelineTask{ CustomTask: true, PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), makeCustomRunStarted(customRuns[1])}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(makeCustomRunFailed(customRuns[0]))), makeCustomRunStarted(customRuns[1])}, }, want: true, }} { diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go index 383159ea9e2..a2af7a936bc 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go @@ -112,7 +112,7 @@ func (state PipelineRunState) ToMap() map[string]*ResolvedPipelineTask { // IsBeforeFirstTaskRun returns true if the PipelineRun has not yet started its first TaskRun func (state PipelineRunState) IsBeforeFirstTaskRun() bool { for _, t := range state { - if len(t.RunObjects) > 0 || len(t.TaskRuns) > 0 { + if len(t.CustomRuns) > 0 || len(t.TaskRuns) > 0 { return false } } @@ -130,8 +130,8 @@ func (state PipelineRunState) IsBeforeFirstTaskRun() bool { func (state PipelineRunState) AdjustStartTime(unadjustedStartTime *metav1.Time) *metav1.Time { adjustedStartTime := unadjustedStartTime for _, rpt := range state { - for _, runObject := range rpt.RunObjects { - creationTime := runObject.GetObjectMeta().GetCreationTimestamp() + for _, customRun := range rpt.CustomRuns { + creationTime := customRun.GetObjectMeta().GetCreationTimestamp() if creationTime.Time.Before(adjustedStartTime.Time) { adjustedStartTime = &creationTime } @@ -176,8 +176,8 @@ func (state PipelineRunState) GetRunsResults() map[string][]v1beta1.CustomRunRes continue } // Currently a Matrix cannot produce results so this is for a singular CustomRun - if len(rpt.RunObjects) == 1 { - cr := rpt.RunObjects[0].(*v1beta1.CustomRun) + if len(rpt.CustomRuns) == 1 { + cr := rpt.CustomRuns[0] results[rpt.PipelineTask.Name] = cr.Status.Results } } @@ -198,24 +198,22 @@ func (state PipelineRunState) GetChildReferences() []v1beta1.ChildStatusReferenc childRefs = append(childRefs, rpt.getChildRefForTaskRun(taskRun)) } } - case len(rpt.RunObjects) != 0: - for _, run := range rpt.RunObjects { - if run != nil { - childRefs = append(childRefs, rpt.getChildRefForRun(run)) - } + case len(rpt.CustomRuns) != 0: + for _, run := range rpt.CustomRuns { + childRefs = append(childRefs, rpt.getChildRefForRun(run)) } } } return childRefs } -func (t *ResolvedPipelineTask) getChildRefForRun(runObj v1beta1.RunObject) v1beta1.ChildStatusReference { +func (t *ResolvedPipelineTask) getChildRefForRun(customRun *v1beta1.CustomRun) v1beta1.ChildStatusReference { return v1beta1.ChildStatusReference{ TypeMeta: runtime.TypeMeta{ APIVersion: v1beta1.SchemeGroupVersion.String(), Kind: pipeline.CustomRunControllerName, }, - Name: runObj.GetObjectMeta().GetName(), + Name: customRun.GetObjectMeta().GetName(), PipelineTaskName: t.PipelineTask.Name, WhenExpressions: t.PipelineTask.WhenExpressions, } @@ -240,7 +238,7 @@ func (state PipelineRunState) getNextTasks(candidateTasks sets.String) []*Resolv tasks := []*ResolvedPipelineTask{} for _, t := range state { if _, ok := candidateTasks[t.PipelineTask.Name]; ok { - if len(t.TaskRuns) == 0 && len(t.RunObjects) == 0 { + if len(t.TaskRuns) == 0 && len(t.CustomRuns) == 0 { tasks = append(tasks, t) } } @@ -497,7 +495,7 @@ func (facts *PipelineRunFacts) GetPipelineTaskStatus() map[string]string { for _, t := range facts.State { if facts.isDAGTask(t.PipelineTask.Name) { // if any of the dag task failed, change the aggregate status to failed and return - if !t.IsCustomTask() && t.areTaskRunsConditionStatusFalse() || t.IsCustomTask() && t.areRunObjectsConditionStatusFalse() { + if !t.IsCustomTask() && t.areTaskRunsConditionStatusFalse() || t.IsCustomTask() && t.areCustomRunsConditionStatusFalse() { aggregateStatus = v1beta1.PipelineRunReasonFailed.String() break } diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go index 4a2e1a6a899..bd361cc2a1b 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go @@ -110,22 +110,22 @@ func TestPipelineRunFacts_CheckDAGTasksDoneDone(t *testing.T) { var customRunRunningState = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, }} var customRunSucceededState = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, }} var customRunFailedState = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, }} var taskCancelledFailedWithRetries = PipelineRunState{{ @@ -626,8 +626,8 @@ func TestGetNextTaskWithRetries(t *testing.T) { var customRunCancelledByStatusState = PipelineRunState{{ PipelineTask: &pts[4], // 2 retries needed - RunObjectNames: []string{"pipelinerun-mytask1"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(newCustomRun(customRuns[0])))}, + CustomRunNames: []string{"pipelinerun-mytask1"}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(newCustomRun(customRuns[0])))}, CustomTask: true, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, @@ -636,8 +636,8 @@ func TestGetNextTaskWithRetries(t *testing.T) { var customRunCancelledBySpecState = PipelineRunState{{ PipelineTask: &pts[4], - RunObjectNames: []string{"pipelinerun-mytask1"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelledBySpec(withCustomRunRetries(newCustomRun(customRuns[0])))}, + CustomRunNames: []string{"pipelinerun-mytask1"}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelledBySpec(withCustomRunRetries(newCustomRun(customRuns[0])))}, CustomTask: true, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, @@ -646,8 +646,8 @@ func TestGetNextTaskWithRetries(t *testing.T) { var customRunRunningState = PipelineRunState{{ PipelineTask: &pts[4], - RunObjectNames: []string{"pipelinerun-mytask1"}, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask1"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, CustomTask: true, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, @@ -656,8 +656,8 @@ func TestGetNextTaskWithRetries(t *testing.T) { var customRunSucceededState = PipelineRunState{{ PipelineTask: &pts[4], - RunObjectNames: []string{"pipelinerun-mytask1"}, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask1"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, CustomTask: true, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, @@ -711,8 +711,8 @@ func TestGetNextTaskWithRetries(t *testing.T) { var runCancelledByStatusStateMatrix = PipelineRunState{{ PipelineTask: &pts[20], // 2 retries needed - RunObjectNames: []string{"pipelinerun-mytask1"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(newCustomRun(customRuns[0])))}, + CustomRunNames: []string{"pipelinerun-mytask1"}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(newCustomRun(customRuns[0])))}, CustomTask: true, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, @@ -721,8 +721,8 @@ func TestGetNextTaskWithRetries(t *testing.T) { var runCancelledBySpecStateMatrix = PipelineRunState{{ PipelineTask: &pts[20], // 2 retries needed - RunObjectNames: []string{"pipelinerun-mytask1"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelledBySpec(withCustomRunRetries(newCustomRun(customRuns[0])))}, + CustomRunNames: []string{"pipelinerun-mytask1"}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelledBySpec(withCustomRunRetries(newCustomRun(customRuns[0])))}, CustomTask: true, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, @@ -731,8 +731,8 @@ func TestGetNextTaskWithRetries(t *testing.T) { var runRunningStateMatrix = PipelineRunState{{ PipelineTask: &pts[20], // 2 retries needed - RunObjectNames: []string{"pipelinerun-mytask1"}, - RunObjects: []v1beta1.RunObject{makeCustomRunStarted(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask1"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunStarted(customRuns[0])}, CustomTask: true, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, @@ -741,8 +741,8 @@ func TestGetNextTaskWithRetries(t *testing.T) { var customRunSucceededStateMatrix = PipelineRunState{{ PipelineTask: &pts[20], // 2 retries needed - RunObjectNames: []string{"pipelinerun-mytask1"}, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRunNames: []string{"pipelinerun-mytask1"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, CustomTask: true, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, @@ -751,8 +751,8 @@ func TestGetNextTaskWithRetries(t *testing.T) { var customRunRetriedStateMatrix = PipelineRunState{{ PipelineTask: &pts[17], // 1 retry needed - RunObjectNames: []string{"pipelinerun-mytask1"}, - RunObjects: []v1beta1.RunObject{withCustomRunCancelled(withCustomRunRetries(newCustomRun(customRuns[0])))}, + CustomRunNames: []string{"pipelinerun-mytask1"}, + CustomRuns: []*v1beta1.CustomRun{withCustomRunCancelled(withCustomRunRetries(newCustomRun(customRuns[0])))}, CustomTask: true, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, @@ -892,7 +892,7 @@ func TestDAGExecutionQueue(t *testing.T) { Name: "createdrun", TaskRef: &v1beta1.TaskRef{Name: "task"}, }, - RunObjectNames: []string{"createdrun"}, + CustomRunNames: []string{"createdrun"}, CustomTask: true, } runningTask := ResolvedPipelineTask{ @@ -911,8 +911,8 @@ func TestDAGExecutionQueue(t *testing.T) { Name: "runningrun", TaskRef: &v1beta1.TaskRef{Name: "task"}, }, - RunObjectNames: []string{"runningrun"}, - RunObjects: []v1beta1.RunObject{newCustomRun(customRuns[0])}, + CustomRunNames: []string{"runningrun"}, + CustomRuns: []*v1beta1.CustomRun{newCustomRun(customRuns[0])}, CustomTask: true, } successfulTask := ResolvedPipelineTask{ @@ -931,8 +931,8 @@ func TestDAGExecutionQueue(t *testing.T) { Name: "successfulrun", TaskRef: &v1beta1.TaskRef{Name: "task"}, }, - RunObjectNames: []string{"successfulrun"}, - RunObjects: []v1beta1.RunObject{makeCustomRunSucceeded(customRuns[0])}, + CustomRunNames: []string{"successfulrun"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunSucceeded(customRuns[0])}, CustomTask: true, } failedTask := ResolvedPipelineTask{ @@ -951,8 +951,8 @@ func TestDAGExecutionQueue(t *testing.T) { Name: "failedrun", TaskRef: &v1beta1.TaskRef{Name: "task"}, }, - RunObjectNames: []string{"failedrun"}, - RunObjects: []v1beta1.RunObject{makeCustomRunFailed(customRuns[0])}, + CustomRunNames: []string{"failedrun"}, + CustomRuns: []*v1beta1.CustomRun{makeCustomRunFailed(customRuns[0])}, CustomTask: true, } tcs := []struct { @@ -1163,7 +1163,7 @@ func TestDAGExecutionQueueSequentialRuns(t *testing.T) { Name: "task-1", TaskRef: &v1beta1.TaskRef{Name: "task"}, }, - RunObjectNames: []string{"task-1"}, + CustomRunNames: []string{"task-1"}, CustomTask: true, } secondRun := ResolvedPipelineTask{ @@ -1172,14 +1172,14 @@ func TestDAGExecutionQueueSequentialRuns(t *testing.T) { TaskRef: &v1beta1.TaskRef{Name: "task"}, RunAfter: []string{"task-1"}, }, - RunObjectNames: []string{"task-2"}, + CustomRunNames: []string{"task-2"}, CustomTask: true, } if tc.firstRun != nil { - firstRun.RunObjects = append(firstRun.RunObjects, tc.firstRun) + firstRun.CustomRuns = append(firstRun.CustomRuns, tc.firstRun) } if tc.secondRun != nil { - secondRun.RunObjects = append(secondRun.RunObjects, tc.secondRun) + secondRun.CustomRuns = append(secondRun.CustomRuns, tc.secondRun) } state := PipelineRunState{&firstRun, &secondRun} d, err := dagFromState(state) @@ -1586,9 +1586,9 @@ func TestGetPipelineConditionStatus(t *testing.T) { var cancelledRun = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask13"}, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRunNames: []string{"pipelinerun-mytask13"}, + CustomRuns: []*v1beta1.CustomRun{ + { Status: v1beta1.CustomRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -1602,9 +1602,9 @@ func TestGetPipelineConditionStatus(t *testing.T) { var timedOutRun = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask14"}, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRunNames: []string{"pipelinerun-mytask14"}, + CustomRuns: []*v1beta1.CustomRun{ + { Spec: v1beta1.CustomRunSpec{ StatusMessage: v1beta1.CustomRunCancelledByPipelineTimeoutMsg, }, @@ -1621,7 +1621,7 @@ func TestGetPipelineConditionStatus(t *testing.T) { var notRunningRun = PipelineRunState{{ PipelineTask: &pts[12], CustomTask: true, - RunObjectNames: []string{"pipelinerun-mytask14"}, + CustomRunNames: []string{"pipelinerun-mytask14"}, }} // 6 Tasks, 4 that run in parallel in the beginning @@ -2162,18 +2162,18 @@ func TestAdjustStartTime(t *testing.T) { }, { name: "multiple CustomRuns, some earlier", prs: PipelineRunState{{ - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { ObjectMeta: metav1.ObjectMeta{ Name: "blah1", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(-1 * time.Second)}, }, - }, &v1beta1.CustomRun{ + }, { ObjectMeta: metav1.ObjectMeta{ Name: "blah2", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(-2 * time.Second)}, }, - }, &v1beta1.CustomRun{ + }, { ObjectMeta: metav1.ObjectMeta{ Name: "blah3", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(2 * time.Second)}, @@ -2185,8 +2185,8 @@ func TestAdjustStartTime(t *testing.T) { }, { name: "CustomRun starts later", prs: PipelineRunState{{ - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { ObjectMeta: metav1.ObjectMeta{ Name: "blah", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(1 * time.Second)}, @@ -2198,8 +2198,8 @@ func TestAdjustStartTime(t *testing.T) { }, { name: "CustomRun starts earlier", prs: PipelineRunState{{ - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { ObjectMeta: metav1.ObjectMeta{ Name: "blah", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(-1 * time.Second)}, @@ -2585,13 +2585,13 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { Name: "nil-taskrun-1", }, }, { - RunObjectNames: []string{"successful-run-with-results"}, + CustomRunNames: []string{"successful-run-with-results"}, CustomTask: true, PipelineTask: &v1beta1.PipelineTask{ Name: "successful-run-with-results-1", }, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { Status: v1beta1.CustomRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -2609,13 +2609,13 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }, }}, }, { - RunObjectNames: []string{"successful-run-without-results"}, + CustomRunNames: []string{"successful-run-without-results"}, CustomTask: true, PipelineTask: &v1beta1.PipelineTask{ Name: "successful-run-without-results-1", }, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { Status: v1beta1.CustomRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -2625,12 +2625,12 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }, }}, }, { - RunObjectNames: []string{"failed-run"}, + CustomRunNames: []string{"failed-run"}, PipelineTask: &v1beta1.PipelineTask{ Name: "failed-run-1", }, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { Status: v1beta1.CustomRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -2645,12 +2645,12 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }}, }, }, { - RunObjectNames: []string{"incomplete-run"}, + CustomRunNames: []string{"incomplete-run"}, PipelineTask: &v1beta1.PipelineTask{ Name: "incomplete-run-1", }, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { Status: v1beta1.CustomRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -2665,7 +2665,7 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }, }}, }, { - RunObjectNames: []string{"nil-run"}, + CustomRunNames: []string{"nil-run"}, CustomTask: true, PipelineTask: &v1beta1.PipelineTask{ Name: "nil-run-1", @@ -2735,7 +2735,7 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }, }}, }, { - RunObjectNames: []string{ + CustomRunNames: []string{ "matrixed-run-0", "matrixed-run-1", "matrixed-run-2", @@ -2756,8 +2756,8 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, }}}, }, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { TypeMeta: metav1.TypeMeta{APIVersion: "example.dev/v0"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-run-0"}, Status: v1beta1.CustomRunStatus{ @@ -2775,7 +2775,7 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }}, }, }, - }, &v1beta1.CustomRun{ + }, { TypeMeta: metav1.TypeMeta{APIVersion: "example.dev/v0"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-run-1"}, Status: v1beta1.CustomRunStatus{ @@ -2793,7 +2793,7 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }}, }, }, - }, &v1beta1.CustomRun{ + }, { TypeMeta: metav1.TypeMeta{APIVersion: "example.dev/v0"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-run-2"}, Status: v1beta1.CustomRunStatus{ @@ -2811,7 +2811,7 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }}, }, }, - }, &v1beta1.CustomRun{ + }, { TypeMeta: metav1.TypeMeta{APIVersion: "example.dev/v0"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-run-3"}, Status: v1beta1.CustomRunStatus{ @@ -2894,7 +2894,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { { name: "unresolved-custom-task", state: PipelineRunState{{ - RunObjectNames: []string{"unresolved-custom-task-run"}, + CustomRunNames: []string{"unresolved-custom-task-run"}, CustomTask: true, PipelineTask: &v1beta1.PipelineTask{ Name: "unresolved-custom-task-1", @@ -2946,7 +2946,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { { name: "single-custom-task", state: PipelineRunState{{ - RunObjectNames: []string{"single-custom-task-run"}, + CustomRunNames: []string{"single-custom-task-run"}, CustomTask: true, PipelineTask: &v1beta1.PipelineTask{ Name: "single-custom-task-1", @@ -2961,8 +2961,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Values: []string{"foo", "bar"}, }}, }, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, ObjectMeta: metav1.ObjectMeta{Name: "single-custom-task-run"}, }}, @@ -2998,7 +2998,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "single-task-run"}, }}, }, { - RunObjectNames: []string{"single-custom-task-run"}, + CustomRunNames: []string{"single-custom-task-run"}, CustomTask: true, PipelineTask: &v1beta1.PipelineTask{ Name: "single-custom-task-1", @@ -3008,8 +3008,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Name: "single-custom-task", }, }, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRuns: []*v1beta1.CustomRun{ + { TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, ObjectMeta: metav1.ObjectMeta{Name: "single-custom-task-run"}, }}, @@ -3199,7 +3199,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }}}, }, CustomTask: true, - RunObjects: []v1beta1.RunObject{ + CustomRuns: []*v1beta1.CustomRun{ customRunWithName("matrixed-run-0"), customRunWithName("matrixed-run-1"), customRunWithName("matrixed-run-2"), diff --git a/pkg/reconciler/pipelinerun/resources/resultrefresolution.go b/pkg/reconciler/pipelinerun/resources/resultrefresolution.go index 5ed44393119..3d3c3c58263 100644 --- a/pkg/reconciler/pipelinerun/resources/resultrefresolution.go +++ b/pkg/reconciler/pipelinerun/resources/resultrefresolution.go @@ -130,12 +130,12 @@ func resolveResultRef(pipelineState PipelineRunState, resultRef *v1beta1.ResultR var resultValue v1beta1.ResultValue var err error if referencedPipelineTask.IsCustomTask() { - if len(referencedPipelineTask.RunObjects) != 1 { + if len(referencedPipelineTask.CustomRuns) != 1 { return nil, resultRef.PipelineTask, fmt.Errorf("referenced tasks can only have length of 1 since a matrixed task does not support producing results, but was length %d", len(referencedPipelineTask.TaskRuns)) } - runObject := referencedPipelineTask.RunObjects[0] - runName = runObject.GetObjectMeta().GetName() - runValue, err = findRunResultForParam(runObject, resultRef) + customRun := referencedPipelineTask.CustomRuns[0] + runName = customRun.GetObjectMeta().GetName() + runValue, err = findRunResultForParam(customRun, resultRef) resultValue = *v1beta1.NewStructuredValues(runValue) if err != nil { return nil, resultRef.PipelineTask, err @@ -161,9 +161,8 @@ func resolveResultRef(pipelineState PipelineRunState, resultRef *v1beta1.ResultR }, "", nil } -func findRunResultForParam(runObj v1beta1.RunObject, reference *v1beta1.ResultRef) (string, error) { - run := runObj.(*v1beta1.CustomRun) - for _, result := range run.Status.Results { +func findRunResultForParam(customRun *v1beta1.CustomRun, reference *v1beta1.ResultRef) (string, error) { + for _, result := range customRun.Status.Results { if result.Name == reference.Result { return result.Value, nil } diff --git a/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go b/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go index fa0cb1e2ae3..84d0a8a417d 100644 --- a/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go @@ -104,9 +104,9 @@ var pipelineRunState = PipelineRunState{{ }, }, { CustomTask: true, - RunObjectNames: []string{"aRun"}, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRunNames: []string{"aRun"}, + CustomRuns: []*v1beta1.CustomRun{ + { ObjectMeta: metav1.ObjectMeta{Name: "aRun"}, Status: v1beta1.CustomRunStatus{ Status: duckv1.Status{ @@ -262,9 +262,9 @@ var pipelineRunState = PipelineRunState{{ }, }, { CustomTask: true, - RunObjectNames: []string{"xRun"}, - RunObjects: []v1beta1.RunObject{ - &v1beta1.CustomRun{ + CustomRunNames: []string{"xRun"}, + CustomRuns: []*v1beta1.CustomRun{ + { ObjectMeta: metav1.ObjectMeta{Name: "xRun"}, Status: v1beta1.CustomRunStatus{ Status: duckv1.Status{ @@ -277,7 +277,7 @@ var pipelineRunState = PipelineRunState{{ }}, }, }, - }, &v1beta1.CustomRun{ + }, { ObjectMeta: metav1.ObjectMeta{Name: "yRun"}, Status: v1beta1.CustomRunStatus{ Status: duckv1.Status{ diff --git a/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go b/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go index 41c37efb319..866ae805a85 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go +++ b/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go @@ -97,7 +97,7 @@ func TestValidatePipelineTaskResults_ValidStates(t *testing.T) { Name: "pt1", }, CustomTask: true, - RunObjectNames: []string{"foo-run"}, + CustomRunNames: []string{"foo-run"}, }, { PipelineTask: &v1beta1.PipelineTask{ Name: "pt2", diff --git a/test/custom_task_test.go b/test/custom_task_test.go index 3ceb1c058fd..e0218e998d3 100644 --- a/test/custom_task_test.go +++ b/test/custom_task_test.go @@ -50,9 +50,7 @@ import ( ) const ( - apiVersion = "wait.testing.tekton.dev/v1alpha1" kind = "Wait" - waitTaskDir = "./custom-task-ctrls/wait-task-alpha" betaAPIVersion = "wait.testing.tekton.dev/v1beta1" betaWaitTaskDir = "./custom-task-ctrls/wait-task-beta" ) @@ -118,7 +116,7 @@ spec: - args: ['-c', 'echo $(input-result-from-custom-task-ref) $(input-result-from-custom-task-spec)'] command: ['/bin/bash'] image: ubuntu -`, pipelineRunName, apiVersion, kind, apiVersion, kind, customTaskRawSpec)), +`, pipelineRunName, betaAPIVersion, kind, betaAPIVersion, kind, customTaskRawSpec)), metav1.CreateOptions{}); err != nil { t.Fatalf("Failed to create PipelineRun %q: %v", pipelineRunName, err) } @@ -135,23 +133,23 @@ spec: } // Get the Run name. - var runNames []string + var customRunNames []string for _, cr := range pr.Status.ChildReferences { if cr.Kind == pipeline.CustomRunControllerName { - runNames = append(runNames, cr.Name) + customRunNames = append(customRunNames, cr.Name) } } - if len(runNames) != 2 { - t.Fatalf("PipelineRun had unexpected number of Runs in .status.childReferences; got %d, want 2", len(runNames)) + if len(customRunNames) != 2 { + t.Fatalf("PipelineRun had unexpected number of CustomRuns in .status.childReferences; got %d, want 2", len(customRunNames)) } - for _, runName := range runNames { - // Get the Run. - cr, err := c.V1beta1CustomRunClient.Get(ctx, runName, metav1.GetOptions{}) + for _, customRunName := range customRunNames { + // Get the CustomRun. + cr, err := c.V1beta1CustomRunClient.Get(ctx, customRunName, metav1.GetOptions{}) if err != nil { - t.Fatalf("Failed to get Run %q: %v", runName, err) + t.Fatalf("Failed to get CustomRun %q: %v", customRunName, err) } if cr.IsDone() { - t.Fatalf("Run unexpectedly done: %v", cr.Status.GetCondition(apis.ConditionSucceeded)) + t.Fatalf("CustomRun unexpectedly done: %v", cr.Status.GetCondition(apis.ConditionSucceeded)) } // Simulate a Custom Task controller updating the CustomRun to done/successful. @@ -171,16 +169,16 @@ spec: } if _, err := c.V1beta1CustomRunClient.UpdateStatus(ctx, cr, metav1.UpdateOptions{}); err != nil { - t.Fatalf("Failed to update Run to successful: %v", err) + t.Fatalf("Failed to update CustomRun to successful: %v", err) } - // Get the Run. - cr, err = c.V1beta1CustomRunClient.Get(ctx, runName, metav1.GetOptions{}) + // Get the CustomRun. + cr, err = c.V1beta1CustomRunClient.Get(ctx, customRunName, metav1.GetOptions{}) if err != nil { - t.Fatalf("Failed to get Run %q: %v", runName, err) + t.Fatalf("Failed to get CustomRun %q: %v", customRunName, err) } - if strings.Contains(runName, "custom-task-spec") { + if strings.Contains(customRunName, "custom-task-spec") { if d := cmp.Diff(customTaskRawSpec, cr.Spec.CustomSpec.Spec.Raw); d != "" { t.Fatalf("Unexpected value of Spec.Raw: %s", diff.PrintWantGot(d)) } @@ -250,10 +248,10 @@ spec: } } -// WaitForRunSpecCancelled polls the spec.status of the Run until it is +// WaitForCustomRunSpecCancelled polls the spec.status of the Run until it is // "RunCancelled", returns an error on timeout. desc will be used to name // the metric that is emitted to track how long it took. -func WaitForRunSpecCancelled(ctx context.Context, c *clients, name string, desc string) error { +func WaitForCustomRunSpecCancelled(ctx context.Context, c *clients, name string, desc string) error { metricName := fmt.Sprintf("WaitForRunSpecCancelled/%s/%s", name, desc) _, span := trace.StartSpan(context.Background(), metricName) defer span.End() @@ -287,7 +285,7 @@ spec: taskRef: apiVersion: %s kind: %s -`, helpers.ObjectNameForTest(t), namespace, apiVersion, kind)) +`, helpers.ObjectNameForTest(t), namespace, betaAPIVersion, kind)) pipelineRun := parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` metadata: name: %s @@ -314,18 +312,18 @@ spec: t.Fatalf("Failed to get PipelineRun %q: %v", pipelineRun.Name, err) } - // Get the Run name. - runName := "" + // Get the CustomRun name. + customRunName := "" if len(pr.Status.ChildReferences) != 1 { t.Fatalf("PipelineRun had unexpected .status.childReferences; got %d, want 1", len(pr.Status.ChildReferences)) } - runName = pr.Status.ChildReferences[0].Name + customRunName = pr.Status.ChildReferences[0].Name // Get the Run. - cr, err := c.V1beta1CustomRunClient.Get(ctx, runName, metav1.GetOptions{}) + cr, err := c.V1beta1CustomRunClient.Get(ctx, customRunName, metav1.GetOptions{}) if err != nil { - t.Fatalf("Failed to get Run %q: %v", runName, err) + t.Fatalf("Failed to get Run %q: %v", customRunName, err) } if cr.IsDone() { t.Fatalf("Run unexpectedly done: %v", cr.Status.GetCondition(apis.ConditionSucceeded)) @@ -353,18 +351,18 @@ spec: t.Errorf("Error waiting for PipelineRun %s to finish: %s", pipelineRun.Name, err) } - runList, err := c.V1beta1CustomRunClient.List(ctx, metav1.ListOptions{LabelSelector: fmt.Sprintf("tekton.dev/pipelineRun=%s", pipelineRun.Name)}) + customRunList, err := c.V1beta1CustomRunClient.List(ctx, metav1.ListOptions{LabelSelector: fmt.Sprintf("tekton.dev/pipelineRun=%s", pipelineRun.Name)}) if err != nil { t.Fatalf("Error listing Runs for PipelineRun %s: %s", pipelineRun.Name, err) } t.Logf("Runs from PipelineRun %s in namespace %s must be cancelled", pipelineRun.Name, namespace) var wg sync.WaitGroup - for _, crItem := range runList.Items { + for _, crItem := range customRunList.Items { wg.Add(1) go func(name string) { defer wg.Done() - err := WaitForRunSpecCancelled(ctx, c, name, "RunCancelled") + err := WaitForCustomRunSpecCancelled(ctx, c, name, "RunCancelled") if err != nil { t.Errorf("Error waiting for Run %s to cancel: %s", name, err) }