@@ -249,47 +249,9 @@ func (api *api) provisionerJobResourcesByID(rw http.ResponseWriter, r *http.Requ
249
249
return
250
250
}
251
251
resources , err := api .Database .GetProvisionerJobResourcesByJobID (r .Context (), job .ID )
252
- if err != nil {
253
- httpapi .Write (rw , http .StatusInternalServerError , httpapi.Response {
254
- Message : fmt .Sprintf ("get provisioner job resources: %s" , err ),
255
- })
256
- return
257
- }
258
- apiResources := make ([]ProvisionerJobResource , 0 )
259
- for _ , resource := range resources {
260
- if ! resource .AgentID .Valid {
261
- apiResources = append (apiResources , convertProvisionerJobResource (resource , nil ))
262
- continue
263
- }
264
- agent , err := api .Database .GetProvisionerJobAgentByResourceID (r .Context (), resource .ID )
265
- if err != nil {
266
- httpapi .Write (rw , http .StatusInternalServerError , httpapi.Response {
267
- Message : fmt .Sprintf ("get provisioner job agent: %s" , err ),
268
- })
269
- return
270
- }
271
- apiAgent , err := convertProvisionerJobAgent (agent )
272
- if err != nil {
273
- httpapi .Write (rw , http .StatusInternalServerError , httpapi.Response {
274
- Message : fmt .Sprintf ("convert provisioner job agent: %s" , err ),
275
- })
276
- return
277
- }
278
- apiResources = append (apiResources , convertProvisionerJobResource (resource , & apiAgent ))
279
- }
280
- render .Status (r , http .StatusOK )
281
- render .JSON (rw , r , apiResources )
282
- }
283
-
284
- func (api * api ) provisionerJobResourceByID (rw http.ResponseWriter , r * http.Request ) {
285
- job := httpmw .ProvisionerJobParam (r )
286
- if ! convertProvisionerJob (job ).Status .Completed () {
287
- httpapi .Write (rw , http .StatusPreconditionFailed , httpapi.Response {
288
- Message : "Job hasn't completed!" ,
289
- })
290
- return
252
+ if errors .Is (err , sql .ErrNoRows ) {
253
+ err = nil
291
254
}
292
- resources , err := api .Database .GetProvisionerJobResourcesByJobID (r .Context (), job .ID )
293
255
if err != nil {
294
256
httpapi .Write (rw , http .StatusInternalServerError , httpapi.Response {
295
257
Message : fmt .Sprintf ("get provisioner job resources: %s" , err ),
0 commit comments