utils

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildHash string

BuildHash is a variable that will be populated at build-time of the binary via the ldflags parameter. It is used to break cache when a new version of makisu is used.

Functions

func ConvertStringSliceToMap

func ConvertStringSliceToMap(values []string) map[string]string

ConvertStringSliceToMap parses a string slice as "=" separated key value pairs, and returns a map.

func DefaultEnv

func DefaultEnv(key string, _default string) string

DefaultEnv returns the environment variable <key> if it is found, and _default otherwise.

func FileInfoStat

func FileInfoStat(fi os.FileInfo) *syscall.Stat_t

FileInfoStat provides a convenience wrapper for casting the generic FileInfo.Sys field.

func GetUIDGID

func GetUIDGID() (int, int, error)

GetUIDGID returns the uid/gid pair for the current user.

func IsSpecialFile

func IsSpecialFile(fi os.FileInfo) bool

IsSpecialFile returns true for file types that overlayfs ignores. Overlayfs logic:

#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))

func IsValidJSON added in v0.1.6

func IsValidJSON(blob []byte) bool

IsValidJSON returns true if the blob passed in is a valid json object.

func MergeEnv

func MergeEnv(envList []string, newEnvMap map[string]string) []string

MergeEnv merges a new env key value pair into existing list. This is needed because Docker image config defines Env as []string, but actually uses it as map[string]string.

func MergeStringMaps

func MergeStringMaps(mapOne, mapTwo map[string]string) map[string]string

MergeStringMaps merges two string maps and returns the combined map. If there are duplicate keys it picks value from second map.

func MergeStructMaps

func MergeStructMaps(mapOne, mapTwo map[string]struct{}) map[string]struct{}

MergeStructMaps merges two struct maps and returns the combined map. If there are duplicate keys it picks value from second map.

func Min

func Min(a int64, others ...int64) int64

Min returns the minimum value of the integers passed in as arguments.

func Must

func Must(condition bool, message string, arguments ...interface{})

Must ensures that the condition passed in is true. If condition is true this function NO-OPS; Otherwise it logs the message formatted with the arguments passed in

func ResolveChown added in v0.1.11

func ResolveChown(chown string) (uid, gid int, err error)

ResolveChown converts a chown string to uid and gid integers. Format: <user>[:<group>] Both <user> and <group> can be either user/group strings or uid/gids. If <group> is not specified, gid will be set to the resolved uid.

Types

type MultiErrors

type MultiErrors struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MultiErrors contains a list of errors. It supports adding and collecting errors in multiple threads.

func NewMultiErrors

func NewMultiErrors() *MultiErrors

NewMultiErrors returns a new MultiErrors obj.

func (*MultiErrors) Add

func (e *MultiErrors) Add(err error)

Add appends an error to the list.

func (*MultiErrors) Collect

func (e *MultiErrors) Collect() error

Collect returns the result error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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