package utils
import "github.com/docker/docker/utils"
Index ¶
- Constants
- Variables
- func CheckLocalDns(resolvConf []byte) bool
- func CompareKernelVersion(a, b *KernelVersionInfo) int
- func CopyDirectory(source, dest string) error
- func CopyEscapable(dst io.Writer, src io.ReadCloser) (written int64, err error)
- func Debugf(format string, a ...interface{})
- func DisplayJSONMessagesStream(in io.Reader, out io.Writer) error
- func Download(url string, stderr io.Writer) (*http.Response, error)
- func Errorf(format string, a ...interface{})
- func FindCgroupMountpoint(cgroupType string) (string, error)
- func GetReleaseVersion() string
- func GetResolvConf() ([]byte, error)
- func GetTotalUsedFds() int
- func Go(f func() error) chan error
- func HashData(src io.Reader) (string, error)
- func HumanDuration(d time.Duration) string
- func HumanSize(size int64) string
- func IsClosedError(err error) bool
- func IsGIT(str string) bool
- func IsURL(str string) bool
- func NewBufReader(r io.Reader) *bufReader
- func NewHTTPRequestError(msg string, res *http.Response) error
- func NopWriteCloser(w io.Writer) io.WriteCloser
- func ParseHost(host string, port int, addr string) string
- func ParseRepositoryTag(repos string) (string, string)
- func PartParser(template, data string) (map[string]string, error)
- func ProgressReader(r io.ReadCloser, size int, output io.Writer, tpl []byte, sf *StreamFormatter, newline bool) *progressReader
- func SelfPath() string
- func ShellQuoteArguments(args []string) string
- func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
- func StripComments(input []byte, commentMarker []byte) []byte
- func Trunc(s string, maxlen int) string
- func TruncateID(id string) string
- type DependencyGraph
- func NewDependencyGraph() DependencyGraph
- func (graph *DependencyGraph) AddDependency(node, to string) error
- func (graph *DependencyGraph) GenerateTraversalMap() ([][]string, error)
- func (graph *DependencyGraph) NewNode(id string) string
- type DependencyNode
- type HTTPMetaHeadersDecorator
- type HTTPRequestDecorator
- type HTTPRequestFactory
- func NewHTTPRequestFactory(d ...HTTPRequestDecorator) *HTTPRequestFactory
- func (self *HTTPRequestFactory) NewRequest(method, urlStr string, body io.Reader, d ...HTTPRequestDecorator) (*http.Request, error)
- type HTTPUserAgentDecorator
- type JSONError
- type JSONLog
- type JSONMessage
- type KernelVersionInfo
- func GetKernelVersion() (*KernelVersionInfo, error)
- func ParseRelease(release string) (*KernelVersionInfo, error)
- func (k *KernelVersionInfo) String() string
- type ListOpts
- type NopFlusher
- type NopWriter
- type StatusError
- type StdType
- type StdWriter
- func NewStdWriter(w io.Writer, t StdType) *StdWriter
- func (w *StdWriter) Write(buf []byte) (n int, err error)
- type StreamFormatter
- func NewStreamFormatter(json bool) *StreamFormatter
- func (sf *StreamFormatter) FormatError(err error) []byte
- func (sf *StreamFormatter) FormatProgress(id, action, progress string) []byte
- func (sf *StreamFormatter) FormatStatus(id, format string, a ...interface{}) []byte
- func (sf *StreamFormatter) Used() bool
- type StreamWriter
- type TarSum
- type TruncIndex
- func NewTruncIndex() *TruncIndex
- func (idx *TruncIndex) Add(id string) error
- func (idx *TruncIndex) Delete(id string) error
- func (idx *TruncIndex) Get(s string) (string, error)
- type User
- type VersionInfo
- type WriteBroadcaster
- func NewWriteBroadcaster() *WriteBroadcaster
- func (w *WriteBroadcaster) AddWriter(writer io.WriteCloser, stream string)
- func (w *WriteBroadcaster) CloseWriters() error
- func (w *WriteBroadcaster) Write(p []byte) (n int, err error)
- type WriteFlusher
Constants ¶
const ( StdWriterPrefixLen = 8 StdWriterFdIndex = 0 StdWriterSizeIndex = 4 )
Variables ¶
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 CompareKernelVersion ¶
func CompareKernelVersion(a, b *KernelVersionInfo) int
Compare two KernelVersionInfo struct. Returns -1 if a < b, = if a == b, 1 it a > b
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 Debugf ¶
func Debugf(format string, a ...interface{})
Debug function, if the debug flag is set, then display. Do nothing otherwise If Docker is in damon mode, also send the debug info on the socket
func DisplayJSONMessagesStream ¶
func Download ¶
Request a given URL and return an io.Reader
func Errorf ¶
func Errorf(format string, a ...interface{})
func FindCgroupMountpoint ¶
func GetReleaseVersion ¶
func GetReleaseVersion() string
func GetResolvConf ¶
GetResolvConf opens and read the content of /etc/resolv.conf. It returns it as byte slice.
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 HashData ¶
func HumanDuration ¶
HumanDuration returns a human-readable approximation of a duration (eg. "About a minute", "4 hours ago", etc.)
func HumanSize ¶
HumanSize returns a human-readable approximation of a size using SI standard (eg. "44kB", "17MB")
func IsClosedError ¶
func IsGIT ¶
func IsURL ¶
func NewBufReader ¶
func NewHTTPRequestError ¶
func NopWriteCloser ¶
func NopWriteCloser(w io.Writer) io.WriteCloser
func ParseHost ¶
func ParseRepositoryTag ¶
Get a repos name and returns the right reposName + tag The tag can be confusing because of a port in a repository name.
Ex: localhost.localdomain:5000/samalba/hipache:latest
func PartParser ¶
func ProgressReader ¶
func ProgressReader(r io.ReadCloser, size int, output io.Writer, tpl []byte, sf *StreamFormatter, newline bool) *progressReader
func SelfPath ¶
func SelfPath() string
Figure out the absolute path of our own binary
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 StripComments ¶
StripComments parses input into lines and strips away comments.
func Trunc ¶
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.
Types ¶
type DependencyGraph ¶
type DependencyGraph struct {
// contains filtered or unexported fields
}
func NewDependencyGraph ¶
func NewDependencyGraph() DependencyGraph
func (*DependencyGraph) AddDependency ¶
func (graph *DependencyGraph) AddDependency(node, to string) error
func (*DependencyGraph) GenerateTraversalMap ¶
func (graph *DependencyGraph) GenerateTraversalMap() ([][]string, error)
The magic happens here ::
func (*DependencyGraph) NewNode ¶
func (graph *DependencyGraph) NewNode(id string) string
type DependencyNode ¶
type DependencyNode struct {
// contains filtered or unexported fields
}
func (*DependencyNode) Degree ¶
func (node *DependencyNode) Degree() int
type HTTPMetaHeadersDecorator ¶
func (*HTTPMetaHeadersDecorator) ChangeRequest ¶
func (self *HTTPMetaHeadersDecorator) ChangeRequest(req *http.Request) (newReq *http.Request, err error)
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 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) NewRequest ¶
func (self *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 ¶
func (self *HTTPUserAgentDecorator) ChangeRequest(req *http.Request) (newReq *http.Request, err error)
type JSONError ¶
type JSONError struct { Code int `json:"code,omitempty"` Message string `json:"message,omitempty"` }
func (*JSONError) Error ¶
type JSONLog ¶
type JSONLog struct { Log string `json:"log,omitempty"` Stream string `json:"stream,omitempty"` Created time.Time `json:"time"` }
type JSONMessage ¶
type JSONMessage struct { Status string `json:"status,omitempty"` Progress string `json:"progress,omitempty"` ErrorMessage string `json:"error,omitempty"` //deprecated ID string `json:"id,omitempty"` From string `json:"from,omitempty"` Time int64 `json:"time,omitempty"` Error *JSONError `json:"errorDetail,omitempty"` }
func (*JSONMessage) Display ¶
func (jm *JSONMessage) Display(out io.Writer) error
type KernelVersionInfo ¶
func GetKernelVersion ¶
func GetKernelVersion() (*KernelVersionInfo, error)
func ParseRelease ¶
func ParseRelease(release string) (*KernelVersionInfo, error)
func (*KernelVersionInfo) String ¶
func (k *KernelVersionInfo) String() string
type ListOpts ¶
type ListOpts []string
ListOpts type
func (*ListOpts) Set ¶
func (*ListOpts) String ¶
type NopFlusher ¶
type NopFlusher struct{}
func (*NopFlusher) Flush ¶
func (f *NopFlusher) Flush()
type NopWriter ¶
type NopWriter struct{}
func (*NopWriter) Write ¶
type StatusError ¶
type StatusError struct { Status int }
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.
func (*StdWriter) Write ¶
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, progress string) []byte
func (*StreamFormatter) FormatStatus ¶
func (sf *StreamFormatter) FormatStatus(id, format string, a ...interface{}) []byte
func (*StreamFormatter) Used ¶
func (sf *StreamFormatter) Used() bool
type StreamWriter ¶
type StreamWriter struct {
// contains filtered or unexported fields
}
type TarSum ¶
func (*TarSum) Read ¶
func (*TarSum) Sum ¶
type TruncIndex ¶
type TruncIndex struct {
// contains filtered or unexported fields
}
TruncIndex allows the retrieval of string identifiers by any of their unique prefixes. This is used to retrieve image and container IDs by more convenient shorthand prefixes.
func NewTruncIndex ¶
func NewTruncIndex() *TruncIndex
func (*TruncIndex) Add ¶
func (idx *TruncIndex) Add(id string) error
func (*TruncIndex) Delete ¶
func (idx *TruncIndex) Delete(id string) error
func (*TruncIndex) Get ¶
func (idx *TruncIndex) Get(s string) (string, error)
type User ¶
type User struct { Uid string // user id Gid string // primary group id Username string Name string HomeDir string }
func UserLookup ¶
UserLookup check if the given username or uid is present in /etc/passwd and returns the user struct. If the username is not found, an error is returned.
type VersionInfo ¶
VersionInfo is used to model entities which has a version. It is basically a tupple with name and version.
type WriteBroadcaster ¶
func NewWriteBroadcaster ¶
func NewWriteBroadcaster() *WriteBroadcaster
func (*WriteBroadcaster) AddWriter ¶
func (w *WriteBroadcaster) AddWriter(writer io.WriteCloser, stream string)
func (*WriteBroadcaster) CloseWriters ¶
func (w *WriteBroadcaster) CloseWriters() error
func (*WriteBroadcaster) Write ¶
func (w *WriteBroadcaster) Write(p []byte) (n int, err error)
type WriteFlusher ¶
func NewWriteFlusher ¶
func NewWriteFlusher(w io.Writer) *WriteFlusher
func (*WriteFlusher) Write ¶
func (wf *WriteFlusher) Write(b []byte) (n int, err error)
Source Files ¶
http.go stdcopy.go tarsum.go utils.go
- Version
- v0.7.0-rc4
- Published
- Oct 19, 2013
- Platform
- js/wasm
- Imports
- 24 packages
- Last checked
- 1 minute ago –
Tools for package owners.