formatter

package
v17.12.1-ce+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2018 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableFormatKey  = "table"
	RawFormatKey    = "raw"
	PrettyFormatKey = "pretty"
)

Format keys used to specify certain kinds of output formats

Variables

This section is empty.

Functions

func CheckpointWrite

func CheckpointWrite(ctx Context, checkpoints []types.Checkpoint) error

CheckpointWrite writes formatted checkpoints using the Context

func ConfigInspectWrite

func ConfigInspectWrite(ctx Context, refs []string, getRef inspect.GetRefFunc) error

ConfigInspectWrite renders the context for a list of configs

func ConfigWrite

func ConfigWrite(ctx Context, configs []swarm.Config) error

ConfigWrite writes the context

func ContainerStatsWrite

func ContainerStatsWrite(ctx Context, containerStats []StatsEntry, osType string, trunc bool) error

ContainerStatsWrite renders the context for a list of containers statistics

func ContainerWrite

func ContainerWrite(ctx Context, containers []types.Container) error

ContainerWrite renders the context for a list of containers

func DiffWrite

func DiffWrite(ctx Context, changes []container.ContainerChangeResponseItem) error

DiffWrite writes formatted diff using the Context

func DisplayablePorts

func DisplayablePorts(ports []types.Port) string

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

func Ellipsis(s string, maxDisplayWidth int) string

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 HistoryWrite

func HistoryWrite(ctx Context, human bool, histories []image.HistoryResponseItem) error

HistoryWrite writes the context

func ImageWrite

func ImageWrite(ctx ImageContext, images []types.ImageSummary) error

ImageWrite writes the formatter images using the ImageContext

func NetworkWrite

func NetworkWrite(ctx Context, networks []types.NetworkResource) error

NetworkWrite writes the context

func NodeInspectWrite

func NodeInspectWrite(ctx Context, refs []string, getRef inspect.GetRefFunc) error

NodeInspectWrite renders the context for a list of nodes

func NodeWrite

func NodeWrite(ctx Context, nodes []swarm.Node, info types.Info) error

NodeWrite writes the context

func PluginWrite

func PluginWrite(ctx Context, plugins []*types.Plugin) error

PluginWrite writes the context

func SearchWrite

func SearchWrite(ctx Context, results []registry.SearchResult, auto bool, stars int) error

SearchWrite writes the context

func SecretInspectWrite

func SecretInspectWrite(ctx Context, refs []string, getRef inspect.GetRefFunc) error

SecretInspectWrite renders the context for a list of secrets

func SecretWrite

func SecretWrite(ctx Context, secrets []swarm.Secret) error

SecretWrite writes the context

func ServiceInspectWrite

func ServiceInspectWrite(ctx Context, refs []string, getRef, getNetwork inspect.GetRefFunc) error

ServiceInspectWrite renders the context for a list of services

func ServiceListWrite

func ServiceListWrite(ctx Context, services []swarm.Service, info map[string]ServiceListInfo) error

ServiceListWrite writes the context

func SignerInfoWrite

func SignerInfoWrite(ctx Context, signerInfoList []SignerInfo) error

SignerInfoWrite writes the context

func StackWrite

func StackWrite(ctx Context, stacks []*Stack) error

StackWrite writes formatted stacks using the Context

func TaskWrite

func TaskWrite(ctx Context, tasks []swarm.Task, names map[string]string, nodes map[string]string) error

TaskWrite writes the context

func TrustTagWrite

func TrustTagWrite(ctx Context, signedTagInfoList []SignedTagInfo) error

TrustTagWrite writes the context

func VolumeWrite

func VolumeWrite(ctx Context, volumes []*types.Volume) error

VolumeWrite writes formatted volumes using the Context

Types

type ContainerStats

type ContainerStats struct {
	StatsEntry
	// contains filtered or unexported fields
}

ContainerStats represents an entity to store containers statistics synchronously

func NewContainerStats

func NewContainerStats(container string) *ContainerStats

NewContainerStats returns a new ContainerStats entity and sets in it the given name

func (*ContainerStats) GetError

func (cs *ContainerStats) GetError() error

GetError returns the container statistics error. This is used to determine whether the statistics are valid or not

func (*ContainerStats) GetStatistics

func (cs *ContainerStats) GetStatistics() StatsEntry

GetStatistics returns container statistics with other meta data such as the container name

func (*ContainerStats) SetError

func (cs *ContainerStats) SetError(err error)

SetError sets container statistics error

func (*ContainerStats) SetErrorAndReset

func (cs *ContainerStats) SetErrorAndReset(err error)

SetErrorAndReset zeroes all the container statistics and store the error. It is used when receiving time out error during statistics collecting to reduce lock overhead

func (*ContainerStats) SetStatistics

func (cs *ContainerStats) SetStatistics(s StatsEntry)

SetStatistics set the container statistics

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.

func (*Context) Write

func (c *Context) Write(sub subContext, f SubFormat) error

Write the template to the buffer using this Context

type DiskUsageContext

