(w http.ResponseWriter, r *http.Request)
| 1429 | } |
| 1430 | |
| 1431 | func handleGetJobs(w http.ResponseWriter, r *http.Request) { |
| 1432 | // Parse crontabs |
| 1433 | crontabs, err := lib.GetAllCrontabs(parseUsers()) |
| 1434 | if err != nil { |
| 1435 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 1436 | return |
| 1437 | } |
| 1438 | |
| 1439 | // Check if this request is from the Crontabs view (has a 'key' query parameter) |
| 1440 | includeIgnoredJobs := r.URL.Query().Get("key") != "" |
| 1441 | |
| 1442 | var jobs []Job |
| 1443 | |
| 1444 | // Process each crontab |
| 1445 | for _, crontab := range crontabs { |
| 1446 | for i := range crontab.Lines { |
| 1447 | line := crontab.Lines[i] |
| 1448 | if !line.IsJob { |
| 1449 | continue |
| 1450 | } |
| 1451 | |
| 1452 | // Skip ignored jobs only if not requested from Crontabs view |
| 1453 | if line.Ignored && !includeIgnoredJobs { |
| 1454 | continue |
| 1455 | } |
| 1456 | |
| 1457 | timezone := effectiveTimezoneLocationName().Name |
| 1458 | if crontab.TimezoneLocationName != nil { |
| 1459 | timezone = crontab.TimezoneLocationName.Name |
| 1460 | } |
| 1461 | |
| 1462 | runAsUser := line.RunAs |
| 1463 | if runAsUser == "" { |
| 1464 | runAsUser = crontab.User |
| 1465 | } |
| 1466 | |
| 1467 | jobKey := line.Key(crontab.CanonicalName()) |
| 1468 | |
| 1469 | // Basic exclusions for cleaner names |
| 1470 | excludeFromName := []string{ |
| 1471 | "2>&1", |
| 1472 | "/bin/bash -l -c", |
| 1473 | "/bin/bash -lc", |
| 1474 | "/bin/bash -c -l", |
| 1475 | "/bin/bash -cl", |
| 1476 | "/dev/null", |
| 1477 | "'", |
| 1478 | "\"", |
| 1479 | "\\", |
| 1480 | } |
| 1481 | allNameCandidates := make(map[string]bool) |
| 1482 | |
| 1483 | job := Job{ |
| 1484 | Name: line.Name, |
| 1485 | DefaultName: createDefaultName(line, crontab, "", excludeFromName, allNameCandidates), |
| 1486 | Command: line.CommandToRun, |
| 1487 | Expression: line.CronExpression, |
| 1488 | RunAsUser: runAsUser, |
no test coverage detected