printer

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTableColumns = []TableColumn{
	{
		TableColumnDefinition: metav1.TableColumnDefinition{
			Name:   "Name",
			Type:   "string",
			Format: "name",
		},
		Extract: func(rev history.Revision) any { return rev.Name() },
	},
	{
		TableColumnDefinition: metav1.TableColumnDefinition{
			Name: "Revision",
			Type: "integer",
		},
		Extract: func(rev history.Revision) any { return rev.Number() },
	},
	{
		TableColumnDefinition: metav1.TableColumnDefinition{
			Name: "Ready",
			Type: "string",
		},
		Extract: func(rev history.Revision) any {
			return fmt.Sprintf("%d/%d", rev.ReadyReplicas(), rev.CurrentReplicas())
		},
	},
	{
		TableColumnDefinition: metav1.TableColumnDefinition{
			Name: "Age",
			Type: "string",
		},
		Extract: func(rev history.Revision) any {
			return table.ConvertToHumanReadableDateType(rev.Object().GetCreationTimestamp())
		},
	},
	{
		TableColumnDefinition: metav1.TableColumnDefinition{
			Name:     "Containers",
			Type:     "string",
			Priority: 1,
		},
		Extract: func(rev history.Revision) any {
			var names []string
			for _, container := range rev.PodTemplate().Spec.Containers {
				names = append(names, container.Name)
			}
			return strings.Join(names, ",")
		},
	},
	{
		TableColumnDefinition: metav1.TableColumnDefinition{
			Name:     "Images",
			Type:     "string",
			Priority: 1,
		},
		Extract: func(rev history.Revision) any {
			var images []string
			for _, container := range rev.PodTemplate().Spec.Containers {
				images = append(images, container.Image)
			}
			return strings.Join(images, ",")
		},
	},
}

DefaultTableColumns is the list of default column definitions.

Functions

func Printable

func Printable(rev history.Revision, templateOnly bool) client.Object

Printable returns the actually printable object of a Revision based on the --template-only flag.

Types

type RevisionPrinter

type RevisionPrinter struct {
	Delegate     printers.ResourcePrinter
	TemplateOnly bool
}

RevisionPrinter prints revisions' objects or pod templates using the given delegate printer.

func (RevisionPrinter) PrintObj

func (p RevisionPrinter) PrintObj(obj runtime.Object, w io.Writer) error

PrintObj prints a revision or list of revisions to the given writer using the printer's delegate.

type RevisionsToTablePrinter

type RevisionsToTablePrinter struct {
	Delegate printers.ResourcePrinter

	// Columns is the list of columns that should be printed.
	Columns []TableColumn
}

RevisionsToTablePrinter transforms revision objects to a metav1.Table and passes it on to the delegate (table) printer.

func (RevisionsToTablePrinter) PrintObj

func (p RevisionsToTablePrinter) PrintObj(obj runtime.Object, w io.Writer) error

type TableColumn

type TableColumn struct {
	metav1.TableColumnDefinition
	Extract func(rev history.Revision) any
}

TableColumn represents a single column with a header and logic for extracting a revision's cell value.

Jump to

Keyboard shortcuts

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