docker

package
v0.0.0-...-88f6cf4 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitCodeTimeout   = 90408
	ExitMaxWriteLines = 90509
	ExitStopKeyword   = 90510
)
View Source
const RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"

RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to ensure the formatted time isalways the same number of characters.

Variables

This section is empty.

Functions

func DeleteImage

func DeleteImage(imageID string) error

func DisplayJSONMessagesStream

func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool, auxCallback func(JSONMessage)) error

DisplayJSONMessagesStream displays a json message stream from `in` to `out`, `isTerminal` describes if `out` is a terminal. If this is the case, it will print `\n` at the end of each line and move the cursor while displaying.

func DisplayJSONMessagesToStream

func DisplayJSONMessagesToStream(in io.Reader, stream stream, auxCallback func(JSONMessage)) error

DisplayJSONMessagesToStream prints json messages to the output stream

func EnsureNetworkMode

func EnsureNetworkMode(networkMode, driver string) (created bool, err error)

func ForwardAllSignals

func ForwardAllSignals(ctx context.Context, client *client.Client, streams Streams, cid string) chan os.Signal

ForwardAllSignals forwards signals to the container

func GetDockerVersion

func GetDockerVersion() (string, error)

func MonitorTtySize

func MonitorTtySize(ctx context.Context, streams Streams, id string, isExec bool) error

MonitorTtySize updates the container tty size when the terminal tty changes size

func NewStreams

func NewStreams(in io.ReadCloser, out io.Writer, err io.Writer) *streams

func PromiseGo

func PromiseGo(f func() error) chan error

func StdCopy

func StdCopy(ctx context.Context, dstOut, dstErr io.Writer, src io.Reader) (written int64, err error)

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`.

Types

type ConditionWriter

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

func CreateConditionWriter

func CreateConditionWriter(innerWriter io.Writer, maxLines int, lineCounter *atomic.Int32, exitChan ExitChan, stopKeywords ...string) *ConditionWriter

func (*ConditionWriter) Write

func (w *ConditionWriter) Write(p []byte) (n int, err error)

type Container

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

func NewContainer

func NewContainer(name string, id *string) *Container

func (*Container) AddPort

func (c *Container) AddPort(portName, hostIP string, hostPort int)

func (*Container) Attach

func (c *Container) Attach(ctx context.Context, tty bool, streams Streams, stdin io.ReadCloser, stdOut, stderr io.Writer, errCh *chan error) (close func(), errAttach error)

func (*Container) BuildImage

func (c *Container) BuildImage(name string, credentials map[string]*Credential, dockerBuildContent, contextDir string, out io.Writer) error

func (*Container) EnsureContainer

func (c *Container) EnsureContainer(attachStdin, attachStdout, attachStderr bool, consoleSize [2]uint) error

func (*Container) EnsureContainerRunning

func (c *Container) EnsureContainerRunning(attachStdin, attachStdout, attachStderr bool, consoleSize [2]uint) error

func (*Container) EnsureID

func (c *Container) EnsureID() (string, error)

func (*Container) EnsureImage

func (c *Container) EnsureImage(name string, ref *string, out io.Writer) (string, error)

func (*Container) EnsureImageByID

func (c *Container) EnsureImageByID(id string) error

func (*Container) Exists

func (c *Container) Exists() (bool, error)

func (*Container) GetImageID

func (c *Container) GetImageID() (string, error)

func (Container) ID

func (c Container) ID() *string

func (*Container) IsRunning

func (c *Container) IsRunning() (bool, error)

func (Container) Name

func (c Container) Name() string

func (*Container) Purge

func (c *Container) Purge() error

func (Container) QualifiedName

func (c Container) QualifiedName() string

func (*Container) Rename

func (c *Container) Rename(newName string) error

func (*Container) SetArgs

func (c *Container) SetArgs(args []string) *Container

func (*Container) SetAuthConfig

func (c *Container) SetAuthConfig(host, userName, password string) *Container

func (*Container) SetEnv

func (c *Container) SetEnv(env map[string]string) *Container

func (*Container) SetMounts

func (c *Container) SetMounts(mounts map[string]string) *Container

func (*Container) SetNetwork

func (c *Container) SetNetwork(networkMode *string) *Container

func (*Container) StopAndRename

func (c *Container) StopAndRename(newName string) error

func (*Container) WaitExitOrRemoved

func (c *Container) WaitExitOrRemoved(ctx context.Context, detach context.CancelFunc, writerExitChan ExitChan) (exitChan ExitChan, err error)

type Credential

type Credential struct {
	UserName string
	Password string
}

type ExitChan

type ExitChan chan struct {
	ExitCode int
	Message  string
}

type InStream

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

InStream is an input stream used by the DockerCli to read user input

func NewInStream

func NewInStream(in io.ReadCloser) *InStream

NewInStream returns a new InStream object from a ReadCloser

func (*InStream) CheckTty

func (i *InStream) CheckTty(attachStdin, ttyMode bool) error

CheckTty checks if we are trying to attach to a container tty from a non-tty client input stream, and if so, returns an error.

func (*InStream) Close

func (i *InStream) Close() error

Close implements the Closer interface

func (*InStream) FD

func (i *InStream) FD() uintptr

FD returns the file descriptor number for this stream

func (*InStream) IsTerminal

func (i *InStream) IsTerminal() bool

IsTerminal returns true if this stream is connected to a terminal

func (*InStream) Read

func (i *InStream) Read(p []byte) (int, error)

func (*InStream) RestoreTerminal

func (i *InStream) RestoreTerminal()

RestoreTerminal restores normal mode to the terminal

func (*InStream) SetRawTerminal

func (i *InStream) SetRawTerminal() (err error)

SetRawTerminal sets raw mode on the input terminal

type JSONError

type JSONError struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

JSONError wraps a concrete Code and Message, `Code` is is an integer error code, `Message` is the error message.

func (*JSONError) Error

func (e *JSONError) Error() string

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"`
	TimeNano        int64         `json:"timeNano,omitempty"`
	Error           *JSONError    `json:"errorDetail,omitempty"`
	ErrorMessage    string        `json:"error,omitempty"` // deprecated
	// Aux contains out-of-band data, such as digests for push signing and image id after building.
	Aux *json.RawMessage `json:"aux,omitempty"`
}

