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

Function gatherCrontabs

cmd/list.go:61–89  ·  view source on GitHub ↗

gatherCrontabs collects crontabs from the specified args or the default locations.

(args []string)

Source from the content-addressed store, hash-verified

59
60// gatherCrontabs collects crontabs from the specified args or the default locations.
61func gatherCrontabs(args []string) []*lib.Crontab {
62 var username string
63 if u, err := user.Current(); err == nil {
64 username = u.Username
65 }
66
67 crontabs := []*lib.Crontab{}
68
69 if len(args) > 0 {
70 if isPathToDirectory(args[0]) {
71 crontabs = lib.ReadCrontabsInDirectory(username, args[0], crontabs)
72 } else {
73 crontabs = lib.ReadCrontabFromFile(username, args[0], crontabs)
74 }
75 } else {
76 users := parseUsers()
77 if len(users) == 0 {
78 users = []string{username}
79 }
80
81 for _, user := range users {
82 crontabs = lib.ReadCrontabFromFile(user, fmt.Sprintf("user:%s", user), crontabs)
83 }
84 crontabs = lib.ReadCrontabFromFile(username, lib.SYSTEM_CRONTAB, crontabs)
85 crontabs = lib.ReadCrontabsInDirectory(username, lib.DROP_IN_DIRECTORY, crontabs)
86 }
87
88 return crontabs
89}
90
91// jobLines returns only the lines that have a command to run.
92func jobLines(crontab *lib.Crontab) []*lib.Line {

Callers 1

list.goFile · 0.85

Calls 4

ReadCrontabsInDirectoryFunction · 0.92
ReadCrontabFromFileFunction · 0.92
isPathToDirectoryFunction · 0.85
parseUsersFunction · 0.85

Tested by

no test coverage detected