MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / GetRun

Method GetRun

server-source-code/internal/handler/patching.go:513–537  ·  view source on GitHub ↗

GetRun returns GET /patching/runs/:id.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

511
512// GetRun returns GET /patching/runs/:id.
513func (h *PatchingHandler) GetRun(w http.ResponseWriter, r *http.Request) {
514 id := chi.URLParam(r, "id")
515 if !isValidPatchUUID(id) {
516 JSON(w, http.StatusBadRequest, map[string]string{"error": "Invalid run ID"})
517 return
518 }
519 run, err := h.patchRuns.GetByID(r.Context(), id)
520 if err != nil || run == nil {
521 JSON(w, http.StatusNotFound, map[string]string{"error": "Patch run not found"})
522 return
523 }
524 resp := patchRunToResponse(run)
525 if host, err := h.hosts.GetByID(r.Context(), run.HostID); err == nil && host != nil {
526 if hosts, ok := resp["hosts"].(map[string]interface{}); ok {
527 hosts["awaiting_post_patch_report_run_id"] = host.AwaitingPostPatchReportRunID
528 // Expose the host's last inventory report timestamp so the
529 // frontend can tell when a post-patch report has arrived and
530 // swap the "awaiting" pill for a "received" pill.
531 if !host.LastUpdate.IsZero() {
532 hosts["last_update"] = host.LastUpdate.UTC().Format(time.RFC3339)
533 }
534 }
535 }
536 JSON(w, http.StatusOK, resp)
537}
538
539// ApproveRun handles POST /patching/runs/:id/approve.
540// Creates a NEW patch run (dry_run=false) linked to the validation run via validation_run_id.

Callers

nothing calls this directly

Calls 4

isValidPatchUUIDFunction · 0.85
patchRunToResponseFunction · 0.85
JSONFunction · 0.70
GetByIDMethod · 0.45

Tested by

no test coverage detected