JSONMessage defines a message struct. It describes the created time, where it from, status, ID of the message. It's used for docker events.

func (*JSONMessage) Display

func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error

Display displays the JSONMessage to `out`. If `isTerminal` is true, it will erase the entire current line when displaying the progressbar.

type JSONProgress

type JSONProgress struct {
	Current int64 `json:"current,omitempty"`
	Total   int64 `json:"total,omitempty"`
	Start   int64 `json:"start,omitempty"`
	// If true, don't show xB/yB
	HideCounts bool   `json:"hidecounts,omitempty"`
	Units      string `json:"units,omitempty"`
	// contains filtered or unexported fields
}

JSONProgress describes a Progress. terminalFd is the fd of the current terminal, Start is the initial value for the operation. Current is the current status and value of the progress made towards Total. Total is the end value describing when we made 100% progress for an operation.

func (*JSONProgress) String

func (p *JSONProgress) String() string

type OutStream

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

OutStream is an output stream used by the DockerCli to write normal program output.

func NewOutStream

func NewOutStream(out io.Writer) *OutStream

NewOutStream returns a new OutStream object from a Writer

func (*OutStream) FD

func (o *OutStream) FD() uintptr

FD returns the file descriptor number for this stream

func (*OutStream) GetTtySize

func (o *OutStream) GetTtySize() (uint, uint)

GetTtySize returns the height and width in characters of the tty

func (*OutStream) IsTerminal

func (o *OutStream) IsTerminal() bool

IsTerminal returns true if this stream is connected to a terminal

func (*OutStream) RestoreTerminal

func (o *OutStream) RestoreTerminal()

RestoreTerminal restores normal mode to the terminal

func (*OutStream) SetRawTerminal

func (o *OutStream) SetRawTerminal() (err error)

SetRawTerminal sets raw mode on the output terminal

func (*OutStream) Write

func (o *OutStream) Write(p []byte) (int, error)

type StdType

type StdType byte

StdType is the type of standard stream a writer can multiplex to.

const (
	// Stdin represents standard input stream type.
	Stdin StdType = iota
	// Stdout represents standard output stream type.
	Stdout
	// Stderr represents standard error steam type.
	Stderr
	// SystemErr represents errors originating from the system that make it
	// into the the multiplexed stream.
	SystemErr
)

type Streams

type Streams interface {
	In() *InStream
	Out() *OutStream
	Err() io.Writer
}

Directories

Path Synopsis
image

Jump to

Keyboard shortcuts

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