(r *db.GetPatchRunByIDRow)
| 1429 | } |
| 1430 | |
| 1431 | func patchRunToResponse(r *db.GetPatchRunByIDRow) map[string]interface{} { |
| 1432 | m := map[string]interface{}{ |
| 1433 | "id": r.ID, |
| 1434 | "host_id": r.HostID, |
| 1435 | "job_id": r.JobID, |
| 1436 | "patch_type": r.PatchType, |
| 1437 | "package_name": r.PackageName, |
| 1438 | "status": r.Status, |
| 1439 | "shell_output": r.ShellOutput, |
| 1440 | "error_message": r.ErrorMessage, |
| 1441 | "started_at": pgTimeToISO(r.StartedAt), |
| 1442 | "completed_at": pgTimeToISO(r.CompletedAt), |
| 1443 | "scheduled_at": pgTimeToISO(r.ScheduledAt), |
| 1444 | "created_at": pgTimeToISO(r.CreatedAt), |
| 1445 | "updated_at": pgTimeToISO(r.UpdatedAt), |
| 1446 | "triggered_by_username": r.TriggeredByUsername, |
| 1447 | "approved_by_username": r.ApprovedByUsername, |
| 1448 | "dry_run": r.DryRun, |
| 1449 | "validation_run_id": r.ValidationRunID, |
| 1450 | "policy_id": r.PolicyID, |
| 1451 | "policy_name": r.PolicyName, |
| 1452 | } |
| 1453 | if len(r.PolicySnapshot) > 0 { |
| 1454 | var snap map[string]interface{} |
| 1455 | if json.Unmarshal(r.PolicySnapshot, &snap) == nil { |
| 1456 | m["policy_snapshot"] = snap |
| 1457 | } |
| 1458 | } |
| 1459 | if len(r.PackageNames) > 0 { |
| 1460 | var names []string |
| 1461 | _ = json.Unmarshal(r.PackageNames, &names) |
| 1462 | m["package_names"] = names |
| 1463 | } |
| 1464 | if len(r.PackagesAffected) > 0 { |
| 1465 | var pkgs []string |
| 1466 | _ = json.Unmarshal(r.PackagesAffected, &pkgs) |
| 1467 | m["packages_affected"] = pkgs |
| 1468 | } |
| 1469 | m["hosts"] = map[string]interface{}{ |
| 1470 | "id": r.HostID, |
| 1471 | "friendly_name": r.HostFriendlyName, |
| 1472 | "hostname": r.HostHostname, |
| 1473 | } |
| 1474 | return m |
| 1475 | } |
| 1476 | |
| 1477 | func patchRunsToResponse(rows []db.ListRecentPatchRunsRow) []map[string]interface{} { |
| 1478 | out := make([]map[string]interface{}, len(rows)) |
no test coverage detected