target: extend TargetResult with TargetError
This will enable reporting of target-specific errors from jobs, once they'll support multiple targets. Target errors are currently reported via `JobResult.JobError`.
This commit is contained in:
parent
59ded68457
commit
6f13db5b92
1 changed files with 9 additions and 4 deletions
|
|
@ -3,11 +3,14 @@ package target
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/worker/clienterrors"
|
||||
)
|
||||
|
||||
type TargetResult struct {
|
||||
Name TargetName `json:"name"`
|
||||
Options TargetResultOptions `json:"options"`
|
||||
TargetError *clienterrors.Error `json:"target_error,omitempty"`
|
||||
}
|
||||
|
||||
func newTargetResult(name TargetName, options TargetResultOptions) *TargetResult {
|
||||
|
|
@ -24,6 +27,7 @@ type TargetResultOptions interface {
|
|||
type rawTargetResult struct {
|
||||
Name TargetName `json:"name"`
|
||||
Options json.RawMessage `json:"options"`
|
||||
TargetError *clienterrors.Error `json:"target_error,omitempty"`
|
||||
}
|
||||
|
||||
func (targetResult *TargetResult) UnmarshalJSON(data []byte) error {
|
||||
|
|
@ -39,6 +43,7 @@ func (targetResult *TargetResult) UnmarshalJSON(data []byte) error {
|
|||
|
||||
targetResult.Name = rawTR.Name
|
||||
targetResult.Options = options
|
||||
targetResult.TargetError = rawTR.TargetError
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue