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

Function sendDockerData

agent-source-code/cmd/patchmon-agent/commands/report.go:419–457  ·  view source on GitHub ↗

sendDockerData sends Docker integration data to server

(httpClient *client.Client, integrationData *models.IntegrationData, hostname, machineID string)

Source from the content-addressed store, hash-verified

417
418// sendDockerData sends Docker integration data to server
419func sendDockerData(httpClient *client.Client, integrationData *models.IntegrationData, hostname, machineID string) {
420 // Extract Docker data from integration data
421 dockerData, ok := integrationData.Data.(*models.DockerData)
422 if !ok {
423 logger.Warn("Failed to extract Docker data from integration")
424 return
425 }
426
427 payload := &models.DockerPayload{
428 DockerData: *dockerData,
429 Hostname: hostname,
430 MachineID: machineID,
431 AgentVersion: pkgversion.Version,
432 }
433
434 logger.WithFields(logrus.Fields{
435 "containers": len(dockerData.Containers),
436 "images": len(dockerData.Images),
437 "volumes": len(dockerData.Volumes),
438 "networks": len(dockerData.Networks),
439 "updates": len(dockerData.Updates),
440 }).Info("Sending Docker data to server...")
441 ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
442 defer cancel()
443
444 response, err := httpClient.SendDockerData(ctx, payload)
445 if err != nil {
446 logger.WithError(err).Warn("Failed to send Docker data (will retry on next report)")
447 return
448 }
449
450 logger.WithFields(logrus.Fields{
451 "containers": response.ContainersReceived,
452 "images": response.ImagesReceived,
453 "volumes": response.VolumesReceived,
454 "networks": response.NetworksReceived,
455 "updates": response.UpdatesFound,
456 }).Info("Docker data sent successfully")
457}
458
459// sendComplianceData sends compliance scan data to server
460func sendComplianceData(httpClient *client.Client, integrationData *models.IntegrationData, hostname, machineID, scanType string) {

Callers 1

sendIntegrationDataFunction · 0.85

Calls 1

SendDockerDataMethod · 0.80

Tested by

no test coverage detected