kubectlk8s.io/kubectl/pkg/cmd/events Index | Files

package events

import "k8s.io/kubectl/pkg/cmd/events"

Index

Functions

func NewCmdEvents

func NewCmdEvents(restClientGetter genericclioptions.RESTClientGetter, streams genericiooptions.IOStreams) *cobra.Command

NewCmdEvents creates a new events command

Types

type EventPrinter

type EventPrinter struct {
	NoHeaders     bool
	AllNamespaces bool
	// contains filtered or unexported fields
}

EventPrinter stores required fields to be used for default printing for events command.

func NewEventPrinter

func NewEventPrinter(noHeader, allNamespaces bool) *EventPrinter

func (*EventPrinter) PrintObj

func (ep *EventPrinter) PrintObj(obj runtime.Object, out io.Writer) error

PrintObj prints different type of event objects.

type EventsFlags

type EventsFlags struct {
	RESTClientGetter genericclioptions.RESTClientGetter
	PrintFlags       *genericclioptions.PrintFlags

	AllNamespaces bool
	Watch         bool
	NoHeaders     bool
	ForObject     string
	FilterTypes   []string
	ChunkSize     int64
	genericiooptions.IOStreams
}

EventsFlags directly reflect the information that CLI is gathering via flags. They will be converted to Options, which reflect the runtime requirements for the command. This structure reduces the transformation to wiring and makes the logic itself easy to unit test.

func NewEventsFlags

func NewEventsFlags(restClientGetter genericclioptions.RESTClientGetter, streams genericiooptions.IOStreams) *EventsFlags

NewEventsFlags returns a default EventsFlags

func (*EventsFlags) AddFlags

func (flags *EventsFlags) AddFlags(cmd *cobra.Command)

AddFlags registers flags for a cli.

func (*EventsFlags) ToOptions

func (flags *EventsFlags) ToOptions() (*EventsOptions, error)

ToOptions converts from CLI inputs to runtime inputs.

type EventsOptions

type EventsOptions struct {
	Namespace     string
	AllNamespaces bool
	Watch         bool
	FilterTypes   []string

	PrintObj printers.ResourcePrinterFunc

	genericiooptions.IOStreams
	// contains filtered or unexported fields
}

EventsOptions is a set of options that allows you to list events. This is the object reflects the runtime needs of an events command, making the logic itself easy to unit test.

func (*EventsOptions) Run

func (o *EventsOptions) Run() error

Run retrieves events

func (*EventsOptions) Validate

func (o *EventsOptions) Validate() error

type SortableEvents

type SortableEvents []corev1.Event

SortableEvents implements sort.Interface for []api.Event by time

func (SortableEvents) Len

func (list SortableEvents) Len() int

func (SortableEvents) Less

func (list SortableEvents) Less(i, j int) bool

func (SortableEvents) Swap

func (list SortableEvents) Swap(i, j int)

Source Files

event_printer.go events.go

Version
v0.32.3 (latest)
Published
Mar 12, 2025
Platform
linux/amd64
Imports
27 packages
Last checked
5 days ago

Tools for package owners.