fs

package
v2.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateDir = func(path string) {
	if !FileExists(path) {
		err := Root.MkdirAll(path, 0755)
		if err != nil {
			fmt.Println("Could not create", path)
			os.Exit(255)
		}
	}
}

CreateDir takes a path and attempts to create it and all of its ancestors on the file system. If there are problems along the way, the program exits with code 255.

View Source
var Root = afero.NewOsFs()

Root is the abstracted file system used for all operations in this package.

Functions

func DataDir

func DataDir() string

DataDir is the file system location in which runtime data is stored.

func FileExists

func FileExists(path string) bool

FileExists takes a path, checks to see if that file exists on the file system. If the file does exist, it returns true. Otherwise, it returns false.

func GroupConfigs

func GroupConfigs() string

GroupConfigs is the file system location in which group definition files are stored.

func Locks

func Locks() string

Locks is the file system location in which group lock files are stored.

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile takes a path, reads the file from the file system, and returns its contents as a byte array as well as an error. If there are issues along the way, the error is populated. Otherwise, the error is nil.

Types

type GroupService

type GroupService struct{}

GroupService is a service that knows how to interact with groups on the file system.

func NewGroupService

func NewGroupService() *GroupService

NewGroupService returns a new instance of GroupService.

func (*GroupService) Get

func (s *GroupService) Get(name string) (*scaley.Group, error)

Get takes a group name, attempts to read that group's definition from the file system, and returns both a group and an error. If there are issues along the way, the error is populated and the group is nil. Otherwise, the group is populated from the values in the associated group file and the error is nil.

type LockService

type LockService struct{}

LockService is a service that knows how to lock and unlock groups via the file system.

func NewLockService

func NewLockService() *LockService

NewLockService returns a new instance of LockService.

func (LockService) Lock

func (service LockService) Lock(group *scaley.Group) error

Lock attempts to lock the given group. If there are issues in doing so, an error is returned. Otherwise, nil is returned.

func (LockService) Locked

func (service LockService) Locked(group *scaley.Group) bool

Locked takes a group and returns a boolean that expresses whether or not that group is currently locked.

func (LockService) Unlock

func (service LockService) Unlock(group *scaley.Group) error

Unlock attempts to unlock the given group. If there are issues in doing so, an error is returned. Otherwise, nil is returned.

type ScalingScriptService

type ScalingScriptService struct{}

ScalingScriptService is a service that knows how to interact with scaling scripts via the file system.

func NewScalingScriptService

func NewScalingScriptService() *ScalingScriptService

NewScalingScriptService returns a new ScalingScriptService.

func (*ScalingScriptService) Exists

func (service *ScalingScriptService) Exists(path string) bool

Exists takes a path and returns a boolean that expresses whether or not the scaling script at that location exists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL