worker: Remove ellipsis operator from clienterrors.Error
The ellipsis operator was used as a hack to not need to pass any details as an argument, but it makes what the end object will actually look like less obvious. It also makes it impossible to pass an array to details without getting a nested array. Fixes #2874
This commit is contained in:
parent
1fb6a574cb
commit
111feda1f5
14 changed files with 103 additions and 108 deletions
|
|
@ -280,7 +280,7 @@ func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID
|
|||
|
||||
if len(dynArgs) == 0 {
|
||||
reason := "No dynamic arguments"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorNoDynamicArgs, reason)
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorNoDynamicArgs, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -288,35 +288,35 @@ func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID
|
|||
err = json.Unmarshal(dynArgs[0], &depsolveResults)
|
||||
if err != nil {
|
||||
reason := "Error parsing dynamic arguments"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, reason)
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = workers.DepsolveJobInfo(depsolveJobID, &depsolveResults)
|
||||
if err != nil {
|
||||
reason := "Error reading depsolve status"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason)
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if jobErr := depsolveResults.JobError; jobErr != nil {
|
||||
if jobErr.ID == clienterrors.ErrorDNFDepsolveError || jobErr.ID == clienterrors.ErrorDNFMarkingErrors {
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency input, bad package set requested")
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency input, bad package set requested", nil)
|
||||
return
|
||||
}
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency")
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency", nil)
|
||||
return
|
||||
}
|
||||
|
||||
if len(depsolveResults.PackageSpecs) == 0 {
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyPackageSpecs, "Received empty package specs")
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyPackageSpecs, "Received empty package specs", nil)
|
||||
return
|
||||
}
|
||||
|
||||
manifest, err := imageType.Manifest(b, options, repos, depsolveResults.PackageSpecs, nil, seed)
|
||||
if err != nil {
|
||||
reason := "Error generating manifest"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestGeneration, reason)
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestGeneration, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
{
|
||||
initResult: worker.KojiInitJobResult{
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiInit, "Koji init error"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiInit, "Koji init error", nil),
|
||||
},
|
||||
},
|
||||
buildResult: worker.OSBuildJobResult{
|
||||
|
|
@ -205,7 +205,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
Success: true,
|
||||
},
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Koji build error"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Koji build error", nil),
|
||||
},
|
||||
},
|
||||
composeReplyCode: http.StatusCreated,
|
||||
|
|
@ -215,7 +215,6 @@ func TestKojiCompose(t *testing.T) {
|
|||
"image_status": {
|
||||
"status": "failure",
|
||||
"error": {
|
||||
"details": null,
|
||||
"id": 10,
|
||||
"reason": "Koji build error"
|
||||
}
|
||||
|
|
@ -224,7 +223,6 @@ func TestKojiCompose(t *testing.T) {
|
|||
{
|
||||
"status": "failure",
|
||||
"error": {
|
||||
"details": null,
|
||||
"id": 10,
|
||||
"reason": "Koji build error"
|
||||
}
|
||||
|
|
@ -299,7 +297,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
},
|
||||
finalizeResult: worker.KojiFinalizeJobResult{
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Koji finalize error"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Koji finalize error", nil),
|
||||
},
|
||||
},
|
||||
composeReplyCode: http.StatusCreated,
|
||||
|
|
@ -346,6 +344,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
clienterrors.WorkerClientError(
|
||||
clienterrors.ErrorDNFOtherError,
|
||||
"DNF Error",
|
||||
nil,
|
||||
),
|
||||
),
|
||||
},
|
||||
|
|
@ -359,7 +358,6 @@ func TestKojiCompose(t *testing.T) {
|
|||
"details": [
|
||||
{
|
||||
"id": 22,
|
||||
"details": null,
|
||||
"reason": "DNF Error"
|
||||
}
|
||||
],
|
||||
|
|
@ -374,7 +372,6 @@ func TestKojiCompose(t *testing.T) {
|
|||
"details": [
|
||||
{
|
||||
"id": 22,
|
||||
"details": null,
|
||||
"reason": "DNF Error"
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ func TestComposeJobError(t *testing.T) {
|
|||
}`, jobId, jobId))
|
||||
|
||||
jobErr := worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Error building image"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Error building image", nil),
|
||||
}
|
||||
jobResult, err := json.Marshal(worker.OSBuildJobResult{JobResult: jobErr})
|
||||
require.NoError(t, err)
|
||||
|
|
@ -835,9 +835,9 @@ func TestComposeDependencyError(t *testing.T) {
|
|||
}`, jobId, jobId))
|
||||
|
||||
jobErr := worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, "Manifest dependency failed"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, "Manifest dependency failed", nil),
|
||||
}
|
||||
jobErr.JobError.Details = clienterrors.WorkerClientError(clienterrors.ErrorDNFOtherError, "DNF Error")
|
||||
jobErr.JobError.Details = clienterrors.WorkerClientError(clienterrors.ErrorDNFOtherError, "DNF Error", nil)
|
||||
jobResult, err := json.Marshal(worker.OSBuildJobResult{JobResult: jobErr})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -851,7 +851,6 @@ func TestComposeDependencyError(t *testing.T) {
|
|||
"image_status": {
|
||||
"error": {
|
||||
"details": {
|
||||
"details": null,
|
||||
"id": 22,
|
||||
"reason": "DNF Error"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue