Documentation ¶
Overview ¶
Package fs provides functions for working with the file system as well as services that specifically deal with the file system.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CreateDir = func(path string, mode os.FileMode) error { if !FileExists(path) { err := Root.MkdirAll(path, mode) if err != nil { return err } } return nil }
CreateDir takes a path and a file mode, and it creates the path on Root with the given file mode. If there are any issues, an error is returned. Otherwise, nil is returned.
var DirectoryExists = func(path string) bool { if !FileExists(path) { return false } if !IsDir(path) { return false } return true }
DirectoryExists takes a directory path and returns a bool. If the directory exists on Root, the result is true. Otherwise, it is false.
var FileExists = func(path string) bool { _, err := Root.Stat(path) if os.IsNotExist(err) { return false } return true }
FileExists takes a file path and returns a bool. If the file exists on Root, the result is true. Otherwise, it is false.
var IsDir = func(path string) bool { info, err := Root.Stat(path) if err != nil { return false } return info.IsDir() }
IsDir takes a path and returns a bool. If the path is a directory, the result is true. Otherwise, it is false.
var Root = afero.NewOsFs()
Root is an Afero Filesystem object used as a proxy to the real file system.
Functions ¶
func Executable ¶
Executable takes a file path and returns a bool. If the file's permissions have the executable bit enabled, the result is true. Otherwise, it is false.
func NewJobService ¶
func NewJobService(path string, logger cronenberg.Logger) cronenberg.JobService
NewJobService takes a file path and a logger, using them to configure the returned JobService.
Types ¶
type JobService ¶
type JobService struct {
// contains filtered or unexported fields
}
JobService is an object that knows how to load job definitions from a yaml file.
func (*JobService) All ¶
func (service *JobService) All() []*cronenberg.Job
All reads the jobs from the service's file path and returns them as an array of Job objects. If there are issues along the way, the result is an empty array.