util

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2017 License: Apache-2.0 Imports: 18 Imported by: 523

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UsingCygwinGit = isUsingCygwinGit()

UsingCygwinGit indicates whether we believe the host's git utility is from Cygwin (expects Windows paths as /cygdrive/c/dir/file) or not (expects paths in host-native format).

Functions

func CreateInjectedFilesRemovalScript added in v1.0.5

func CreateInjectedFilesRemovalScript(files []string, scriptName string) (string, error)

CreateInjectedFilesRemovalScript creates a shell script that contains truncation of all files we injected into the container. The path to the script is returned. When the scriptName is provided, it is also truncated together with all secrets.

func ExpandInjectedFiles added in v1.0.5

func ExpandInjectedFiles(fs FileSystem, injections api.VolumeList) ([]string, error)

ExpandInjectedFiles returns a flat list of all files that are injected into a container. All files from nested directories are returned in the list.

func FixInjectionsWithRelativePath added in v1.0.5

func FixInjectionsWithRelativePath(workdir string, injections api.VolumeList) api.VolumeList

FixInjectionsWithRelativePath fixes the injections that does not specify the destination directory or the directory is relative to use the provided working directory.

func GenerateLabelsFromConfig added in v1.0.2

func GenerateLabelsFromConfig(labels map[string]string, config *api.Config, namespace string) map[string]string

GenerateLabelsFromConfig generate the labels based on build s2i Config

func GenerateLabelsFromSourceInfo added in v1.0.2

func GenerateLabelsFromSourceInfo(labels map[string]string, info *api.SourceInfo, namespace string) map[string]string

GenerateLabelsFromSourceInfo generate the labels based on the source repository informations.

func GenerateOutputImageLabels added in v1.0.1

func GenerateOutputImageLabels(info *api.SourceInfo, config *api.Config) map[string]string

GenerateOutputImageLabels generate the labels based on the s2i Config and source repository informations.

func HandleInjectionError added in v1.0.5

func HandleInjectionError(p api.VolumeSpec, err error) error

HandleInjectionError handles the error caused by injection and provide reasonable suggestion to users.

func IsTimeoutError added in v1.0.6

func IsTimeoutError(e error) bool

IsTimeoutError checks if the provided error is a TimeoutError.

func ReadEnvironmentFile added in v1.0.1

func ReadEnvironmentFile(path string) (map[string]string, error)

ReadEnvironmentFile reads the content for a file that contains a list of environment variables and values. The key-pairs are separated by a new line character. The file can also have comments (both '#' and '//' are supported).

func TimeoutAfter added in v1.0.6

func TimeoutAfter(t time.Duration, errorMsg string, f func(*time.Timer) error) error

TimeoutAfter executes the provided function and returns TimeoutError in the case that the execution time of the function exceeded the provided duration. The provided function is passed the timer in case it wishes to reset it. If so, the following pattern must be used:

if !timer.Stop() {
  return &TimeoutError{}
}

timer.Reset(timeout)

func ToSlashCygwin added in v1.1.4

func ToSlashCygwin(path string) (string, error)

ToSlashCygwin converts a path to a format suitable for sending to a Cygwin binary - `/dir/file` on UNIX-style systems; `c:\dir\file` on Windows without Cygwin; `/cygdrive/c/dir/file` on Windows with Cygwin.

Types

type CallbackInvoker

type CallbackInvoker interface {
	ExecuteCallback(callbackURL string, success bool, labels map[string]string, messages []string) []string
}

CallbackInvoker posts results to a callback URL when a STI build is done.

func NewCallbackInvoker

func NewCallbackInvoker() CallbackInvoker

NewCallbackInvoker creates an instance of the default CallbackInvoker implementation

type CommandOpts

type CommandOpts struct {
	Stdout    io.Writer
	Stderr    io.Writer
	Dir       string
	EnvAppend []string
}

CommandOpts contains options to attach Stdout/err to a command to run or set its initial directory

type CommandRunner

type CommandRunner interface {
	RunWithOptions(opts CommandOpts, name string, arg ...string) error
	Run(name string, arg ...string) error
	StartWithStdoutPipe(opts CommandOpts, name string, arg ...string) (io.ReadCloser, error)
	Wait() error
}

CommandRunner executes OS commands with the given parameters and options

func NewCommandRunner

func NewCommandRunner() CommandRunner

NewCommandRunner creates a new instance of the default implementation of CommandRunner

type FileInfo added in v1.1.4

type FileInfo struct {
	FileName    string
	FileSize    int64
	FileMode    os.FileMode
	FileModTime time.Time
	FileIsDir   bool
	FileSys     interface{}
}

FileInfo is a struct which implements os.FileInfo. We use it (a) for test purposes, and (b) because we enrich the FileMode on Windows systems

func (*FileInfo) IsDir added in v1.1.4

func (fi *FileInfo) IsDir() bool

IsDir returns true if fi refers to a directory

func (*FileInfo) ModTime added in v1.1.4

func (fi *FileInfo) ModTime() time.Time

ModTime returns the file modification time of fi

func (*FileInfo) Mode added in v1.1.4

func (fi *FileInfo) Mode() os.FileMode

Mode returns the file mode of fi

func (*FileInfo) Name added in v1.1.4

func (fi *FileInfo) Name() string

Name retuns the filename of fi

func (*FileInfo) Size added in v1.1.4

func (fi *FileInfo) Size() int64

Size returns the file size of fi

func (*FileInfo) Sys added in v1.1.4

func (fi *FileInfo) Sys() interface{}

Sys returns the sys interface of fi

type FileSystem

type FileSystem interface {
	Chmod(file string, mode os.FileMode) error
	Rename(from, to string) error
	MkdirAll(dirname string) error
	Mkdir(dirname string) error
	Exists(file string) bool
	Copy(sourcePath, targetPath string) error
	CopyContents(sourcePath, targetPath string) error
	RemoveDirectory(dir string) error
	CreateWorkingDirectory() (string, error)
	Open(file string) (io.ReadCloser, error)
	WriteFile(file string, data []byte) error
	ReadDir(string) ([]os.FileInfo, error)
	Stat(string) (os.FileInfo, error)
	Walk(string, filepath.WalkFunc) error
}

FileSystem allows STI to work with the file system and perform tasks such as creating and deleting directories

func NewFileSystem

func NewFileSystem() FileSystem

NewFileSystem creates a new instance of the default FileSystem implementation

type TimeoutError added in v1.0.6

type TimeoutError struct {
	// contains filtered or unexported fields
}

TimeoutError is error returned after timeout occurred.

func (*TimeoutError) Error added in v1.0.6

func (t *TimeoutError) Error() string

Error implements the Go error interface.

Directories

Path Synopsis
Package status provides functionality to update the status of a build with information about failures that occurred.
Package status provides functionality to update the status of a build with information about failures that occurred.

Jump to

Keyboard shortcuts

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