MCPcopy Create free account
hub / github.com/cronitorio/cronitor-cli / handleGetJobs

Function handleGetJobs

cmd/dash.go:1431–1555  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

1429}
1430
1431func 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,

Callers 1

handleJobsFunction · 0.85

Calls 14

GetAllCrontabsFunction · 0.92
parseUsersFunction · 0.85
createDefaultNameFunction · 0.85
logFunction · 0.85
findInstancesFunction · 0.85
ErrorMethod · 0.80
GetMethod · 0.80
KeyMethod · 0.80
CanonicalNameMethod · 0.80
DisplayNameMethod · 0.80
IsMetaCronJobMethod · 0.80

Tested by

no test coverage detected