Help us shape the future of Go! Take the 2026 Go Developer Survey

formatter

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerStatus

func ContainerStatus(ctx context.Context, c containerd.Container) string

func Ellipsis

func Ellipsis(str string, maxDisplayWidth int) string

func FormatLabels added in v0.22.1

func FormatLabels(labelMap map[string]string) string

func FormatPorts

func FormatPorts(labelMap map[string]string) string

func FormatSlice added in v1.2.0

func FormatSlice(format string, writer io.Writer, x []interface{}) error

FormatSlice formats the slice with `--format` flag.

--format="" (default): JSON --format='{{json .}}': JSON lines

FormatSlice is expected to be only used for `nerdctl OBJECT inspect` commands.

func InspectContainerCommand

func InspectContainerCommand(spec *oci.Spec, trunc, quote bool) string

func InspectContainerCommandTrunc

func InspectContainerCommandTrunc(spec *oci.Spec) string

func ParseTemplate added in v1.2.0

func ParseTemplate(format string) (*template.Template, error)

ParseTemplate wraps github.com/docker/cli/templates.Parse() to allow `json` as an alias of `{{json .}}`. ParseTemplate can be removed when https://github.com/docker/cli/pull/3355 gets merged and tagged (Docker 22.XX).

func TimeSinceInHuman

func TimeSinceInHuman(since time.Time) string

func ToJSON added in v1.1.0

func ToJSON(i interface{}, prefix string, indentation string) (string, error)

ToJSON return a string with the JSON representation of the interface{} https://github.com/docker/compose/blob/v2/cmd/formatter/json.go#L31C4-L39

Types

type Flusher added in v1.2.0

type Flusher interface {
	Flush() error
}

Flusher is implemented by text/tabwriter.Writer

Jump to

Keyboard shortcuts

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