formatter

package
v1.10.16 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2017 License: Apache-2.0 Imports: 9 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 ContainerStatsWrite

func ContainerStatsWrite(ctx Context, containerStats []StatsEntry) error

ContainerStatsWrite renders the context for a list of containers statistics

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 Format

type Format string

Format is the format string rendered using the Context

func NewStatsFormat

func NewStatsFormat(source string) Format

NewStatsFormat returns a format for rendering an CStatsContext

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) AddHeader

func (c *HeaderContext) AddHeader(header string)

AddHeader adds another column to the header

func (*HeaderContext) FullHeader

func (c *HeaderContext) FullHeader() string

FullHeader returns the header as a string

type StatsEntry

type StatsEntry struct {
	Container        string
	Name             string
	ID               string
	CPUPercentage    float64
	Memory           float64
	MemoryLimit      float64
	MemoryPercentage float64
	NetworkRx        float64
	NetworkTx        float64
	BlockRead        float64
	BlockWrite       float64
	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