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

Function GetCrontab

lib/crontab.go:900–914  ·  view source on GitHub ↗

GetCrontab returns a single Crontab object for the specified filename. The filename can be either a full path to a crontab file or a user crontab in the form "user: ".

(filename string)

Source from the content-addressed store, hash-verified

898// GetCrontab returns a single Crontab object for the specified filename.
899// The filename can be either a full path to a crontab file or a user crontab in the form "user:<username>".
900func GetCrontab(filename string) (*Crontab, error) {
901 var username string
902
903 if strings.HasPrefix(filename, "user:") {
904 username = strings.TrimPrefix(filename, "user:")
905 } else if u, err := user.Current(); err == nil {
906 username = u.Username
907 }
908
909 crontabs := ReadCrontabFromFile(username, filename, []*Crontab{})
910 if len(crontabs) == 0 {
911 return nil, fmt.Errorf("no crontab found at %s", filename)
912 }
913 return crontabs[0], nil
914}
915
916// lightweightCrontab creates a copy of Crontab without the Lines field to prevent circular references
917func (c *Crontab) lightweightCopy() Crontab {

Callers 6

handleRunJobFunction · 0.92
handleDeleteJobFunction · 0.92
handlePostJobFunction · 0.92
handlePostCrontabsFunction · 0.92
handlePutCrontabsFunction · 0.92
handlePutJobFunction · 0.92

Calls 1

ReadCrontabFromFileFunction · 0.85

Tested by

no test coverage detected