utils

package
v0.0.0-...-746469e Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: Apache-2.0 Imports: 14 Imported by: 39

Documentation

Index

Constants

View Source
const (
	ChunkSize = 128 * 1024
)

Variables

This section is empty.

Functions

func DataSha256sum

func DataSha256sum(data []byte) string

func FileSha256sum

func FileSha256sum(fsb afero.Fs, filepath string) (string, error)

func FsbFileSha256sum

func FsbFileSha256sum(f afero.File) string

func LimitReader

func LimitReader(r io.ReadSeeker, n int64) io.ReadSeeker

func MergeErrorList

func MergeErrorList(errorList []error) error

func SanitizeServerAddress

func SanitizeServerAddress(address string) (string, error)

Types

type CmdLine

type CmdLine struct {
}

func (*CmdLine) Execute

func (cl *CmdLine) Execute(cmdline string) ([]byte, error)

type CmdLineExecuter

type CmdLineExecuter interface {
	Execute(cmdline string) ([]byte, error)
}

type FileSystem

type FileSystem struct {
	CmdLineExecuter
}

func (*FileSystem) Format

func (fs *FileSystem) Format(targetDevice string, fsType string, formatOptions string) error

func (*FileSystem) Mount

func (fs *FileSystem) Mount(targetDevice string, mountPath string, fsType string, mountOptions string) error

func (*FileSystem) TempDir

func (fs *FileSystem) TempDir(fsb afero.Fs, prefix string) (string, error)

func (*FileSystem) Umount

func (fs *FileSystem) Umount(mountPath string) error

type FileSystemHelper

type FileSystemHelper interface {
	Format(targetDevice string, fsType string, formatOptions string) error
	Mount(targetDevice string, mountPath string, fsType string, mountOptions string) error
	TempDir(fsb afero.Fs, prefix string) (string, error)
	Umount(mountPath string) error
}

type LimitedReader

type LimitedReader struct {
	R io.ReadSeeker
	N int64
}

func (*LimitedReader) Read

func (l *LimitedReader) Read(p []byte) (n int, err error)

func (*LimitedReader) Seek

func (l *LimitedReader) Seek(offset int64, whence int) (int64, error)

type Permissions

type Permissions interface {
	ApplyChmod(fsb afero.Fs, filepath string, modestr string) error
	ApplyChown(filepath string, uid interface{}, gid interface{}) error
}

type PermissionsDefaultImpl

type PermissionsDefaultImpl struct {
}

func (*PermissionsDefaultImpl) ApplyChmod

func (pdi *PermissionsDefaultImpl) ApplyChmod(fsb afero.Fs, filepath string, modestr string) error

func (*PermissionsDefaultImpl) ApplyChown

func (pdi *PermissionsDefaultImpl) ApplyChown(filepath string, uid interface{}, gid interface{}) error

FIXME: this cannot be tested yet with unit tests because requires mock for: os.Chown, os.Lchown, os.Lstat, user.Lookup and user.LookupGroup. Since we can't change ownership on a real filesystem, this must be tested through integration.

type Rebooter

type Rebooter interface {
	Reboot() error
}

type RebooterImpl

type RebooterImpl struct {
}

func (*RebooterImpl) Reboot

func (r *RebooterImpl) Reboot() error

Jump to

Keyboard shortcuts

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