Documentation ¶
Index ¶
- 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 DigestReference(ref string) bool
- func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool) error
- func DockerInitPath(localCopy string) string
- func DoesEnvExist(name string) bool
- func Download(url string) (resp *http.Response, err error)
- func GetCallerName(depth int) string
- func GetTotalUsedFds() int
- func HashData(src io.Reader) (string, error)
- func ImageReference(repo, ref string) string
- func NewHTTPRequestError(msg string, res *http.Response) error
- func ParseFlags(cmd *flag.FlagSet, args []string, withHelp bool) error
- func ReadDockerIgnore(path string) ([]string, error)
- func ReadSymlinkedDirectory(path string) (string, error)
- func RemovePidFile(pidfile string)
- func ReplaceOrAppendEnvValues(defaults, overrides []string) []string
- func ReportError(cmd *flag.FlagSet, str string, withHelp bool)
- func SelfPath() string
- func ShellQuoteArguments(args []string) string
- func StringsContainsNoCase(slice []string, s string) bool
- func TempDir(rootDir string) (string, error)
- func TestDirectory(templateDir string) (dir string, err error)
- func Trunc(s string, maxlen int) 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 StatusError
- type StderrFormater
- type StdoutFormater
- type StreamFormatter
- func (sf *StreamFormatter) FormatError(err error) []byte
- func (sf *StreamFormatter) FormatProg(id, action string, p interface{}) []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 VersionInfo
- type WriteCounter
- type WriteFlusher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyEscapable ¶
Code c/c from io.Copy() modified to handle escape sequence
func CreatePidFile ¶ added in v0.6.6
func DigestReference ¶ added in v1.6.0
DigestReference returns true if ref is a digest reference; i.e. if it is of the form <algorithm>:<digest>.
func DisplayJSONMessagesStream ¶ added in v0.6.0
func DockerInitPath ¶ added in v0.6.5
Figure out the path of our dockerinit (which may be SelfPath())
func DoesEnvExist ¶ added in v1.5.0
func GetCallerName ¶ added in v0.6.7
GetCallerName introspects the call stack and returns the name of the function `depth` levels down in the stack.
func GetTotalUsedFds ¶
func GetTotalUsedFds() int
func ImageReference ¶ added in v1.6.0
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 ¶ added in v0.6.0
func ParseFlags ¶ added in v1.5.0
ParseFlags is a utility function that adds a help flag if withHelp is true, calls cmd.Parse(args) and prints a relevant error message if there are incorrect number of arguments. It returns error only if error handling is set to ContinueOnError and parsing fails. If error handling is set to ExitOnError, it's safe to ignore the return value. TODO: move this to a better package than utils
func ReadDockerIgnore ¶ added in v1.5.0
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 ¶ added in v0.9.0
ReadSymlinkedDirectory returns the target directory of a symlink. The target of the symbolic link may not be a file.
func RemovePidFile ¶ added in v0.6.6
func RemovePidFile(pidfile string)
func ReplaceOrAppendEnvValues ¶ added in v0.9.0
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 ¶ added in v0.6.7
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 ¶ added in v1.2.0
func TestDirectory ¶ added in v0.6.7
TestDirectory creates a new temporary directory and returns its path. The contents of directory at path `templateDir` is copied into the new directory.
func ValidateContextDirectory ¶ added in v0.12.0
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 ¶ added in v0.10.0
Types ¶
type HTTPAuthDecorator ¶ added in v0.7.1
type HTTPAuthDecorator struct {
// contains filtered or unexported fields
}
func (*HTTPAuthDecorator) ChangeRequest ¶ added in v0.7.1
type HTTPMetaHeadersDecorator ¶ added in v0.6.1
func (*HTTPMetaHeadersDecorator) ChangeRequest ¶ added in v0.6.1
type HTTPRequestDecorator ¶ added in v0.6.0
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 ¶ added in v0.7.1
func NewHTTPAuthDecorator(login, password string) HTTPRequestDecorator
func NewHTTPUserAgentDecorator ¶ added in v0.6.0
func NewHTTPUserAgentDecorator(versions ...VersionInfo) HTTPRequestDecorator
type HTTPRequestFactory ¶ added in v0.6.0
type HTTPRequestFactory struct {
// contains filtered or unexported fields
}
HTTPRequestFactory creates an HTTP request and applies a list of decorators on the request.
func NewHTTPRequestFactory ¶ added in v0.6.0
func NewHTTPRequestFactory(d ...HTTPRequestDecorator) *HTTPRequestFactory
func (*HTTPRequestFactory) AddDecorator ¶ added in v0.7.1
func (self *HTTPRequestFactory) AddDecorator(d ...HTTPRequestDecorator)
func (*HTTPRequestFactory) GetDecorators ¶ added in v1.5.0
func (self *HTTPRequestFactory) GetDecorators() []HTTPRequestDecorator
func (*HTTPRequestFactory) NewRequest ¶ added in v0.6.0
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 ¶ added in v0.6.0
type HTTPUserAgentDecorator struct {
// contains filtered or unexported fields
}
HTTPUserAgentDecorator appends the product/version to the user agent field of a request.
func (*HTTPUserAgentDecorator) ChangeRequest ¶ added in v0.6.0
type JSONError ¶ added in v0.6.0
type JSONMessage ¶ added in v0.4.1
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 ¶ added in v0.7.1
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 ¶ added in v0.7.1
func (p *JSONProgress) String() string
type KeyValuePair ¶ added in v0.10.0
type StatusError ¶ added in v0.6.2
An StatusError reports an unsuccessful exit by a command.
func (*StatusError) Error ¶ added in v0.6.2
func (e *StatusError) Error() string
type StderrFormater ¶ added in v0.10.0
type StderrFormater struct { io.Writer *StreamFormatter }
type StdoutFormater ¶ added in v0.10.0
type StdoutFormater struct { io.Writer *StreamFormatter }
type StreamFormatter ¶ added in v0.4.0
type StreamFormatter struct {
// contains filtered or unexported fields
}
func NewStreamFormatter ¶ added in v0.4.0
func NewStreamFormatter(json bool) *StreamFormatter
func (*StreamFormatter) FormatError ¶ added in v0.4.0
func (sf *StreamFormatter) FormatError(err error) []byte
func (*StreamFormatter) FormatProg ¶ added in v1.6.0
func (sf *StreamFormatter) FormatProg(id, action string, p interface{}) []byte
func (*StreamFormatter) FormatProgress ¶ added in v0.4.0
func (sf *StreamFormatter) FormatProgress(id, action string, progress *JSONProgress) []byte
func (*StreamFormatter) FormatStatus ¶ added in v0.4.0
func (sf *StreamFormatter) FormatStatus(id, format string, a ...interface{}) []byte
func (*StreamFormatter) FormatStream ¶ added in v0.7.1
func (sf *StreamFormatter) FormatStream(str string) []byte
func (*StreamFormatter) Json ¶ added in v0.8.0
func (sf *StreamFormatter) Json() bool
type VersionInfo ¶ added in v0.6.0
VersionInfo is used to model entities which has a version. It is basically a tupple with name and version.
type WriteCounter ¶ added in v1.6.0
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 ¶ added in v1.6.0
func NewWriteCounter(w io.Writer) *WriteCounter
type WriteFlusher ¶
func NewWriteFlusher ¶
func NewWriteFlusher(w io.Writer) *WriteFlusher
func (*WriteFlusher) Flush ¶ added in v0.6.6
func (wf *WriteFlusher) Flush()
Flush the stream immediately.