utils

package
v1.10.0-experimental Latest Latest
Warning

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

Go to latest
Published: May 6, 2015 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyEscapable

func CopyEscapable(dst io.Writer, src io.ReadCloser) (written int64, err error)

Code c/c from io.Copy() modified to handle escape sequence

func CopyFile

func CopyFile(src, dst string) (int64, error)

func DigestReference

func DigestReference(ref string) bool

DigestReference returns true if ref is a digest reference; i.e. if it is of the form <algorithm>:<digest>.

func DockerInitPath

func DockerInitPath(localCopy string) string

Figure out the path of our dockerinit (which may be SelfPath())

func DoesEnvExist

func DoesEnvExist(name string) bool

func Download

func Download(url string) (resp *http.Response, err error)

Request a given URL and return an io.Reader

func GetCallerName

func GetCallerName(depth int) string

GetCallerName introspects the call stack and returns the name of the function `depth` levels down in the stack.

func GetTotalUsedFds

func GetTotalUsedFds() int

func HashData

func HashData(src io.Reader) (string, error)

func ImageReference

func ImageReference(repo, ref string) string

ImageReference combines `repo` and `ref` and returns a string representing the combination. If `ref` is a digest (meaning it's of the form <algorithm>:<digest>, the returned string is <repo>@<ref>. Otherwise, ref is assumed to be a tag, and the returned string is <repo>:<tag>.

func NewHTTPRequestError

func NewHTTPRequestError(msg string, res *http.Response) error

func ReadDockerIgnore

func ReadDockerIgnore(path string) ([]string, error)

Reads a .dockerignore file and returns the list of file patterns to ignore. Note this will trim whitespace from each line as well as use GO's "clean" func to get the shortest/cleanest path for each.

func ReadSymlinkedDirectory

func ReadSymlinkedDirectory(path string) (string, error)

ReadSymlinkedDirectory returns the target directory of a symlink. The target of the symbolic link may not be a file.

func ReplaceOrAppendEnvValues

func ReplaceOrAppendEnvValues(defaults, overrides []string) []string

ReplaceOrAppendValues returns the defaults with the overrides either replaced by env key or appended to the list

func SelfPath

func SelfPath() string

Figure out the absolute path of our own binary (if it's still around).

func ShellQuoteArguments

func ShellQuoteArguments(args []string) string

Take a list of strings and escape them so they will be handled right when passed as arguments to an program via a shell

func StringsContainsNoCase

func StringsContainsNoCase(slice []string, s string) bool

func TestDirectory

func TestDirectory(templateDir string) (dir string, err error)

TestDirectory creates a new temporary directory and returns its path. The contents of directory at path `templateDir` is copied into the new directory.

func Trunc

func Trunc(s string, maxlen int) string

func ValidateContextDirectory

func ValidateContextDirectory(srcPath string, excludes []string) error

ValidateContextDirectory checks if all the contents of the directory can be read and returns an error if some files can't be read symlinks which point to non-existing files don't trigger an error

func ValidateID

func ValidateID(id string) error

Types

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

type StatusError

type StatusError struct {
	Status     string
	StatusCode int
}

An StatusError reports an unsuccessful exit by a command.

func (*StatusError) Error

func (e *StatusError) Error() string

type WriteCounter

type WriteCounter struct {
	Count  int64
	Writer io.Writer
}

Wrap a concrete io.Writer and hold a count of the number of bytes written to the writer during a "session". This can be convenient when write return is masked (e.g., json.Encoder.Encode())

func NewWriteCounter

func NewWriteCounter(w io.Writer) *WriteCounter

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (count int, err error)

type WriteFlusher

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

func NewWriteFlusher

func NewWriteFlusher(w io.Writer) *WriteFlusher

func (*WriteFlusher) Flush

func (wf *WriteFlusher) Flush()

Flush the stream immediately.

func (*WriteFlusher) Write

func (wf *WriteFlusher) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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