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

Function processDirectory

cmd/discover.go:262–286  ·  view source on GitHub ↗
(username, directory string)

Source from the content-addressed store, hash-verified

260}
261
262func processDirectory(username, directory string) {
263 // Look for crontab files in the system drop-in directory but only prompt to import them
264 // if the directory is writable for this user.
265 files := lib.EnumerateFiles(directory)
266 if len(files) > 0 {
267 testCrontab := lib.CrontabFactory(username, files[0])
268 if !testCrontab.IsWritable() {
269 printWarningText(fmt.Sprintf("Directory %s is not writable. Re-run command with sudo. Skipping", directory), false)
270 return
271 }
272
273 for _, crontabFile := range files {
274 if userAbortedSync {
275 break
276 }
277 if importedCrontabs > 0 {
278 printLn()
279 }
280
281 if processCrontab(lib.CrontabFactory(username, crontabFile)) {
282 importedCrontabs++
283 }
284 }
285 }
286}
287
288// importMonitorsFromFile imports monitors from a YAML or JSON file
289// YAML files are sent with Content-Type: application/yaml

Callers 1

discover.goFile · 0.85

Calls 6

EnumerateFilesFunction · 0.92
CrontabFactoryFunction · 0.92
printWarningTextFunction · 0.85
printLnFunction · 0.85
processCrontabFunction · 0.85
IsWritableMethod · 0.80

Tested by

no test coverage detected