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

Method Key

lib/crontab.go:522–539  ·  view source on GitHub ↗
(CanonicalPath string)

Source from the content-addressed store, hash-verified

520}
521
522func (l Line) Key(CanonicalPath string) string {
523 var CommandToRun, RunAs, CronExpression string
524 if l.IsAutoDiscoverCommand() {
525 // Go out of our way to prevent making a duplicate monitor for an auto-discovery command.
526 CommandToRun = "auto discover " + CanonicalPath
527 RunAs = ""
528 CronExpression = ""
529 } else {
530 CommandToRun = l.CommandToRun
531 RunAs = l.RunAs
532 CronExpression = l.CronExpression
533 }
534
535 // Always use os.Hostname when creating a key so the key does not change when a user modifies their hostname using param/var
536 hostname, _ := os.Hostname()
537 data := []byte(fmt.Sprintf("%s-%s-%s-%s", hostname, CommandToRun, CronExpression, RunAs))
538 return fmt.Sprintf("%x", sha1.Sum(data))
539}
540
541func (l Line) GetCode() string {
542 // Existing integrations will have a code already in the Line struct

Callers 8

MarshalJSONMethod · 0.95
handlePostJobFunction · 0.95
handlePutJobFunction · 0.95
processCrontabFunction · 0.80
handleGetJobsFunction · 0.80
handleGetMonitorsFunction · 0.80
handleRunJobFunction · 0.80
handleDeleteJobFunction · 0.80

Calls 1

IsAutoDiscoverCommandMethod · 0.95

Tested by

no test coverage detected