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

Method RefreshDocker

server-source-code/internal/handler/hosts.go:583–614  ·  view source on GitHub ↗

RefreshDocker handles POST /hosts/:hostId/refresh-docker.

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

Source from the content-addressed store, hash-verified

581
582// RefreshDocker handles POST /hosts/:hostId/refresh-docker.
583func (h *HostsHandler) RefreshDocker(w http.ResponseWriter, r *http.Request) {
584 if h.queueClient == nil {
585 Error(w, http.StatusServiceUnavailable, "Queue service unavailable")
586 return
587 }
588 hostID := chi.URLParam(r, "hostId")
589 host, err := h.hosts.GetByID(r.Context(), hostID)
590 if err != nil || host == nil {
591 Error(w, http.StatusNotFound, "Host not found")
592 return
593 }
594 task, err := queue.NewDockerInventoryRefreshTask(host.ApiID, hostFromRequest(r))
595 if err != nil {
596 Error(w, http.StatusInternalServerError, "Failed to create Docker refresh task")
597 return
598 }
599 info, err := h.queueClient.Enqueue(task)
600 if err != nil {
601 Error(w, http.StatusInternalServerError, "Failed to refresh Docker inventory")
602 return
603 }
604 JSON(w, http.StatusOK, map[string]interface{}{
605 "success": true,
606 "message": "Docker inventory refresh queued",
607 "jobId": info.ID,
608 "host": map[string]interface{}{
609 "id": host.ID,
610 "friendlyName": host.FriendlyName,
611 "apiId": host.ApiID,
612 },
613 })
614}
615
616// ForceAgentUpdate handles POST /hosts/:hostId/force-agent-update.
617func (h *HostsHandler) ForceAgentUpdate(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 4

ErrorFunction · 0.85
hostFromRequestFunction · 0.85
JSONFunction · 0.70
GetByIDMethod · 0.45

Tested by

no test coverage detected