formatter

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2018 License: Apache-2.0 Imports: 20 Imported by: 6

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 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 StackWrite

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

StackWrite writes formatted stacks using the Context

Types

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 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 NewStackFormat

func NewStackFormat(source string) Format

NewStackFormat returns a format for use with a stack 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 ServiceListInfo

type ServiceListInfo struct {
	Mode     string
	Replicas string
}

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

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