-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
pipeline_job_spec_errors_controller.go
42 lines (35 loc) · 1.21 KB
/
pipeline_job_spec_errors_controller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package web
import (
"database/sql"
"net/http"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/smartcontractkit/chainlink/v2/core/logger/audit"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
)
// PipelineJobSpecErrorsController manages PipelineJobSpecError requests
type PipelineJobSpecErrorsController struct {
App chainlink.Application
}
// Destroy deletes a PipelineJobSpecError record from the database, effectively
// silencing the error notification
func (psec *PipelineJobSpecErrorsController) Destroy(c *gin.Context) {
jobSpec := job.SpecError{}
err := jobSpec.SetID(c.Param("ID"))
if err != nil {
jsonAPIError(c, http.StatusUnprocessableEntity, err)
return
}
err = psec.App.JobORM().DismissError(c.Request.Context(), jobSpec.ID)
if errors.Is(err, sql.ErrNoRows) {
jsonAPIError(c, http.StatusNotFound, errors.New("PipelineJobSpecError not found"))
return
}
if err != nil {
jsonAPIError(c, http.StatusInternalServerError, err)
return
}
psec.App.GetAuditLogger().Audit(audit.JobErrorDismissed, map[string]interface{}{"id": jobSpec.ID})
jsonAPIResponseWithStatus(c, nil, "job", http.StatusNoContent)
}