sendDockerData sends Docker integration data to server
(httpClient *client.Client, integrationData *models.IntegrationData, hostname, machineID string)
| 417 | |
| 418 | // sendDockerData sends Docker integration data to server |
| 419 | func 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 |
| 460 | func sendComplianceData(httpClient *client.Client, integrationData *models.IntegrationData, hostname, machineID, scanType string) { |
no test coverage detected