utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2016 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir added in v0.2.0

func CopyDir(srcPath, dstPath string) error

CopyDir recursively copies files from one directory to another

func GenerateUUID

func GenerateUUID(name string) uuid.UUID

GenerateUUID generates a new uuid for a minion

func SameContent added in v0.2.0

func SameContent(src, dst string) (bool, error)

SameContent returns a boolean indicating whether two files have the same content

func WalkPath added in v0.2.0

func WalkPath(root string, skip []string) ([]string, error)

WalkPath walks a path and returns a slice of file names that were found during path traversing

Types

type ConcurrentMap added in v0.2.0

type ConcurrentMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConcurrentMap is a map type that can be safely shared between goroutines that require read/write access to a map

func NewConcurrentMap

func NewConcurrentMap() *ConcurrentMap

NewConcurrentMap creates a new concurrent map

func (*ConcurrentMap) Get added in v0.2.0

func (cm *ConcurrentMap) Get(key string) (interface{}, bool)

Get retrieves the value for a concurrent map item

func (*ConcurrentMap) Iter added in v0.2.0

func (cm *ConcurrentMap) Iter() <-chan ConcurrentMapItem

Iter iterates over the items in a concurrent map Each item is sent over a channel, so that we can iterate over the map using the builtin range keyword

func (*ConcurrentMap) Set added in v0.2.0

func (cm *ConcurrentMap) Set(key string, value interface{})

Set adds an item to a concurrent map

type ConcurrentMapItem

type ConcurrentMapItem struct {
	Key   string
	Value interface{}
}

ConcurrentMapItem contains a key/value pair item of a concurrent map

type ConcurrentSlice added in v0.2.0

type ConcurrentSlice struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConcurrentSlice type that can be safely shared between goroutines

func NewConcurrentSlice

func NewConcurrentSlice() *ConcurrentSlice

NewConcurrentSlice creates a new concurrent slice

func (*ConcurrentSlice) Append added in v0.2.0

func (cs *ConcurrentSlice) Append(item interface{})

Append adds an item to the concurrent slice

func (*ConcurrentSlice) Iter added in v0.2.0

func (cs *ConcurrentSlice) Iter() <-chan ConcurrentSliceItem

Iter iterates over the items in the concurrent slice Each item is sent over a channel, so that we can iterate over the slice using the builin range keyword

type ConcurrentSliceItem

type ConcurrentSliceItem struct {
	Index int
	Value interface{}
}

ConcurrentSliceItem contains the index/value pair of an item in a concurrent slice

type FileOwner added in v0.2.0

type FileOwner struct {
	*user.User
	*user.Group
}

FileOwner type provides details about the user and group that owns a file

type FileUtil added in v0.2.0

type FileUtil struct {
	// Path to the file we manage
	Path string
}

FileUtil type

func NewFileUtil added in v0.2.0

func NewFileUtil(path string) *FileUtil

NewFileUtil creates a file utility from the given path

func (*FileUtil) Abs added in v0.2.0

func (fu *FileUtil) Abs() (string, error)

Abs returns the absolute path for the file

func (*FileUtil) Chmod added in v0.2.0

func (fu *FileUtil) Chmod(perm os.FileMode) error

Chmod changes the permissions of the file

func (*FileUtil) CopyFrom added in v0.2.0

func (fu *FileUtil) CopyFrom(srcPath string, overwrite bool) error

CopyFrom copies contents from another source to the current file

func (*FileUtil) Exists added in v0.2.0

func (fu *FileUtil) Exists() bool

Exists returns a boolean indicating whether the file exists or not

func (*FileUtil) Md5 added in v0.2.0

func (fu *FileUtil) Md5() (string, error)

Md5 returns the md5 checksum of the file's contents

func (*FileUtil) Mode added in v0.2.0

func (fu *FileUtil) Mode() (os.FileMode, error)

Mode returns the file permission bits

func (*FileUtil) Owner added in v0.2.0

func (fu *FileUtil) Owner() (*FileOwner, error)

Owner retrieves the owner and group for the file

func (*FileUtil) Remove added in v0.2.0

func (fu *FileUtil) Remove() error

Remove removes the file

func (*FileUtil) SameContentWith added in v0.2.0

func (fu *FileUtil) SameContentWith(dst string) (bool, error)

SameContentWith returns a boolean indicating whether the content of the current file is the same as the destination

func (*FileUtil) SetOwner added in v0.2.0

func (fu *FileUtil) SetOwner(owner, group string) error

SetOwner sets the ownership for the file

func (*FileUtil) Sha1 added in v0.2.0

func (fu *FileUtil) Sha1() (string, error)

Sha1 returns the sha1 checksum of the file's contents

func (*FileUtil) Sha256 added in v0.2.0

func (fu *FileUtil) Sha256() (string, error)

Sha256 returns the sha256 checksum of the file's contents

type GitRepo added in v0.3.0

type GitRepo struct {
	// Local path to the repository
	Path string

	// Upstream URL of the Git repository
	Upstream string
	// contains filtered or unexported fields
}

GitRepo type manages a VCS repository with Git

func NewGitRepo added in v0.3.0

func NewGitRepo(path, upstream string) (*GitRepo, error)

NewGitRepo creates a new Git repository

func (*GitRepo) Checkout added in v0.3.0

func (gr *GitRepo) Checkout(branch string) ([]byte, error)

Checkout checks out a given local branch

func (*GitRepo) CheckoutDetached added in v0.3.0

func (gr *GitRepo) CheckoutDetached(branch string) ([]byte, error)

CheckoutDetached checks out a given local branch in detached mode

func (*GitRepo) Clone added in v0.3.0

func (gr *GitRepo) Clone() ([]byte, error)

Clone clones the upstream repository

func (*GitRepo) Fetch added in v0.3.0

func (gr *GitRepo) Fetch(remote string) ([]byte, error)

Fetch fetches from the given remote

func (*GitRepo) Head added in v0.3.0

func (gr *GitRepo) Head() (string, error)

Head returns the SHA1 commit id at HEAD

func (*GitRepo) IsGitRepo added in v0.3.0

func (gr *GitRepo) IsGitRepo() bool

IsGitRepo checks if the repository is a valid Git repository

func (*GitRepo) Pull added in v0.3.0

func (gr *GitRepo) Pull(remote, branch string) ([]byte, error)

Pull pulls from the given remote and merges changes into the local branch

type List added in v0.4.0

type List []string

List type represents a slice of strings

func NewList added in v0.4.0

func NewList(s ...string) List

NewList creates a new list with the given items

func (List) Contains added in v0.4.0

func (l List) Contains(x string) bool

Contains returns a boolean indicating whether the list contains the given string.

type String added in v0.4.0

type String struct {
	// contains filtered or unexported fields
}

String type represents a string

func NewString added in v0.4.0

func NewString(s string) String

NewString creates a new string

func (String) IsInList added in v0.4.0

func (s String) IsInList(l List) bool

IsInList returns a boolean indicating whether the string is contained within a given list

func (String) String added in v0.4.0

func (s String) String() string

String implements the fmt.Stringer interface

Jump to

Keyboard shortcuts

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