From 78c7a32549cf1018df505f41b4b7c17fa2d949f5 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 --- deploy/crds/shipwright.io_buildruns.yaml | 20 +++++++++++------- pkg/apis/build/v1alpha1/buildrun_types.go | 7 +++++++ .../build/v1alpha1/zz_generated.deepcopy.go | 21 +++++++++++++++++++ pkg/reconciler/buildrun/buildrun.go | 7 +++++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/deploy/crds/shipwright.io_buildruns.yaml b/deploy/crds/shipwright.io_buildruns.yaml index ffeda8a40a..6182a77e3b 100644 --- a/deploy/crds/shipwright.io_buildruns.yaml +++ b/deploy/crds/shipwright.io_buildruns.yaml @@ -361,18 +361,22 @@ spec: for executing this BuildRun. \n TODO: This should be called something like \"TaskRunName\"" type: string - reason: - description: "The Succeeded reason of the TaskRun \n Deprecated: Use - Conditions instead. This will be removed in a future release." - type: string + results: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array startTime: description: StartTime is the time the build is actually started. format: date-time type: string - succeeded: - description: "The Succeeded status of the TaskRun \n Deprecated: Use - Conditions instead. This will be removed in a future release." - type: string type: object type: object served: true 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