output

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package output provides terminal output convenience helpers for namespace type icons and cgroup information rendering.

Index

Constants

View Source
const (
	IconFlagName = "icon"
)

Names of the CLI flags defined and used in this package.

Variables

View Source
var ControlGroupNameModes = map[ControlGroupNames][]string{
	CgroupShortened: {"short"},
	CgroupComplete:  {"full", "complete"},
}

ControlGroupNameModes specifies the mapping between the user-facing CLI flag values and the program-internal flag values.

NamespaceTypeIcons maps individual Linux-kernel namespace types (species.NNamespaceTypeIcons) to Unicode characters to be used as icons.

Functions

func ControlgroupDisplayName

func ControlgroupDisplayName(s string) string

ControlgroupDisplayName takes a control group name (path) and, depending on the display flags set, returns a name better suited for display. In particular, it optionally shortens 64 hex digit IDs as used by Docker for identifying containers to the Docker-typical 12 hex digit "digest".

func IconSetupCLI

func IconSetupCLI(rootCmd *cobra.Command)

IconSetupCLI is a plugin function that registers the CLI "--icon" flag.

func LabelSetupCLI

func LabelSetupCLI(cmd *cobra.Command)

LabelSetupCLI adds the flags for controlling control group name display.

func NamespaceIcon

func NamespaceIcon(ns model.Namespace) (icon string)

NamespaceIcon returns an Unicode string which can be displayed as an "icon" for the specified namespace. If showing namespace icons is disabled, then an empty string is always returned instead. If necessary, the returned string contains padding.

func NamespaceReferenceLabel

func NamespaceReferenceLabel(ns model.Namespace) string

NamespaceReferenceLabel returns a string describing a reference to the specified namespace, either in form of a (leader) process name and PID, or if there is no such process then in form of a filesystem reference.

Types

type ControlGroupNames

type ControlGroupNames enumflag.Flag

ControlGroupNames defines the enumeration flag type for controlling optimizing control group names for display (or not).

const (
	// CgroupShortened enables optimizing the display of Docker container IDs.
	CgroupShortened ControlGroupNames = iota
	// CgroupComplete switches off any display optimization of control group
	// names.
	CgroupComplete
)

Jump to

Keyboard shortcuts

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