worker/osbuild: move target errors to detail of job error
Add a new worker client error type `ErrorTargetError` representing that at least one of job targets failed. The actual target errors are added to the job detail. Add a new `OSBuildJobResult.TargetErrors()` method for gathering a slice of target errors contained within an `OSBuildJobResult` instance. Cover the method with unit test.
This commit is contained in:
parent
20cb2e1b2c
commit
6dcadc9d20
5 changed files with 112 additions and 3 deletions
|
|
@ -46,6 +46,25 @@ type OSBuildJobResult struct {
|
|||
JobResult
|
||||
}
|
||||
|
||||
// TargetErrors returns a slice of *clienterrors.Error gathered
|
||||
// from the job result's target results. If there were no target errors
|
||||
// then the returned slice will be empty.
|
||||
func (j *OSBuildJobResult) TargetErrors() []*clienterrors.Error {
|
||||
targetErrors := []*clienterrors.Error{}
|
||||
|
||||
for _, targetResult := range j.TargetResults {
|
||||
if targetResult.TargetError != nil {
|
||||
targetError := targetResult.TargetError
|
||||
// Add the target name to the error details, because the error reason
|
||||
// may not contain any information to determine the type of the target
|
||||
// which failed.
|
||||
targetErrors = append(targetErrors, clienterrors.WorkerClientError(targetError.ID, targetError.Reason, targetResult.Name))
|
||||
}
|
||||
}
|
||||
|
||||
return targetErrors
|
||||
}
|
||||
|
||||
type KojiInitJob struct {
|
||||
Server string `json:"server"`
|
||||
Name string `json:"name"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue