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 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" 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 Context ¶
type Context struct { // Output is the output stream to which the formatted string is written. Output io.Writer // Format is used to choose raw, table or custom format for the output. Format Format // Trunc when set to true will truncate the output of certain fields such as Container ID. Trunc bool // contains filtered or unexported fields }
Context contains information required by the formatter to print the output as desired.
type DiskUsageContext ¶
type DiskUsageContext struct { Context Verbose bool LayersSize int64 Images []*types.ImageSummary Containers []*types.Container Volumes []*types.Volume BuildCache []*types.BuildCache BuilderSize int64 }
DiskUsageContext contains disk usage specific information required by the formatter, encapsulate a Context struct.
func (*DiskUsageContext) Write ¶
func (ctx *DiskUsageContext) Write() (err error)
type Format ¶
type Format string
Format is the format string rendered using the Context
func NewBuildCacheFormat ¶
NewBuildCacheFormat returns a Format for rendering using a Context
func NewClientContextFormat ¶
NewClientContextFormat returns a Format for rendering using a Context
func NewContainerFormat ¶
NewContainerFormat returns a Format for rendering using a Context
func NewDiskUsageFormat ¶
NewDiskUsageFormat returns a format for rendering an DiskUsageContext
func NewImageFormat ¶
NewImageFormat returns a format for rendering an ImageContext
func NewVolumeFormat ¶
NewVolumeFormat returns a format for use with a volume Context
type HeaderContext ¶
type HeaderContext struct {
Header interface{}
}
HeaderContext provides the subContext interface for managing headers
func (*HeaderContext) FullHeader ¶
func (c *HeaderContext) FullHeader() interface{}
FullHeader returns the header as an interface
type ImageContext ¶
ImageContext contains image specific information required by the formatter, encapsulate a Context struct.
type SubContext ¶
type SubContext interface {
FullHeader() interface{}
}
SubContext defines what Context implementation should provide
type SubFormat ¶
type SubFormat func(func(SubContext) error) error
SubFormat is a function type accepted by Write()
type SubHeaderContext ¶
SubHeaderContext is a map destined to formatter header (table format)
func (SubHeaderContext) Label ¶
func (c SubHeaderContext) Label(name string) string
Label returns the header label for the specified string