formatter

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 16 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 DisplayablePorts

func DisplayablePorts(ports []types.Port) string

DisplayablePorts formats the given ports information for displaying

func FormatLabels

func FormatLabels(labels map[string]string) string

FormatLabels returns the string representation of the given labels.

func FormatPorts

func FormatPorts(ports []swarm.PortConfig) string

FormatPorts returns the string representation of the given PortConfig

func FormatSwarmNetworks

func FormatSwarmNetworks(networks []swarm.NetworkAttachmentConfig) string

FormatSwarmNetworks returns the string representation of the given slice of NetworkAttachmentConfig

func PrettyPrint

func PrettyPrint(i interface{}) string

PrettyPrint creates a string representation of the given vale for human formatted output by uppercasing the first letter.

func TruncateID

func TruncateID(id string) string

TruncateID returns a shorthand version of the given string identifier

Types

type ContainerFormatter

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

ContainerFormatter knows how to pretty-print the information of a container

func NewContainerFormatter

func NewContainerFormatter(c *docker.Container, trunc bool) *ContainerFormatter

NewContainerFormatter creates a new container formatter

func (*ContainerFormatter) Command

func (c *ContainerFormatter) Command() string

Command prettifies the command that starts the container

func (*ContainerFormatter) CreatedAt

func (c *ContainerFormatter) CreatedAt() string

CreatedAt prettifies the command that starts the container

func (*ContainerFormatter) ID

func (c *ContainerFormatter) ID() string

ID prettifies the id

func (*ContainerFormatter) Image

func (c *ContainerFormatter) Image() string

Image prettifies the image used by the container

func (*ContainerFormatter) Labels

func (c *ContainerFormatter) Labels() string

Labels prettifies the container labels

func (*ContainerFormatter) Names

func (c *ContainerFormatter) Names() string

Names prettifies the container name(s)

func (*ContainerFormatter) Ports

func (c *ContainerFormatter) Ports() string

Ports prettifies the container port information

func (*ContainerFormatter) RunningFor

func (c *ContainerFormatter) RunningFor() string

RunningFor prettifies the that starts the container

func (*ContainerFormatter) Size

func (c *ContainerFormatter) Size() string

Size prettifies the container size

func (*ContainerFormatter) Status

func (c *ContainerFormatter) Status() string

Status prettifies the container status

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 Format

type Format string

Format is the format string rendered using the 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 ImageFormatter

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

ImageFormatter knows how to pretty-print the information of an image

func NewImageFormatter

func NewImageFormatter(image types.ImageSummary, trunc bool) *ImageFormatter

NewImageFormatter creates an image formatter

func (*ImageFormatter) CreatedSince

func (formatter *ImageFormatter) CreatedSince() string

CreatedSince prettifies the image creation date

func (*ImageFormatter) Digest

func (formatter *ImageFormatter) Digest() string

Digest prettifies the image digestv

func (*ImageFormatter) ID

func (formatter *ImageFormatter) ID() string

ID prettifies the id

func (*ImageFormatter) Repository

func (formatter *ImageFormatter) Repository() string

Repository prettifies the repository

func (*ImageFormatter) Size

func (formatter *ImageFormatter) Size() string

Size prettifies the image size

func (*ImageFormatter) Tag

func (formatter *ImageFormatter) Tag() string

Tag prettifies the tag

type NetworkFormatter

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

NetworkFormatter knows how to pretty-print the information of an network

func NewNetworkFormatter

func NewNetworkFormatter(network types.NetworkResource, trunc bool) *NetworkFormatter

NewNetworkFormatter creates an network formatter

func (*NetworkFormatter) Containers

func (formatter *NetworkFormatter) Containers() string

Containers prettifies the number of containers using the network

func (*NetworkFormatter) Driver

func (formatter *NetworkFormatter) Driver() string

Driver prettifies the network driver

func (*NetworkFormatter) Gateway

func (formatter *NetworkFormatter) Gateway() string

Gateway prettifies the network gateway

func (*NetworkFormatter) ID

func (formatter *NetworkFormatter) ID() string

ID prettifies the id

func (*NetworkFormatter) Name

func (formatter *NetworkFormatter) Name() string

Name prettifies the network name

func (*NetworkFormatter) Scope

func (formatter *NetworkFormatter) Scope() string

Scope prettifies the network scope

func (*NetworkFormatter) Services

func (formatter *NetworkFormatter) Services() string

Services prettifies the number of containers using the network

func (*NetworkFormatter) Subnet

func (formatter *NetworkFormatter) Subnet() string

Subnet prettifies the network subnet

type SubFormat

type SubFormat func(func(subContext) error) error

SubFormat is a function type accepted by Write()

type TaskStringer

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

TaskStringer converts to it string representation Task attributes

func NewTaskStringer

func NewTaskStringer(api docker.SwarmAPI, task swarm.Task, trunc bool) *TaskStringer

NewTaskStringer creates a TaskStringer for the given task

func (*TaskStringer) CurrentState

func (t *TaskStringer) CurrentState() string

CurrentState Task current state as a string

func (*TaskStringer) DesiredState

func (t *TaskStringer) DesiredState() string

DesiredState Task desired state as a string

func (*TaskStringer) Error

func (t *TaskStringer) Error() string

Error Task status error as a string

func (*TaskStringer) ID

func (t *TaskStringer) ID() string

ID Task id as a string

func (*TaskStringer) Image

func (t *TaskStringer) Image() string

Image Task image as a string

func (*TaskStringer) Name

func (t *TaskStringer) Name() string

Name Task name as a string

func (*TaskStringer) NodeID

func (t *TaskStringer) NodeID() string

NodeID Task nodeID as a string

func (*TaskStringer) Ports

func (t *TaskStringer) Ports() string

Ports Task ports as a string

Jump to

Keyboard shortcuts

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