Documentation
¶
Index ¶
- Constants
- func BuildCacheWrite(ctx Context, buildCaches []*types.BuildCache) error
- func ClientContextWrite(ctx Context, contexts []*ClientContext) error
- func ContainerWrite(ctx Context, containers []types.Container) error
- func DisplayablePorts(ports []types.Port) string
- func Ellipsis(s string, maxDisplayWidth int) string
- func ImageWrite(ctx ImageContext, images []types.ImageSummary) error
- func MarshalJSON(x interface{}) ([]byte, error)
- func VolumeWrite(ctx Context, volumes []*types.Volume) error
- type ClientContext
- type ContainerContext
- func (c *ContainerContext) Command() string
- func (c *ContainerContext) CreatedAt() string
- func (c *ContainerContext) ID() string
- func (c *ContainerContext) Image() string
- func (c *ContainerContext) Label(name string) string
- func (c *ContainerContext) Labels() string
- func (c *ContainerContext) LocalVolumes() string
- func (c *ContainerContext) MarshalJSON() ([]byte, error)
- func (c *ContainerContext) Mounts() string
- func (c *ContainerContext) Names() string
- func (c *ContainerContext) Networks() string
- func (c *ContainerContext) Ports() string
- func (c *ContainerContext) RunningFor() string
- func (c *ContainerContext) Size() string
- func (c *ContainerContext) State() string
- func (c *ContainerContext) Status() string
- type Context
- type DiskUsageContext
- type Format
- func NewBuildCacheFormat(source string, quiet bool) Format
- func NewClientContextFormat(source string, quiet bool) Format
- func NewContainerFormat(source string, quiet bool, size bool) Format
- func NewDiskUsageFormat(source string, verbose bool) Format
- func NewImageFormat(source string, quiet bool, digest bool) Format
- func NewVolumeFormat(source string, quiet bool) Format
- type HeaderContext
- type ImageContext
- type SubContext
- type SubFormat
- type SubHeaderContext
Constants ¶
const ( CreatedSinceHeader = "CREATED" CreatedAtHeader = "CREATED AT" SizeHeader = "SIZE" LabelsHeader = "LABELS" NameHeader = "NAME" DescriptionHeader = "DESCRIPTION" DriverHeader = "DRIVER" ScopeHeader = "SCOPE" StateHeader = "STATE" StatusHeader = "STATUS" PortsHeader = "PORTS" ImageHeader = "IMAGE" ContainerIDHeader = "CONTAINER ID" )
Common header constants
const ( TableFormatKey = "table" RawFormatKey = "raw" PrettyFormatKey = "pretty" DefaultQuietFormat = "{{.ID}}" )
Format keys used to specify certain kinds of output formats
const ( // ClientContextTableFormat is the default client context format ClientContextTableFormat = "" /* 127-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func BuildCacheWrite ¶
func BuildCacheWrite(ctx Context, buildCaches []*types.BuildCache) error
BuildCacheWrite renders the context for a list of containers
func ClientContextWrite ¶
func ClientContextWrite(ctx Context, contexts []*ClientContext) error
ClientContextWrite writes formatted contexts using the Context
func ContainerWrite ¶
ContainerWrite renders the context for a list of containers
func DisplayablePorts ¶
DisplayablePorts returns formatted string representing open ports of container e.g. "0.0.0.0:80->9090/tcp, 9988/tcp" it's used by command 'docker ps'
func Ellipsis ¶
Ellipsis truncates a string to fit within maxDisplayWidth, and appends ellipsis (…). For maxDisplayWidth of 1 and lower, no ellipsis is appended. For maxDisplayWidth of 1, first char of string will return even if its width > 1.
func ImageWrite ¶
func ImageWrite(ctx ImageContext, images []types.ImageSummary) error
ImageWrite writes the formatter images using the ImageContext
func MarshalJSON ¶
MarshalJSON marshals x into json It differs a bit from encoding/json MarshalJSON function for formatter
Types ¶
type ClientContext ¶
type ClientContext struct {
Name string
Description string
DockerEndpoint string
KubernetesEndpoint string
StackOrchestrator string
Current bool
}
ClientContext is a context for display
type ContainerContext ¶
type ContainerContext struct {
HeaderContext
// FieldsUsed is used in the pre-processing step to detect which fields are
// used in the template. It's currently only used to detect use of the .Size
// field which (if used) automatically sets the '--size' option when making
// the API call.
FieldsUsed map[string]interface{}
// contains filtered or unexported fields
}
ContainerContext is a struct used for rendering a list of containers in a Go template.
func NewContainerContext ¶
func NewContainerContext() *ContainerContext
NewContainerContext creates a new context for rendering containers
func (*ContainerContext) Command ¶
func (c *ContainerContext) Command() string
Command returns's the container's command. If the trunc option is set, the returned command is truncated (ellipsized).
func (*ContainerContext) CreatedAt ¶
func (c *ContainerContext) CreatedAt() string
CreatedAt returns the "Created" date/time of the container as a unix timestamp.
func (*ContainerContext) ID ¶
func (c *ContainerContext) ID() string
ID returns the container's ID as a string. Depending on the `--no-trunc` option being set, the full or truncated ID is returned.
func (*ContainerContext) Image ¶
func (c *ContainerContext) Image() string
Image returns the container's image reference. If the trunc option is set, the image's registry digest can be included.