From e3c22fcfde0edb1b4115a8ce26c2c8c449ccdd87 Mon Sep 17 00:00:00 2001 From: poy Date: Wed, 27 Nov 2019 13:23:46 -0700 Subject: [PATCH] Update v1alpha1 status types to inline fields Splits up the status types into two structs: * XXXStatus * XXXStatusFields This first inlines both knative's duck status type and the XXXStatusFields. The second stores all the fields that were originially in XXXStatus. This is advantageous as downstream users can now embed a the XXXStatusFields if their CRDs manage a Tekton object. This pattern is demonstrated in Knative (e.g., Serving). Moving to this pattern does not change the JSON/YAML structure in anyway, however it does change how status objects have to be instantiated in Go. fixes #1590 --- pkg/apis/pipeline/v1alpha1/condition_types.go | 8 + .../pipeline/v1alpha1/pipelinerun_types.go | 8 + .../v1alpha1/pipelinerun_types_test.go | 8 +- pkg/apis/pipeline/v1alpha1/taskrun_types.go | 8 + .../pipeline/v1alpha1/taskrun_types_test.go | 8 +- .../v1alpha1/zz_generated.deepcopy.go | 69 +++++- pkg/pod/status_test.go | 206 ++++++++++-------- .../pipelinerun/pipelinerun_test.go | 27 ++- .../resources/conditionresolution.go | 12 +- .../resources/pipelinerunresolution_test.go | 10 +- pkg/reconciler/taskrun/taskrun_test.go | 4 +- test/builder/pipeline_test.go | 20 +- test/builder/task_test.go | 10 +- 13 files changed, 265 insertions(+), 133 deletions(-) diff --git a/pkg/apis/pipeline/v1alpha1/condition_types.go b/pkg/apis/pipeline/v1alpha1/condition_types.go index d6dc169a56a..3071a4c89e9 100644 --- a/pkg/apis/pipeline/v1alpha1/condition_types.go +++ b/pkg/apis/pipeline/v1alpha1/condition_types.go @@ -44,6 +44,14 @@ type Condition struct { type ConditionCheckStatus struct { duckv1beta1.Status `json:",inline"` + // ConditionCheckStatusFields inlines the status fields. + ConditionCheckStatusFields `json:",inline"` +} + +// ConditionCheckStatusFields holds the fields of ConfigurationCheck's status. +// This is defined separately and inlined so that other types can readily +// consume these fields via duck typing. +type ConditionCheckStatusFields struct { // PodName is the name of the pod responsible for executing this condition check. PodName string `json:"podName"` diff --git a/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go b/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go index 1e0853c1115..efd80510d0a 100644 --- a/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go +++ b/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go @@ -98,6 +98,14 @@ type PipelineRef struct { type PipelineRunStatus struct { duckv1beta1.Status `json:",inline"` + // PipelineRunStatusFields inlines the status fields. + PipelineRunStatusFields `json:",inline"` +} + +// PipelineRunStatusFields holds the fields of PipelineRunStatus' status. +// This is defined separately and inlined so that other types can readily +// consume these fields via duck typing. +type PipelineRunStatusFields struct { // StartTime is the time the PipelineRun is actually started. // +optional StartTime *metav1.Time `json:"startTime,omitempty"` diff --git a/pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go b/pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go index 32d5d51d4a1..26a32edbaef 100644 --- a/pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go +++ b/pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go @@ -150,13 +150,17 @@ func TestPipelineRunHasStarted(t *testing.T) { }, { name: "prWithStartTime", prStatus: v1alpha1.PipelineRunStatus{ - StartTime: &metav1.Time{Time: time.Now()}, + PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + StartTime: &metav1.Time{Time: time.Now()}, + }, }, expectedValue: true, }, { name: "prWithZeroStartTime", prStatus: v1alpha1.PipelineRunStatus{ - StartTime: &metav1.Time{}, + PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + StartTime: &metav1.Time{}, + }, }, expectedValue: false, }} diff --git a/pkg/apis/pipeline/v1alpha1/taskrun_types.go b/pkg/apis/pipeline/v1alpha1/taskrun_types.go index 1a676a7cbaf..b16340c1478 100644 --- a/pkg/apis/pipeline/v1alpha1/taskrun_types.go +++ b/pkg/apis/pipeline/v1alpha1/taskrun_types.go @@ -93,6 +93,14 @@ var taskRunCondSet = apis.NewBatchConditionSet() type TaskRunStatus struct { duckv1beta1.Status `json:",inline"` + // TaskRunStatusFields inlines the status fields. + TaskRunStatusFields `json:",inline"` +} + +// TaskRunStatusFields holds the fields of TaskRun's status. This is defined +// separately and inlined so that other types can readily consume these fields +// via duck typing. +type TaskRunStatusFields struct { // PodName is the name of the pod responsible for executing this task's steps. PodName string `json:"podName"` diff --git a/pkg/apis/pipeline/v1alpha1/taskrun_types_test.go b/pkg/apis/pipeline/v1alpha1/taskrun_types_test.go index aea8d19b104..2842554ac59 100644 --- a/pkg/apis/pipeline/v1alpha1/taskrun_types_test.go +++ b/pkg/apis/pipeline/v1alpha1/taskrun_types_test.go @@ -132,13 +132,17 @@ func TestTaskRunHasStarted(t *testing.T) { }, { name: "trWithStartTime", trStatus: v1alpha1.TaskRunStatus{ - StartTime: &metav1.Time{Time: time.Now()}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + StartTime: &metav1.Time{Time: time.Now()}, + }, }, expectedValue: true, }, { name: "trWithZeroStartTime", trStatus: v1alpha1.TaskRunStatus{ - StartTime: &metav1.Time{}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + StartTime: &metav1.Time{}, + }, }, expectedValue: false, }} diff --git a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go index 2d57103828e..b34c75c1c73 100644 --- a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go @@ -295,6 +295,23 @@ func (in *ConditionCheck) DeepCopy() *ConditionCheck { func (in *ConditionCheckStatus) DeepCopyInto(out *ConditionCheckStatus) { *out = *in in.Status.DeepCopyInto(&out.Status) + in.ConditionCheckStatusFields.DeepCopyInto(&out.ConditionCheckStatusFields) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionCheckStatus. +func (in *ConditionCheckStatus) DeepCopy() *ConditionCheckStatus { + if in == nil { + return nil + } + out := new(ConditionCheckStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConditionCheckStatusFields) DeepCopyInto(out *ConditionCheckStatusFields) { + *out = *in if in.StartTime != nil { in, out := &in.StartTime, &out.StartTime *out = (*in).DeepCopy() @@ -307,12 +324,12 @@ func (in *ConditionCheckStatus) DeepCopyInto(out *ConditionCheckStatus) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionCheckStatus. -func (in *ConditionCheckStatus) DeepCopy() *ConditionCheckStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionCheckStatusFields. +func (in *ConditionCheckStatusFields) DeepCopy() *ConditionCheckStatusFields { if in == nil { return nil } - out := new(ConditionCheckStatus) + out := new(ConditionCheckStatusFields) in.DeepCopyInto(out) return out } @@ -985,6 +1002,23 @@ func (in *PipelineRunSpecServiceAccountName) DeepCopy() *PipelineRunSpecServiceA func (in *PipelineRunStatus) DeepCopyInto(out *PipelineRunStatus) { *out = *in in.Status.DeepCopyInto(&out.Status) + in.PipelineRunStatusFields.DeepCopyInto(&out.PipelineRunStatusFields) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineRunStatus. +func (in *PipelineRunStatus) DeepCopy() *PipelineRunStatus { + if in == nil { + return nil + } + out := new(PipelineRunStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PipelineRunStatusFields) DeepCopyInto(out *PipelineRunStatusFields) { + *out = *in if in.StartTime != nil { in, out := &in.StartTime, &out.StartTime *out = (*in).DeepCopy() @@ -1011,12 +1045,12 @@ func (in *PipelineRunStatus) DeepCopyInto(out *PipelineRunStatus) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineRunStatus. -func (in *PipelineRunStatus) DeepCopy() *PipelineRunStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineRunStatusFields. +func (in *PipelineRunStatusFields) DeepCopy() *PipelineRunStatusFields { if in == nil { return nil } - out := new(PipelineRunStatus) + out := new(PipelineRunStatusFields) in.DeepCopyInto(out) return out } @@ -1734,6 +1768,23 @@ func (in *TaskRunSpec) DeepCopy() *TaskRunSpec { func (in *TaskRunStatus) DeepCopyInto(out *TaskRunStatus) { *out = *in in.Status.DeepCopyInto(&out.Status) + in.TaskRunStatusFields.DeepCopyInto(&out.TaskRunStatusFields) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskRunStatus. +func (in *TaskRunStatus) DeepCopy() *TaskRunStatus { + if in == nil { + return nil + } + out := new(TaskRunStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskRunStatusFields) DeepCopyInto(out *TaskRunStatusFields) { + *out = *in if in.StartTime != nil { in, out := &in.StartTime, &out.StartTime *out = (*in).DeepCopy() @@ -1776,12 +1827,12 @@ func (in *TaskRunStatus) DeepCopyInto(out *TaskRunStatus) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskRunStatus. -func (in *TaskRunStatus) DeepCopy() *TaskRunStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskRunStatusFields. +func (in *TaskRunStatusFields) DeepCopy() *TaskRunStatusFields { if in == nil { return nil } - out := new(TaskRunStatus) + out := new(TaskRunStatusFields) in.DeepCopyInto(out) return out } diff --git a/pkg/pod/status_test.go b/pkg/pod/status_test.go index a1ae052d6df..74ae37dafbd 100644 --- a/pkg/pod/status_test.go +++ b/pkg/pod/status_test.go @@ -49,8 +49,10 @@ func TestMakeTaskRunStatus(t *testing.T) { Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{}, + Sidecars: []v1alpha1.SidecarState{}, + }, }, }, { desc: "ignore-creds-init", @@ -73,15 +75,17 @@ func TestMakeTaskRunStatus(t *testing.T) { Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - Steps: []v1alpha1.StepState{{ - ContainerState: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ - ExitCode: 123, - }}, - Name: "state-name", - ContainerName: "step-state-name", - }}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{{ + ContainerState: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ + ExitCode: 123, + }}, + Name: "state-name", + ContainerName: "step-state-name", + }}, + Sidecars: []v1alpha1.SidecarState{}, + }, }, }, { desc: "ignore-init-containers", @@ -107,16 +111,18 @@ func TestMakeTaskRunStatus(t *testing.T) { Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - Steps: []v1alpha1.StepState{{ - ContainerState: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ - ExitCode: 123, - }}, - Name: "state-name", - ContainerName: "step-state-name", - ImageID: "image-id", - }}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{{ + ContainerState: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ + ExitCode: 123, + }}, + Name: "state-name", + ContainerName: "step-state-name", + ImageID: "image-id", + }}, + Sidecars: []v1alpha1.SidecarState{}, + }, }, }, { desc: "success", @@ -141,18 +147,20 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "All Steps have completed executing", }}, }, - Steps: []v1alpha1.StepState{{ - ContainerState: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ - ExitCode: 0, - }}, - Name: "step-push", - ContainerName: "step-step-push", - ImageID: "image-id", - }}, - Sidecars: []v1alpha1.SidecarState{}, - // We don't actually care about the time, just that it's not nil - CompletionTime: &metav1.Time{Time: time.Now()}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{{ + ContainerState: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ + ExitCode: 0, + }}, + Name: "step-push", + ContainerName: "step-step-push", + ImageID: "image-id", + }}, + Sidecars: []v1alpha1.SidecarState{}, + // We don't actually care about the time, just that it's not nil + CompletionTime: &metav1.Time{Time: time.Now()}, + }, }, }, { desc: "running", @@ -169,14 +177,16 @@ func TestMakeTaskRunStatus(t *testing.T) { Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - Steps: []v1alpha1.StepState{{ - ContainerState: corev1.ContainerState{ - Running: &corev1.ContainerStateRunning{}, - }, - Name: "running-step", - ContainerName: "step-running-step", - }}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{{ + ContainerState: corev1.ContainerState{ + Running: &corev1.ContainerStateRunning{}, + }, + Name: "running-step", + ContainerName: "step-running-step", + }}, + Sidecars: []v1alpha1.SidecarState{}, + }, }, }, { desc: "failure-terminated", @@ -205,19 +215,21 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: `"step-failure" exited with code 123 (image: "image-id"); for logs run: kubectl -n foo logs pod -c step-failure`, }}, }, - Steps: []v1alpha1.StepState{{ - ContainerState: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ - ExitCode: 123, - }}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{{ + ContainerState: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ + ExitCode: 123, + }}, - Name: "failure", - ContainerName: "step-failure", - ImageID: "image-id", - }}, - Sidecars: []v1alpha1.SidecarState{}, - // We don't actually care about the time, just that it's not nil - CompletionTime: &metav1.Time{Time: time.Now()}, + Name: "failure", + ContainerName: "step-failure", + ImageID: "image-id", + }}, + Sidecars: []v1alpha1.SidecarState{}, + // We don't actually care about the time, just that it's not nil + CompletionTime: &metav1.Time{Time: time.Now()}, + }, }, }, { desc: "failure-message", @@ -234,10 +246,12 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "boom", }}, }, - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, - // We don't actually care about the time, just that it's not nil - CompletionTime: &metav1.Time{Time: time.Now()}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{}, + Sidecars: []v1alpha1.SidecarState{}, + // We don't actually care about the time, just that it's not nil + CompletionTime: &metav1.Time{Time: time.Now()}, + }, }, }, { desc: "failure-unspecified", @@ -251,10 +265,12 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "build failed for unspecified reasons.", }}, }, - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, - // We don't actually care about the time, just that it's not nil - CompletionTime: &metav1.Time{Time: time.Now()}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{}, + Sidecars: []v1alpha1.SidecarState{}, + // We don't actually care about the time, just that it's not nil + CompletionTime: &metav1.Time{Time: time.Now()}, + }, }, }, { desc: "pending-waiting-message", @@ -281,16 +297,18 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: `build step "step-status-name" is pending with reason "i'm pending"`, }}, }, - Steps: []v1alpha1.StepState{{ - ContainerState: corev1.ContainerState{ - Waiting: &corev1.ContainerStateWaiting{ - Message: "i'm pending", + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{{ + ContainerState: corev1.ContainerState{ + Waiting: &corev1.ContainerStateWaiting{ + Message: "i'm pending", + }, }, - }, - Name: "status-name", - ContainerName: "step-status-name", - }}, - Sidecars: []v1alpha1.SidecarState{}, + Name: "status-name", + ContainerName: "step-status-name", + }}, + Sidecars: []v1alpha1.SidecarState{}, + }, }, }, { desc: "pending-pod-condition", @@ -311,8 +329,10 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: `pod status "the type":"Unknown"; message: "the message"`, }}, }, - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{}, + Sidecars: []v1alpha1.SidecarState{}, + }, }, }, { desc: "pending-message", @@ -329,8 +349,10 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "pod status message", }}, }, - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{}, + Sidecars: []v1alpha1.SidecarState{}, + }, }, }, { desc: "pending-no-message", @@ -344,8 +366,10 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "Pending", }}, }, - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{}, + Sidecars: []v1alpha1.SidecarState{}, + }, }, }, { desc: "pending-not-enough-node-resources", @@ -365,8 +389,10 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "TaskRun Pod exceeded available resources", }}, }, - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{}, + Sidecars: []v1alpha1.SidecarState{}, + }, }, }, { desc: "with-sidecar-running", @@ -390,17 +416,19 @@ func TestMakeTaskRunStatus(t *testing.T) { Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - Steps: []v1alpha1.StepState{{ - ContainerState: corev1.ContainerState{ - Running: &corev1.ContainerStateRunning{}, - }, - Name: "running-step", - ContainerName: "step-running-step", - }}, - Sidecars: []v1alpha1.SidecarState{{ - Name: "running", - ImageID: "image-id", - }}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{{ + ContainerState: corev1.ContainerState{ + Running: &corev1.ContainerStateRunning{}, + }, + Name: "running-step", + ContainerName: "step-running-step", + }}, + Sidecars: []v1alpha1.SidecarState{{ + Name: "running", + ImageID: "image-id", + }}, + }, }, }} { t.Run(c.desc, func(t *testing.T) { diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index bf8ca0f10f6..eacd4c54d46 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -466,18 +466,21 @@ func TestUpdateTaskRunsState(t *testing.T) { expectedTaskRunsStatus["test-pipeline-run-success-unit-test-1"] = &v1alpha1.PipelineRunTaskRunStatus{ PipelineTaskName: "unit-test-1", Status: &v1alpha1.TaskRunStatus{ - Steps: []v1alpha1.StepState{{ - ContainerState: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ExitCode: 0}, - }, - }}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Steps: []v1alpha1.StepState{{ + ContainerState: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ExitCode: 0}, + }, + }}}, Status: duckv1beta1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded}}, }, }, } expectedPipelineRunStatus := v1alpha1.PipelineRunStatus{ - TaskRuns: expectedTaskRunsStatus, + PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + TaskRuns: expectedTaskRunsStatus, + }, } state := []*resources.ResolvedPipelineRunTask{{ @@ -531,8 +534,10 @@ func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { successConditionCheckStatus := &v1alpha1.PipelineRunConditionCheckStatus{ ConditionName: successCondition.Name, Status: &v1alpha1.ConditionCheckStatus{ - Check: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ExitCode: 0}, + ConditionCheckStatusFields: v1alpha1.ConditionCheckStatusFields{ + Check: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ExitCode: 0}, + }, }, Status: duckv1beta1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue}}, @@ -542,8 +547,10 @@ func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { failingConditionCheckStatus := &v1alpha1.PipelineRunConditionCheckStatus{ ConditionName: failingCondition.Name, Status: &v1alpha1.ConditionCheckStatus{ - Check: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ExitCode: 127}, + ConditionCheckStatusFields: v1alpha1.ConditionCheckStatusFields{ + Check: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ExitCode: 127}, + }, }, Status: duckv1beta1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse}}, diff --git a/pkg/reconciler/pipelinerun/resources/conditionresolution.go b/pkg/reconciler/pipelinerun/resources/conditionresolution.go index b6396039a8e..c271426b783 100644 --- a/pkg/reconciler/pipelinerun/resources/conditionresolution.go +++ b/pkg/reconciler/pipelinerun/resources/conditionresolution.go @@ -162,11 +162,13 @@ func (rcc *ResolvedConditionCheck) NewConditionCheckStatus() *v1alpha1.Condition } return &v1alpha1.ConditionCheckStatus{ - Status: trs.Status, - PodName: trs.PodName, - StartTime: trs.StartTime, - CompletionTime: trs.CompletionTime, - Check: checkStep, + Status: trs.Status, + ConditionCheckStatusFields: v1alpha1.ConditionCheckStatusFields{ + PodName: trs.PodName, + StartTime: trs.StartTime, + CompletionTime: trs.CompletionTime, + Check: checkStep, + }, } } diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go index b9ebd69176f..d9bd57d1157 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go @@ -1341,7 +1341,9 @@ func TestResolvePipelineRun_withExistingTaskRuns(t *testing.T) { Name: "pipelinerun", }, Status: v1alpha1.PipelineRunStatus{ - TaskRuns: taskrunStatus, + PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + TaskRuns: taskrunStatus, + }, }, } @@ -1647,8 +1649,10 @@ func TestResolveConditionCheck_UseExistingConditionCheckName(t *testing.T) { Name: "pipelinerun", }, Status: v1alpha1.PipelineRunStatus{ - Status: duckv1beta1.Status{}, - TaskRuns: trStatus, + Status: duckv1beta1.Status{}, + PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + TaskRuns: trStatus, + }, }, } diff --git a/pkg/reconciler/taskrun/taskrun_test.go b/pkg/reconciler/taskrun/taskrun_test.go index 3e745a27351..25248a30412 100644 --- a/pkg/reconciler/taskrun/taskrun_test.go +++ b/pkg/reconciler/taskrun/taskrun_test.go @@ -1225,7 +1225,9 @@ func TestReconcilePodUpdateStatus(t *testing.T) { t.Fatalf("MakePod: %v", err) } taskRun.Status = v1alpha1.TaskRunStatus{ - PodName: pod.Name, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + PodName: pod.Name, + }, } d := test.Data{ TaskRuns: []*v1alpha1.TaskRun{taskRun}, diff --git a/test/builder/pipeline_test.go b/test/builder/pipeline_test.go index 35b76775a59..3049a6eb0c3 100644 --- a/test/builder/pipeline_test.go +++ b/test/builder/pipeline_test.go @@ -174,10 +174,12 @@ func TestPipelineRun(t *testing.T) { Status: duckv1beta1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded}}, }, - StartTime: &metav1.Time{Time: startTime}, - CompletionTime: &metav1.Time{Time: completedTime}, - TaskRuns: map[string]*v1alpha1.PipelineRunTaskRunStatus{ - "trname": {PipelineTaskName: "task-1"}, + PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + StartTime: &metav1.Time{Time: startTime}, + CompletionTime: &metav1.Time{Time: completedTime}, + TaskRuns: map[string]*v1alpha1.PipelineRunTaskRunStatus{ + "trname": {PipelineTaskName: "task-1"}, + }, }, }, } @@ -247,10 +249,12 @@ func TestPipelineRunWithResourceSpec(t *testing.T) { Status: duckv1beta1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded}}, }, - StartTime: &metav1.Time{Time: startTime}, - CompletionTime: &metav1.Time{Time: completedTime}, - TaskRuns: map[string]*v1alpha1.PipelineRunTaskRunStatus{ - "trname": {PipelineTaskName: "task-1"}, + PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + StartTime: &metav1.Time{Time: startTime}, + CompletionTime: &metav1.Time{Time: completedTime}, + TaskRuns: map[string]*v1alpha1.PipelineRunTaskRunStatus{ + "trname": {PipelineTaskName: "task-1"}, + }, }, }, } diff --git a/test/builder/task_test.go b/test/builder/task_test.go index c426ce00253..f8669075335 100644 --- a/test/builder/task_test.go +++ b/test/builder/task_test.go @@ -230,13 +230,15 @@ func TestTaskRunWithTaskRef(t *testing.T) { }, }, Status: v1alpha1.TaskRunStatus{ - PodName: "my-pod-name", Status: duckv1beta1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded}}, }, - Steps: []v1alpha1.StepState{{ContainerState: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ExitCode: 127}, - }}}, + TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + PodName: "my-pod-name", + Steps: []v1alpha1.StepState{{ContainerState: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ExitCode: 127}, + }}}, + }, }, } if d := cmp.Diff(expectedTaskRun, taskRun); d != "" {