From ee729dc4ce3227bac217d7cb3fccd81feab44af2 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Mon, 24 Jul 2023 13:07:01 -0700 Subject: [PATCH] Flattened task/report. Signed-off-by: Jeff Ortel --- api/task.go | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/api/task.go b/api/task.go index 5552fe61..e732f742 100644 --- a/api/task.go +++ b/api/task.go @@ -518,15 +518,15 @@ type Task struct { Application *Ref `json:"application,omitempty" yaml:",omitempty"` State string `json:"state"` Image string `json:"image,omitempty" yaml:",omitempty"` - Bucket *Ref `json:"bucket,omitempty" yaml:",omitempty"` - Purged bool `json:"purged,omitempty" yaml:",omitempty"` - Started *time.Time `json:"started,omitempty" yaml:",omitempty"` - Terminated *time.Time `json:"terminated,omitempty" yaml:",omitempty"` - Errors []TaskError `json:"errors,omitempty" yaml:",omitempty"` Pod string `json:"pod,omitempty" yaml:",omitempty"` Retries int `json:"retries,omitempty" yaml:",omitempty"` + Started *time.Time `json:"started,omitempty" yaml:",omitempty"` + Terminated *time.Time `json:"terminated,omitempty" yaml:",omitempty"` Canceled bool `json:"canceled,omitempty" yaml:",omitempty"` - Report *TaskReport `json:"report,omitempty" yaml:",omitempty"` + Bucket *Ref `json:"bucket,omitempty" yaml:",omitempty"` + Purged bool `json:"purged,omitempty" yaml:",omitempty"` + Errors []TaskError `json:"errors,omitempty" yaml:",omitempty"` + Activity []string `json:"activity,omitempty" yaml:",omitempty"` } // @@ -549,17 +549,25 @@ func (r *Task) With(m *model.Task) { r.Retries = m.Retries r.Canceled = m.Canceled _ = json.Unmarshal(m.Data, &r.Data) - if m.Report != nil { - report := &TaskReport{} - report.With(m.Report) - r.Report = report - } if m.TTL != nil { _ = json.Unmarshal(m.TTL, &r.TTL) } if m.Errors != nil { _ = json.Unmarshal(m.Errors, &r.Errors) } + if m.Report != nil { + report := &TaskReport{} + report.With(m.Report) + r.Activity = report.Activity + r.Errors = append(report.Errors, r.Errors...) + switch r.State { + case tasking.Succeeded: + switch report.Status { + case tasking.Failed: + r.State = report.Status + } + } + } } //