From 4777c31043bcee442e7b91e5ece663f0c243261d Mon Sep 17 00:00:00 2001 From: Enrique Encalada Date: Wed, 26 May 2021 22:48:37 +0200 Subject: [PATCH] WIP add buildrun results list under status --- pkg/apis/build/v1alpha1/buildrun_types.go | 7 +++++++ .../build/v1alpha1/zz_generated.deepcopy.go | 21 +++++++++++++++++++ pkg/reconciler/buildrun/buildrun.go | 7 +++++++ 3 files changed, 35 insertions(+) diff --git a/pkg/apis/build/v1alpha1/buildrun_types.go b/pkg/apis/build/v1alpha1/buildrun_types.go index b7de82479b..6ef3462a53 100644 --- a/pkg/apis/build/v1alpha1/buildrun_types.go +++ b/pkg/apis/build/v1alpha1/buildrun_types.go @@ -54,6 +54,8 @@ type BuildRunStatus struct { // +optional LatestTaskRunRef *string `json:"latestTaskRunRef,omitempty"` + BuildResults []BuildResult `json:"results,omitempty"` + // StartTime is the time the build is actually started. // +optional StartTime *metav1.Time `json:"startTime,omitempty"` @@ -71,6 +73,11 @@ type BuildRunStatus struct { FailedAt *FailedAt `json:"failedAt,omitempty"` } +type BuildResult struct { + Name string `json:"name"` + Value string `json:"value"` +} + // FailedAt describes the location where the failure happened type FailedAt struct { Pod string `json:"pod,omitempty"` diff --git a/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go index 2a5e778982..44cf6f870f 100644 --- a/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go @@ -91,6 +91,22 @@ func (in *BuildRef) DeepCopy() *BuildRef { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BuildResult) DeepCopyInto(out *BuildResult) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildResult. +func (in *BuildResult) DeepCopy() *BuildResult { + if in == nil { + return nil + } + out := new(BuildResult) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BuildRun) DeepCopyInto(out *BuildRun) { *out = *in @@ -203,6 +219,11 @@ func (in *BuildRunStatus) DeepCopyInto(out *BuildRunStatus) { *out = new(string) **out = **in } + if in.BuildResults != nil { + in, out := &in.BuildResults, &out.BuildResults + *out = make([]BuildResult, len(*in)) + copy(*out, *in) + } if in.StartTime != nil { in, out := &in.StartTime, &out.StartTime *out = (*in).DeepCopy() diff --git a/pkg/reconciler/buildrun/buildrun.go b/pkg/reconciler/buildrun/buildrun.go index 3693422f01..3dd6b09eb6 100644 --- a/pkg/reconciler/buildrun/buildrun.go +++ b/pkg/reconciler/buildrun/buildrun.go @@ -231,6 +231,13 @@ func (r *ReconcileBuildRun) Reconcile(request reconcile.Request) (reconcile.Resu } else if apierrors.IsNotFound(err) { return reconcile.Result{}, nil } + // TODO: quick test + for _, r := range lastTaskRun.Status.TaskRunResults { + buildRun.Status.BuildResults = append(buildRun.Status.BuildResults, buildv1alpha1.BuildResult{ + Name: r.Name, + Value: r.Value, + }) + } // Check if the BuildRun is already finished, this happens if the build controller is restarted. // It then reconciles all TaskRuns. This is valuable if the build controller was down while the TaskRun