ParseAlert returns a slice of suggestions for the given Vale alert.
(s string, cfg *core.Config)
| 35 | |
| 36 | // ParseAlert returns a slice of suggestions for the given Vale alert. |
| 37 | func ParseAlert(s string, cfg *core.Config) (Solution, error) { |
| 38 | body := core.Alert{} |
| 39 | resp := Solution{} |
| 40 | |
| 41 | err := json.Unmarshal([]byte(s), &body) |
| 42 | if err != nil { |
| 43 | return Solution{}, err |
| 44 | } |
| 45 | |
| 46 | suggestions, err := FixAlert(body, cfg) |
| 47 | if err != nil { |
| 48 | resp.Error = err.Error() |
| 49 | } |
| 50 | resp.Suggestions = suggestions |
| 51 | |
| 52 | return resp, nil |
| 53 | } |
| 54 | |
| 55 | func FixAlert(alert core.Alert, cfg *core.Config) ([]string, error) { |
| 56 | action := alert.Action.Name |