type DiskUsageContext struct {
	Context
	Verbose     bool
	LayersSize  int64
	Images      []*types.ImageSummary
	Containers  []*types.Container
	Volumes     []*types.Volume
	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 NewCheckpointFormat

func NewCheckpointFormat(source string) Format

NewCheckpointFormat returns a format for use with a checkpoint Context

func NewConfigFormat

func NewConfigFormat(source string, quiet bool) Format

NewConfigFormat returns a Format for rendering using a config Context

func NewContainerFormat

func NewContainerFormat(source string, quiet bool, size bool) Format

NewContainerFormat returns a Format for rendering using a Context

func NewDiffFormat

func NewDiffFormat(source string) Format

NewDiffFormat returns a format for use with a diff Context

func NewDiskUsageFormat

func NewDiskUsageFormat(source string) Format

NewDiskUsageFormat returns a format for rendering an DiskUsageContext

func NewHistoryFormat

func NewHistoryFormat(source string, quiet bool, human bool) Format

NewHistoryFormat returns a format for rendering an HistoryContext

func NewImageFormat

func NewImageFormat(source string, quiet bool, digest bool) Format

NewImageFormat returns a format for rendering an ImageContext

func NewNetworkFormat

func NewNetworkFormat(source string, quiet bool) Format

NewNetworkFormat returns a Format for rendering using a network Context

func NewNodeFormat

func NewNodeFormat(source string, quiet bool) Format

NewNodeFormat returns a Format for rendering using a node Context

func NewPluginFormat

func NewPluginFormat(source string, quiet bool) Format

NewPluginFormat returns a Format for rendering using a plugin Context

func NewSearchFormat

func NewSearchFormat(source string) Format

NewSearchFormat returns a Format for rendering using a network Context

func NewSecretFormat

func NewSecretFormat(source string, quiet bool) Format

NewSecretFormat returns a Format for rendering using a secret Context

func NewServiceFormat

func NewServiceFormat(source string) Format

NewServiceFormat returns a Format for rendering using a Context

func NewServiceListFormat

func NewServiceListFormat(source string, quiet bool) Format

NewServiceListFormat returns a Format for rendering using a service Context

func NewSignerInfoFormat

func NewSignerInfoFormat() Format

NewSignerInfoFormat returns a Format for rendering a signer role info Context

func NewStackFormat

func NewStackFormat(source string) Format

NewStackFormat returns a format for use with a stack Context

func NewStatsFormat

func NewStatsFormat(source, osType string) Format

NewStatsFormat returns a format for rendering an CStatsContext

func NewTaskFormat

func NewTaskFormat(source string, quiet bool) Format

NewTaskFormat returns a Format for rendering using a task Context

func NewTrustTagFormat

func NewTrustTagFormat() Format

NewTrustTagFormat returns a Format for rendering using a trusted tag Context

func NewVolumeFormat

func NewVolumeFormat(source string, quiet bool) Format

NewVolumeFormat returns a format for use with a volume Context

func (Format) Contains

func (f Format) Contains(sub string) bool

Contains returns true if the format contains the substring

func (Format) IsTable

func (f Format) IsTable() bool

IsTable returns true if the format is a table-type format

type HeaderContext

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

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

type ImageContext struct {
	Context
	Digest bool
}

ImageContext contains image specific information required by the formatter, encapsulate a Context struct.

type ServiceListInfo

type ServiceListInfo struct {
	Mode     string
	Replicas string
}

ServiceListInfo stores the information about mode and replicas to be used by template

type SignedTagInfo

type SignedTagInfo struct {
	Name    string
	Digest  string
	Signers []string
}

SignedTagInfo represents all formatted information needed to describe a signed tag: Name: name of the signed tag Digest: hex encoded digest of the contents Signers: list of entities who signed the tag

type SignerInfo

type SignerInfo struct {
	Name string
	Keys []string
}

SignerInfo represents all formatted information needed to describe a signer: Name: name of the signer role Keys: the keys associated with the signer

type SignerInfoList

type SignerInfoList []SignerInfo

SignerInfoList helps sort []SignerInfo by signer names

func (SignerInfoList) Len

func (signerInfoComp SignerInfoList) Len() int

func (SignerInfoList) Less

func (signerInfoComp SignerInfoList) Less(i, j int) bool

func (SignerInfoList) Swap

func (signerInfoComp SignerInfoList) Swap(i, j int)

type Stack

type Stack struct {
	// Name is the name of the stack
	Name string
	// Services is the number of the services
	Services int
}

Stack contains deployed stack information.

type StatsEntry

type StatsEntry struct {
	Container        string
	Name             string
	ID               string
	CPUPercentage    float64
	Memory           float64 // On Windows this is the private working set
	MemoryLimit      float64 // Not used on Windows
	MemoryPercentage float64 // Not used on Windows
	NetworkRx        float64
	NetworkTx        float64
	BlockRead        float64
	BlockWrite       float64
	PidsCurrent      uint64 // Not used on Windows
	IsInvalid        bool
}

StatsEntry represents represents the statistics data collected from a container

type SubFormat

type SubFormat func(func(subContext) error) error

SubFormat is a function type accepted by Write()

Jump to

Keyboard shortcuts

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