CI: install nodejs before checkout; recovery followup via ITILFollowup
ci / vet (pull_request) Successful in 1m42s

golang:alpine lacks node (actions/checkout 127). GLPI 11 rejects the
legacy /followup input shape -> item-endpoint first, legacy fallback;
solve no longer skipped when followup fails.
Ticket: https://projects.knownelement.com/issues/824
This commit is contained in:
2026-09-06 13:00:55 -05:00
parent 16519fd97f
commit bfd05f0064
4 changed files with 22 additions and 9 deletions
+19 -8
View File
@@ -131,14 +131,18 @@ func (g *glpiClient) openTicketFor(monitor string) (int, error) {
q.Set("criteria[1][field]", "12") // status
q.Set("criteria[1][searchtype]", "equals")
q.Set("criteria[1][value]", "notold")
var out []struct {
ID int `json:"2"`
var out struct {
Data []map[string]any `json:"data"`
}
if err := g.do("GET", "/search/Ticket?"+q.Encode(), nil, &out); err != nil {
return 0, err
}
if len(out) > 0 {
return out[0].ID, nil
for _, row := range out.Data {
if v, ok := row["2"]; ok {
var tid int
fmt.Sscanf(fmt.Sprint(v), "%d", &tid)
return tid, nil
}
}
return 0, nil
}
@@ -154,9 +158,17 @@ func (g *glpiClient) createTicket(name, content string) (int, error) {
}
func (g *glpiClient) followup(ticket int, content string) error {
return g.do("POST", "/followup", map[string]any{
"input": map[string]any{"itemtype": "Ticket", "items_id": ticket, "content": content},
// GLPI 11: followups live under the item endpoint; fall back to the
// legacy path when the item endpoint rejects the payload.
err := g.do("POST", fmt.Sprintf("/Ticket/%d/ITILFollowup", ticket), map[string]any{
"input": map[string]any{"content": content},
}, nil)
if err != nil {
return g.do("POST", "/followup", map[string]any{
"input": map[string]any{"itemtype": "Ticket", "items_id": ticket, "content": content},
}, nil)
}
return nil
}
type bridge struct {
@@ -210,8 +222,7 @@ func (b *bridge) handle(w http.ResponseWriter, r *http.Request) {
go func() {
fu := fmt.Sprintf("RECOVERY: monitor %s back UP at %s. Ticket auto-closing as solved with recovery evidence.", k.Monitor.Name, k.Heartbeat.Time)
if err := b.glpi.followup(tid, fu); err != nil {
log.Printf("followup failed: %v", err)
return
log.Printf("followup failed (continuing to solve): %v", err)
}
if err := b.glpi.do("POST", fmt.Sprintf("/Ticket/%d", tid), map[string]any{"input": map[string]any{"status": 11}}, nil); err != nil { // 11 = solved
log.Printf("solve failed: %v", err)