Documentation ¶
Index ¶
- Constants
- Variables
- func CheckLocalDns(resolvConf []byte) bool
- func CopyDirectory(source, dest string) error
- func CopyEscapable(dst io.Writer, src io.ReadCloser) (written int64, err error)
- func CopyFile(src, dst string) (int64, error)
- func CreatePidFile(pidfile string) error
- func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool) error
- func DockerInitPath(localCopy string) string
- func Download(url string) (resp *http.Response, err error)
- func GenerateRandomID() string
- func GetCallerName(depth int) string
- func GetLines(input []byte, commentMarker []byte) [][]byte
- func GetTotalUsedFds() int
- func Go(f func() error) chan error
- func HashData(src io.Reader) (string, error)
- func IsGIT(str string) bool
- func IsURL(str string) bool
- func Matches(relFilePath string, patterns []string) (bool, error)
- func NewBufReader(r io.Reader) *bufReader
- func NewHTTPRequestError(msg string, res *http.Response) error
- func NewReadCloserWrapper(r io.Reader, closer func() error) io.ReadCloser
- func NewTimeoutConn(conn net.Conn, timeout time.Duration) net.Conn
- func NopWriteCloser(w io.Writer) io.WriteCloser
- func ProgressReader(r io.ReadCloser, size int, output io.Writer, sf *StreamFormatter, newline bool, ...) *progressReader
- func RandomString() string
- func ReadSymlinkedDirectory(path string) (string, error)
- func RemovePidFile(pidfile string)
- func ReplaceOrAppendEnvValues(defaults, overrides []string) []string
- func SelfPath() string
- func ShellQuoteArguments(args []string) string
- func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
- func StringsContainsNoCase(slice []string, s string) bool
- func TempDir(rootDir string) (string, error)
- func TestDirectory(templateDir string) (dir string, err error)
- func TreeSize(dir string) (size int64, err error)
- func Trunc(s string, maxlen int) string
- func TruncateID(id string) string
- func ValidateContextDirectory(srcPath string, excludes []string) error
- func ValidateID(id string) error
- type HTTPAuthDecorator
- type HTTPMetaHeadersDecorator
- type HTTPRequestDecorator
- type HTTPRequestFactory
- type HTTPUserAgentDecorator
- type JSONError
- type JSONMessage
- type JSONProgress
- type KeyValuePair
- type NopFlusher
- type NopWriter
- type StatusError
- type StdType
- type StdWriter
- type StderrFormater
- type StdoutFormater
- type StreamFormatter
- func (sf *StreamFormatter) FormatError(err error) []byte
- func (sf *StreamFormatter) FormatProgress(id, action string, progress *JSONProgress) []byte
- func (sf *StreamFormatter) FormatStatus(id, format string, a ...interface{}) []byte
- func (sf *StreamFormatter) FormatStream(str string) []byte
- func (sf *StreamFormatter) Json() bool
- type TimeoutConn
- type VersionInfo
- type WriteFlusher
Constants ¶
const ( StdWriterPrefixLen = 8 StdWriterFdIndex = 0 StdWriterSizeIndex = 4 )
Variables ¶
var ErrInvalidStdHeader = errors.New("Unrecognized input header")
Functions ¶
func CheckLocalDns ¶
CheckLocalDns looks into the /etc/resolv.conf, it returns true if there is a local nameserver or if there is no nameserver.
func CopyDirectory ¶
FIXME: this is deprecated by CopyWithTar in archive.go
func CopyEscapable ¶
Code c/c from io.Copy() modified to handle escape sequence
func CreatePidFile ¶
func DockerInitPath ¶
Figure out the path of our dockerinit (which may be SelfPath())
func GetCallerName ¶
GetCallerName introspects the call stack and returns the name of the function `depth` levels down in the stack.
func GetTotalUsedFds ¶
func GetTotalUsedFds() int
func Go ¶
Go is a basic promise implementation: it wraps calls a function in a goroutine, and returns a channel which will later return the function's return value.
func NewBufReader ¶
func NewReadCloserWrapper ¶
func NewReadCloserWrapper(r io.Reader, closer func() error) io.ReadCloser
func NopWriteCloser ¶
func NopWriteCloser(w io.Writer) io.WriteCloser
func ProgressReader ¶
func ProgressReader(r io.ReadCloser, size int, output io.Writer, sf *StreamFormatter, newline bool, ID, action string) *progressReader
func RandomString ¶
func RandomString() string
func ReadSymlinkedDirectory ¶
ReadSymlinkedDirectory returns the target directory of a symlink. The target of the symbolic link may not be a file.
func RemovePidFile ¶
func RemovePidFile(pidfile string)
func ReplaceOrAppendEnvValues ¶
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 ¶
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 StdCopy ¶
StdCopy is a modified version of io.Copy.
StdCopy will demultiplex `src`, assuming that it contains two streams, previously multiplexed together using a StdWriter instance. As it reads from `src`, StdCopy will write to `dstout` and `dsterr`.
StdCopy will read until it hits EOF on `src`. It will then return a nil error. In other words: if `err` is non nil, it indicates a real underlying error.
`written` will hold the total number of bytes written to `dstout` and `dsterr`.
func StringsContainsNoCase ¶
func TestDirectory ¶
TestDirectory creates a new temporary directory and returns its path. The contents of directory at path `templateDir` is copied into the new directory.
func TruncateID ¶
TruncateID returns a shorthand version of a string identifier for convenience. A collision with other shorthands is very unlikely, but possible. In case of a collision a lookup with TruncIndex.Get() will fail, and the caller will need to use a langer prefix, or the full-length Id.
func ValidateContextDirectory ¶
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 ¶
Types ¶
type HTTPAuthDecorator ¶
type HTTPAuthDecorator struct {
// contains filtered or unexported fields
}
func (*HTTPAuthDecorator) ChangeRequest ¶
type HTTPMetaHeadersDecorator ¶
func (*HTTPMetaHeadersDecorator) ChangeRequest ¶
type HTTPRequestDecorator ¶
type HTTPRequestDecorator interface { // ChangeRequest() changes the request accordingly. // The changed request will be returned or err will be non-nil // if an error occur. ChangeRequest(req *http.Request) (newReq *http.Request, err error) }
HTTPRequestDecorator is used to change an instance of http.Request. It could be used to add more header fields, change body, etc.
func NewHTTPAuthDecorator ¶
func NewHTTPAuthDecorator(login, password string) HTTPRequestDecorator
func NewHTTPUserAgentDecorator ¶
func NewHTTPUserAgentDecorator(versions ...VersionInfo) HTTPRequestDecorator
type HTTPRequestFactory ¶
type HTTPRequestFactory struct {
// contains filtered or unexported fields
}
HTTPRequestFactory creates an HTTP request and applies a list of decorators on the request.
func NewHTTPRequestFactory ¶
func NewHTTPRequestFactory(d ...HTTPRequestDecorator) *HTTPRequestFactory
func (*HTTPRequestFactory) AddDecorator ¶
func (self *HTTPRequestFactory) AddDecorator(d ...HTTPRequestDecorator)
func (*HTTPRequestFactory) NewRequest ¶
func (h *HTTPRequestFactory) NewRequest(method, urlStr string, body io.Reader, d ...HTTPRequestDecorator) (*http.Request, error)
NewRequest() creates a new *http.Request, applies all decorators in the HTTPRequestFactory on the request, then applies decorators provided by d on the request.
type HTTPUserAgentDecorator ¶
type HTTPUserAgentDecorator struct {
// contains filtered or unexported fields
}
HTTPUserAgentDecorator appends the product/version to the user agent field of a request.
func (*HTTPUserAgentDecorator) ChangeRequest ¶
type JSONError ¶
type JSONMessage ¶
type JSONMessage struct { Stream string `json:"stream,omitempty"` Status string `json:"status,omitempty"` Progress *JSONProgress `json:"progressDetail,omitempty"` ProgressMessage string `json:"progress,omitempty"` //deprecated ID string `json:"id,omitempty"` From string `json:"from,omitempty"` Time int64 `json:"time,omitempty"` Error *JSONError `json:"errorDetail,omitempty"` ErrorMessage string `json:"error,omitempty"` //deprecated }
type JSONProgress ¶
type JSONProgress struct { Current int `json:"current,omitempty"` Total int `json:"total,omitempty"` Start int64 `json:"start,omitempty"` // contains filtered or unexported fields }
func (*JSONProgress) String ¶
func (p *JSONProgress) String() string
type KeyValuePair ¶
type StatusError ¶
An StatusError reports an unsuccessful exit by a command.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
type StdType ¶
type StdType [StdWriterPrefixLen]byte
type StdWriter ¶
func NewStdWriter ¶
NewStdWriter instanciates a new Writer. Everything written to it will be encapsulated using a custom format, and written to the underlying `w` stream. This allows multiple write streams (e.g. stdout and stderr) to be muxed into a single connection. `t` indicates the id of the stream to encapsulate. It can be utils.Stdin, utils.Stdout, utils.Stderr.
type StderrFormater ¶
type StderrFormater struct { io.Writer *StreamFormatter }
type StdoutFormater ¶
type StdoutFormater struct { io.Writer *StreamFormatter }
type StreamFormatter ¶
type StreamFormatter struct {
// contains filtered or unexported fields
}
func NewStreamFormatter ¶
func NewStreamFormatter(json bool) *StreamFormatter
func (*StreamFormatter) FormatError ¶
func (sf *StreamFormatter) FormatError(err error) []byte
func (*StreamFormatter) FormatProgress ¶
func (sf *StreamFormatter) FormatProgress(id, action string, progress *JSONProgress) []byte
func (*StreamFormatter) FormatStatus ¶
func (sf *StreamFormatter) FormatStatus(id, format string, a ...interface{}) []byte
func (*StreamFormatter) FormatStream ¶
func (sf *StreamFormatter) FormatStream(str string) []byte
func (*StreamFormatter) Json ¶
func (sf *StreamFormatter) Json() bool
type TimeoutConn ¶
A net.Conn that sets a deadline for every Read or Write operation
type VersionInfo ¶
VersionInfo is used to model entities which has a version. It is basically a tupple with name and version.
type WriteFlusher ¶
func NewWriteFlusher ¶
func NewWriteFlusher(w io.Writer) *WriteFlusher