utils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(socket string, timeout time.Duration) (net.Conn, error)

func GenIsoImage

func GenIsoImage(isoPath string, volumeId string, srcDir string) error

GenIsoImage generates an ISO 9660 filesystem image containing files from srcDir. It uses specified volumeId as the volume id.

func MapToJson

func MapToJson(m map[string]interface{}) string

MapToJson converts the specified map object to indented JSON. It panics in case if the map connot be converted.

func MapToJsonUnindented

func MapToJsonUnindented(m map[string]interface{}) string

MapToJson converts the specified map object to unindented JSON. It panics in case if the map connot be converted.

func NewFakeDownloader

func NewFakeDownloader(baseDir string) *fakeDownloader

NewFakeDownloader returns a fake downloader that places fake downloaded files under the specified dir. The fake downloader writes the location passed to it into the file instead of actually downloading it.

func NewUuid

func NewUuid() string

func NewUuid5

func NewUuid5(nsUuid, s string) string

func ReadJson

func ReadJson(filename string, v interface{}) error

func Tempfile

func Tempfile() (string, error)

func WaitLoop

func WaitLoop(test func() (bool, error), retryPeriod time.Duration, timeout time.Duration, clock clockwork.Clock) error

WaitLoop executes test func in loop until it returns error, true, or the timeout elapses. clock argument denotes a clock object to use for waiting. When clock is nil, WaitLoop uses clockwork.NewRealClock()

func WriteFiles

func WriteFiles(targetDir string, content map[string][]byte) error

WriteFiles writes the files specified as a map under `targetDir`. The keys of the map are subpaths and values are file contents. WriteFiles automatically creates any non-existing directories mentioned in subpaths.

func WriteJson

func WriteJson(filename string, v interface{}, perm os.FileMode) error

Types

type Downloader

type Downloader interface {
	// DownloadFile downloads the specified file and returns path
	// to it
	DownloadFile(location string) (string, error)
}

Downloader is an interface for downloading files from web

func NewDownloader

func NewDownloader(protocol string) Downloader

NewDownloader returns the default downloader for 'protocol'. The default downloader downloads a file via an URL constructed as 'protocol://location' and saves it in temporary file in default system directory for temporary files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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