util

package
v0.0.0-...-6ca4c02 Latest Latest
Warning

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

Go to latest
Published: May 19, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendError

func AppendError(errs []error, err error) []error

append(errs, err) if err != nil

func AppendField

func AppendField(fields []string, flag, prefix string) []string

func EnsureExecutable

func EnsureExecutable(p string) error

EnsureExecutable sets the executable file mode bits, for all users, to ensure that we can execute a file

func ExecError

func ExecError(err error) string

ExecError returns a string format of err including stderr if the err is an ExitError, useful for errors from e.g. exec.Cmd.Output().

func ExtractField

func ExtractField(fields []string, target string) ([]string, string, bool)

ExtractField("--a=this --b=that --c=other", "--b") returns [--a=this, --c=other"], "that"

func FlushMem

func FlushMem()

FlushMem will try to reduce the memory usage of the container it is running in run this after a build

func Home

func Home(parts ...string) string

Returns $HOME/part/part/part

func InsertPath

func InsertPath(path string) error

export PATH=path:$PATH

func JoinURL

func JoinURL(urlPath, path string) (string, error)

gs://foo and bar becomes gs://foo/bar

func JsonForDebug

func JsonForDebug(o interface{}) string

JsonForDebug returns a json representation of the value, or a string representation of an error It is useful for an easy implementation of fmt.Stringer

func K8s

func K8s(topdir string, parts ...string) string

Returns $GOPATH/src/k8s.io/...

func MigrateOptions

func MigrateOptions(m []MigratedOption) error

Read value from ENV if --flag unset, optionally pushing to ENV

func PushEnv

func PushEnv(env, value string) (func() error, error)

Push env=value and return a function that resets env

func Pushd

func Pushd(dir string) (func() error, error)

Chdir() to dir and return a function to cd back to Getwd()

func SetFieldDefault

func SetFieldDefault(fields []string, flag, val string) []string

Types

type MigratedOption

type MigratedOption struct {
	Env      string  // env associated with --flag
	Option   *string // Value of --flag
	Name     string  // --flag name
	SkipPush bool    // Push option to env if false
}

Option that was an ENV that is now a --flag

type TestCase

type TestCase struct {
	XMLName   xml.Name `xml:"testcase"`
	ClassName string   `xml:"classname,attr"`
	Name      string   `xml:"name,attr"`
	Time      float64  `xml:"time,attr"`
	Failure   string   `xml:"failure,omitempty"`
	Skipped   string   `xml:"skipped,omitempty"`
}

type TestSuite

type TestSuite struct {
	XMLName  xml.Name `xml:"testsuite"`
	Failures int      `xml:"failures,attr"`
	Tests    int      `xml:"tests,attr"`
	Time     float64  `xml:"time,attr"`
	Cases    []TestCase
}

Jump to

Keyboard shortcuts

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