utils

package
v0.0.0-...-058fe0e Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Second     = time.Second
	Minute     = Second * 60
	Hour       = Minute * 60
	Day        = Hour * 24
	Week       = Day * 7
	Month      = Day * 30
	Year       = Day * 365
	TimeLayout = "2006-01-02 15:04:05"
)

Common durations that is . There are some definitions for units of Day and larger .

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(size int64) string

FormatSize format image size to B/KB/MB/GB

func FormatTimeInterval

func FormatTimeInterval(input int64) (formattedTime string, err error)

FormatTimeInterval is used to show the time interval from input time to now.

func GenTLSConfig

func GenTLSConfig(key, cert, ca string) (*tls.Config, error)

GenTLSConfig returns a tls config object according to inputting parameters.

func If

func If(cond bool, v1, v2 interface{}) interface{}

If implements ternary operator. if cond is true return v1, or return v2 instead.

func IsMountpoint

func IsMountpoint(dir string) bool

IsMountpoint is used to check the directory is mountpoint or not.

func MakeFSVolume

func MakeFSVolume(fscmd []string, devicePath string, timeout time.Duration) error

MakeFSVolume is used to make file system on device with format type and options.

func MountVolume

func MountVolume(mountCmd []string, devicePath, mountPath string, timeout time.Duration) error

MountVolume is used to mount device to directory with options.

Types

type TLSConfig

type TLSConfig struct {
	CA           string
	Cert         string
	Key          string
	VerifyRemote bool
}

TLSConfig contains information of tls which users can specify

Jump to

Keyboard shortcuts

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